Swagger 的 allOf 显示为未定义

Swagger's allOf shows up as undefined

我已经采用了 https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#models-with-composition 中的所有示例,并将它们应用于参数架构和响应架构。但是,我的所有参数和响应都显示为未定义。当只使用 Pet 而不是 Cat 时,它工作正常。请让我知道如何使用 Swagger 的 allOf

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

Cat 定义对象中缺少 type 字段,因此 swagger-editor 显示 undefined

添加type: object如下可以修复它:

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