Nathan Tregillus Nathan Tregillus - 16 days ago 6
YAML Question

swagger failing to parse my parameters

I have a relatively simple swagger doc, that is not getting parsed, and the error message i am getting when validating it does't make sense to me:

below is my swagger doc:

---
swagger: '2.0'
info:
version: 1.0.0
title: Required APIs for Loan Provider
schemes:
- https
consumes:
- application/json
produces:
- application/json
paths:
"/loan/{LoanGuid}/":
post:
description: initiation api for starting a loan
operationId: InitLoan
produces:
- application/json
parameters:
- name: LoanGuid
in: path
type: string
required: 'true'
- name: body
in: body
schema:
"$ref": "#/definitions/CreditApp"
responses:
'200':
description: successful submittion of a loan
schema:
"$ref": "#/definitions/LoanDetails"
'400':
description: validation error
schema:
"$ref": "#/definitions/Error"
'500':
description: unknown exception
schema:
"$ref": "#/definitions/Error"
definitions:
Error:
title: Non Successful Response
type: object
properties:
LoanGuid:
description: the unique identifier for the loan
type: string
Error:
type: string
CreditApp:
title: Credit Application
type: object
properties:
FirstName:
type: string
MiddleName:
type: string
LastName:
type: string
Address:
title: Address
type: object
properties:
Street:
type: string
Street2:
type: string
City:
type: string
State:
type: string
Zip:
type: string
LoanDetails:
title: Loan Details
type: object
properties:
FirstName:
type: string
MiddleName:
type: string
LastName:
type: string


I am getting the following exception from http://editor.swagger.io/#/

Not a valid parameter definition
Jump to line 19
Details
Object
code: "ONE_OF_MISSING"
params: Array [0]
message: "Not a valid parameter definition"
path: Array [5]
0: "paths"
1: "/loan/{LoanGuid}/"
2: "post"
3: "parameters"
4: "0"
schemaId: "http://swagger.io/v2/schema.json#"
inner: Array [2]
0: Object
code: "ONE_OF_MISSING"
params: Array [0]
message: "Data does not match any schemas from 'oneOf'"
path: Array [5]
inner: Array [2]
1: Object
code: "OBJECT_MISSING_REQUIRED_PROPERTY"
params: Array [1]
message: "Missing required property: $ref"
path: Array [5]
level: 900
type: "Swagger Error"
description: "Not a valid parameter definition"
lineNumber: 19

Answer

Change

required: 'true'

to

required: true

'true' in quotes is a string and not a boolean.