I have this YAML file with a service, but I keep getting some wierd error about receiveing a array instead of a object.
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"
The message error shown is:
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
This YAML file I am generating dynamically. Any questions about anything that I may answer, I'd be glad to answer!
Paste your YAML into http://editor.swagger.io and follow the tips. The specific problems are:
1) There must be spaces between - and the values, e.g.:
- application/json
2) The body parameter needs a name, and all attributes must be aligned (have the same indentation):
- in: body
name: body
schema:
$ref: "#/definitions/TrocarProprietarioVeiculoChamada"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With