SwaggerUI / YAML - 映射条目的分析器错误错误缩进

问题描述 投票:0回答:1

Screenshot of Swagger Editor & code您好,我是API测试和Swagger的新手,并且在Swagger编辑器中收到此解析器错误消息,我在查找问题时遇到问题。

Bellow是代码的复制粘贴。

错误消息是“映射条目的错误缩进”,并显示在 - > in: "path"的位置。

我按照YouTube教程 - > https://www.youtube.com/watch?v=CoUl9_NWdqQ

swagger: '2.0'
info:
  version: 'v1.0'
  title: 'Random'

# Added by API Auto Mocking Plugin
host: virtserver.swaggerhub.com
basePath: /GroovySalmon/DOITNOW/v1.0
schemes:
  - https

paths:
  /vehicles/{id}/data_request/drive_state:
    get:
      operationId: "drive_state"
      description: "Returns the driving and position state of the vehicle"
      parameters:
      **-name: "id"**
          in: "path"
          description: "The ID number of the car"
          required: true
          type: "String"
      responses:
        200:
          description: "Success"
          schema:
            properties:
              shift_state:
                type: "String"
                example: "sport"
              speed:
                type: "number"
                format: "double"
                example: 94.5
              latitude:
                description: "degrees north of the equator"
                type: "number"
                format: "double"
                example: 37.345
              longitude:
                description: "degrees west of the prime meridian"
                type: "number"
                format: "double"
                example: 122.1243
              heading:
                description: "integer compass heading"
                type: "integer"
                format: "int32"
                minimum: 0
                maximum: 359
                example: 4
              gps_as_of:
                description: "unix timestamp of gps fix"
                example: "1234934991232"
swagger swagger-2.0 swagger-editor
1个回答
0
投票

更改

type: "String"

type: "string"

注意“string”中的小写“s”。

所有OpenAPI type值都是小写且区分大小写的。

另外,确保在参数定义(以及一般的YAML列表)中​​的-之后有空格,并且缩进是正确的:

- name: "id"
  in: "path"
  ...
© www.soinside.com 2019 - 2024. All rights reserved.