首页 > 解决方案 > 将“条目”字段添加到组件的属性会破坏编译器

问题描述

我在招摇中遇到了一个非常奇怪的错误。

当尝试使用名为“条目”的属性渲染组件时,编译器会因错误而中断:

The provided definition does not specify a valid version field.

Please indicate a valid Swagger or OpenAPI version field.
Supported version fields are swagger: "2.0" and those that
match openapi: 3.0.n (for example, openapi: 3.0.0).

将返回此错误的示例:

openapi: 3.0.2
info:
  title: API Documentation
  version: '1'
paths:
  /v1/detail/:
    get:
      tags:
        - clips
      summary: Get details
      operationId: Create Detail
      description: Retrieve details
      parameters: []
      responses:
        '200':
          content:
            application/json:
              schema:
                type: object
                $ref: '#/components/schemas/Clip'
          description: ''
components:
  schemas:
    Clip:
      type: object
      properties:
        entries:
          type: string
          example: 'abc'

但是通过将条目重命名为其他名称,例如“x_entries”,编译器就可以了。

我在 openapi 文档中找不到任何对“条目”的引用,尽管我在这里可能是错的。有谁知道为什么“条目”作为组件中的属性会导致问题?

标签: swaggeropenapi

解决方案


Swagger UI v. 3.25.3 和 Swagger Editor v. 3.8.3 中的一个错误。

在 UI v. 3.25.4 和 Editor v. 3.9.0 中修复。


推荐阅读