2015-12-23 3 views
0

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

{ 
    "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" 
      } 
      } 
     } 
     ] 
    } 
    } 
} 

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

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

enter image description here

Однако, когда вы смотрите на попробовать это коробки вы увидите два запроса коробки (вместо одного) и ExtendedErrorModel быть пустым выпадающее поле

enter image description here

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

Любые советы оценили, Спасибо, D

ответ

0

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

  • запятая после метки массива "tags": ["Products"],
  • ответ отсутствует

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

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

enter image description here

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

Parameters input

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

Paramaters input on 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 
Смежные вопросы