Проблема с наследованием Swagger

У меня проблемы с использованием наследования с чванством. У меня есть следующее:

{
    "swagger": "2.0",
    "info": {
        "title": "Uber API",
        "description": "Move your app forward with the Uber API",
        "version": "1.0.0"
    },
    "host": "api.uber.com",
    "schemes": [
        "https"
    ],
    "basePath": "/v1",
    "produces": [
        "application/json"
    ],
    "paths": {
        "/products": {
            "post": {
                "summary": "Product Types",
                "description": "The Products endpoint returns information about the *Uber* products\noffered at a given location. The response includes the display name\nand other details about each product, and lists the products in the\nproper display order.\n",
                "parameters": [
                    {
                        "name": "error",
                        "in": "body",
                        "description": "Latitude component of location.",
                        "required": true,
                        "type": "",
                        "schema": {
                          "$ref": "#/definitions/ExtendedErrorModel"
                        }
                    }

                ],
                "tags": [
                    "Products"
                ],

            }
        }
    },

  "definitions": {
    "ErrorModel": {
      "type": "object",
      "required": [
        "message",
        "code"
      ],
      "properties": {
        "message": {
          "type": "string"
        },
        "code": {
          "type": "integer",
          "minimum": 100,
          "maximum": 600
        }
      }
    },
    "ExtendedErrorModel": {
      "allOf": [
        {
          "$ref": "#/definitions/ErrorModel"
        },
        {
          "type": "object",
          "required": [
            "rootCause"
          ],
          "properties": {
            "rootCause": {
              "type": "string"
            }
          }
        }
      ]
    }
  }
}

Когда я вижу пользовательский интерфейс и нажимаю «Попробовать это», я ожидаю увидеть поля для ExtendedErrorModel. Однако я просто вижу следующее, что неверно:

Как видите, типы данных кажутся правильными.

введите здесь описание изображения

Однако, когда вы посмотрите на поля try this, вы заметите два поля запроса (вместо одного) и ExtendedErrorModel, представляющий собой пустой раскрывающийся список.

введите здесь описание изображения

Сайт: http://editor.swagger.io/#/

Любые советы приветствуются, спасибо, D


person darewreck    schedule 23.12.2015    source источник


Ответы (1)


Предоставленное определение недействительно:

  • запятая после массива тегов "tags": ["Products"],
  • пропущенный ответ

Но главная проблема в том, что вы не можете использовать type и schema одновременно. Вы должны выбрать.

После исправления этих проблем и удаления type:'' редактор считает спецификацию действительной.

введите здесь описание изображения

Но онлайн-редактор на editor.swagger.io не показывает все параметры:

Ввод параметров

Если вы попробуете на https://swaggerhub.com, это сработает:

Ввод параметров на swaggerhub.com

Исправлена ​​спецификация:

swagger: '2.0'
info:
  title: Uber API
  description: Move your app forward with the Uber API
  version: 1.0.0
host: api.uber.com
schemes:
  - https
basePath: /v1
produces:
  - application/json
paths:
  /products:
    post:
      summary: Product Types
      description: |
        The Products endpoint returns information about the *Uber* products
        offered at a given location. The response includes the display name
        and other details about each product, and lists the products in the
        proper display order.
      parameters:
        - name: error
          in: body
          description: Latitude component of location.
          required: true
          schema:
            $ref: '#/definitions/ExtendedErrorModel'
      tags:
        - Products
      responses:
        200:
          description: OK
definitions:
  ErrorModel:
    type: object
    required:
      - message
      - code
    properties:
      message:
        type: string
      code:
        type: integer
        minimum: 100
        maximum: 600
  ExtendedErrorModel:
    allOf:
      - $ref: '#/definitions/ErrorModel'
      - type: object
        required:
          - rootCause
        properties:
          rootCause:
            type: string
person Arnaud Lauret    schedule 16.05.2016