2016-05-31 60 views
0

我面對的使用揚鞭UI有點問題,我還沒有確定wheter是一個bug或不...揚鞭UI不機型顯示枚舉值

我描述我的API使用Swagger編輯器,我有一個包含枚舉參數的方法。

現在,問題:在'模型'選項卡中生成的Swagger-UI文檔中,我有一個'messageType'對象的空定義:(我想顯示允許的值(BRAND,VISITOR,COMMENT和響應)

一個代碼片段重現:?

swagger: '2.0' 
info: 
    version: 1.0.0-SNAPSHOT 
    title: foo 
    description: foo 
host: dev.fr 
basePath: /base 
schemes: 
    - http 
    - https 
consumes: 
    - application/json 
produces: 
    - application/json 

paths: 
    /social/message: 
    post: 
     operationId: create 
     responses: 
     '201': 
      schema: 
      $ref: '#/definitions/message' 
     'default': 
      description: Default error response 

definitions: 
    message: 
    required: 
     - title 
     - messageType 
    properties: 
     title: 
     type: string 
     messageType: 
     $ref: '#/definitions/messageType' 

    messageType: 
    enum: 
     - COMMENT 
     - RESPONSE 

screen capture

任何想法,我做錯了它是一個錯誤 非常感謝:)

+2

您的'messageType'不聲明它是'type'。 'enum'在JSON模式中不是有效的類型。考慮將「type:string」添加爲枚舉的兄弟。 – fehguy

+0

你是正確的!謝謝 :) – hiveship

回答

0

fehguy是正確的,通過在我的對象中添加「type:string」來解決問題:)