Swagger:需要类型数组,但在 #/paths/../parameters 处找到类型对象

Ped*_*pes 3 java api rest swagger swagger-2.0

我有一个带有服务的 YAML 文件,但我不断收到一些关于接收数组而不是对象的奇怪错误。

swagger: "2.0"
info:
    description: ""
    version: 1.0.0
    title: Your project
basePath: /
schemes:
  - http
paths: 
    /trocarProprietarioVeiculo:
        post:
            description: ""
            consumes: 
              -application/json
            produces: 
              -application/json
            parameters:
              -in: body
                schema: 
                  $ref: "#/definitions/TrocarProprietarioVeiculoChamada"
            responses:
                "200": 
                  description: ""
                  schema: 
                    $ref: "#/definitions/TrocarProprietarioVeiculoResposta"
definitions: 
    Resposta:
        type: object
        properties:
            erro:
                type: integer
            mensagens:
                type: array
                items:
                    type: string
    RespostaServico:
        type: object
        properties:
            resposta:
                $ref: "#/definitions/Resposta"
    TrocarProprietarioVeiculoChamada:
        type: object
        properties:
            chassi:
                type: string
            codigoCliente:
                type: integer
            nomeCliente:
                type: string
    TrocarProprietarioVeiculoResposta:
        type: object
        properties:
            respostaServico:
                $ref: "#/definitions/RespostaServico"
Run Code Online (Sandbox Code Playgroud)

显示的消息错误是:

  Swagger schema validation failed. 
  Expected type array but found type object at #/paths//trocarProprietarioVeiculo/post/parameters
  Expected type array but found type string at #/paths//trocarProprietarioVeiculo/post/produces
  Expected type array but found type string at #/paths//trocarProprietarioVeiculo/post/consumes

JSON_OBJECT_VALIDATION_FAILED
Run Code Online (Sandbox Code Playgroud)

我动态生成这个 YAML 文件。有任何关于我可以回答的问题,我很乐意回答!

Hel*_*len 5

将您的 YAML 粘贴到http://editor.swagger.io并按照提示进行操作。具体问题是:

-1)和 值之间必须有空格,例如:

- application/json
Run Code Online (Sandbox Code Playgroud)

2) body 参数需要 a name,并且所有属性必须对齐(具有相同的缩进):

- application/json
Run Code Online (Sandbox Code Playgroud)