使用 Swagger 获取解析错误

Getting a parse error with Swagger

我的项目要求坚持用Swagger写API规范。我正在学习本教程:APIHandyman

我已将以下 YAML 传递到 UI:

swagger: '2.0'

info:
  version: '1.0.0'
  title: 'Simple API'
  description: 'A simple API to learn how to write OPEN API Specificaiton'

# Added by API Auto Mocking Plugin
host: virtserver.swaggerhub.com
basePath: /xxxxxxx/Simple_API/1.0.0
schemes:
 - https

paths:
  /persons:
    get:
      summary: Gets some persons
      description: Returns a list containing all persons.
      responses:
        200:
          description: A list of Person
          schema:
            type: array
            items:
              required:
                - username
              properties:
                firstName:
                  type: string
                lastName:
                  type: string
                username:
                  type: string

我在编译器中遇到此错误:

我将不胜感激。

您也可以尝试将您的 swagger 导入此工具:

https://apibldr.com

它还可以让您直观地构建 API 定义。