2016-09-23 5 views
0

Ich habe die allof Beispiele in https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#models-with-composition nehmen, und wandte sie auf Parameter Schema und Antworten-Schema. Meine allOf Parameter und Antworten werden jedoch als nicht definiert angezeigt. Wenn man Pet statt Cat benutzt, funktioniert es gut. Bitte lassen Sie mich wissen, wie allofSwaggers allof zeigt sich als 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

Antwort

1

A type Feld Swaggers zu verwenden ist in Cat Definitionen fehlt Objekt und damit Prahlerei-Editor zeigt undefined.

hinzufügen type: object wie folgt kann es beheben:

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

Thank you! Das hat mich verrückt gemacht. – user1032531