昂首阔步未能解析我的参数

时间:2016-11-21 23:44:15

标签: yaml swagger

我有一个相对简单的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

我从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

1 个答案:

答案 0 :(得分:0)

更改

required: 'true'

required: true
引号中的

'true'是一个字符串,而不是布尔值。