2016-09-23 171 views
0

我已将https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#models-with-composition中的allOf示例应用于参数模式和响应模式。但是,我的allOf参数和响应显示为未定义。当只使用Pet而不是Cat时,它工作正常。请让我知道如何使用扬鞭的allOfSwagger的allOf显示为undefined

swagger: '2.0' 

# This is your document metadata 
info: 
    version: "0.0.0" 
    title: <enter your title> 

# Describe your paths here 
paths: 
    /test1: 
    # This is a HTTP operation 
    post: 
     description: bla bla 
     parameters: 
     - name: Pet 
      required: true 
      in: body 
      description: The Pet. 
      schema: 
      $ref: '#/definitions/Pet' 
     # Expected responses for this operation: 
     responses: 
     # Response code 
     200: 
      description: Successful response 
      schema: 
      $ref: '#/definitions/Pet' 
    /test2: 
    # This is a HTTP operation 
    post: 
     description: bla bla 
     parameters: 
     - name: Cat 
      required: true 
      in: body 
      description: The cat. 
      schema: 
      $ref: '#/definitions/Cat' 
     # Expected responses for this operation: 
     responses: 
     # Response code 
     200: 
      description: Successful response 
      schema: 
      $ref: '#/definitions/Cat' 
definitions: 
    Pet: 
    type: object 
    discriminator: petType 
    properties: 
     name: 
     type: string 
     petType: 
     type: string 
    required: 
    - name 
    - petType 
    Cat: 
    description: A representation of a cat 
    allOf: 
    - $ref: '#/definitions/Pet' 
    - type: object 
     properties: 
     huntingSkill: 
      type: string 
      description: The measured skill for hunting 
      default: lazy 
      enum: 
      - clueless 
      - lazy 
      - adventurous 
      - aggressive 
     required: 
     - huntingSkill 

enter image description here

enter image description here

回答

1

一个type场中缺少Cat定义对象,因此招摇编辑器显示undefined

添加type: object如下能解决这个问题:

Cat: 
    type: object 
    description: A representation of a cat 
    allOf: 
+0

谢谢!那让我疯狂。 – user1032531