我有一个带有服务的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"
显示的消息错误是:
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
这是我动态生成的YAML文件。如果有任何问题我可以回答,我很乐意回答!
答案 0 :(得分:3)
将您的YAML粘贴到http://editor.swagger.io并按照提示操作。具体问题是:
1)-
和值之间必须有空格,例如:
- application/json
2)body参数需要name
,所有属性必须对齐(具有相同的缩进):
- in: body
name: body
schema:
$ref: "#/definitions/TrocarProprietarioVeiculoChamada"