Swagger UI 不在模型中显示枚举值
Swagger UI don't display enum values in models
我在使用 Swagger 时遇到了一个小问题 UI,我不确定这是否是错误...
我已经使用 Swagger Editor 描述了我的 API,并且我有一个包含枚举参数的方法。
现在,问题是:在生成的 Swagger-UI 文档中,在 'model' 选项卡中,我有一个 'messageType' 对象的空定义:( 我想显示允许的值(BRAND、VISITOR、COMMENT 和 RESPONSE)
要重现的代码片段:
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
有什么想法吗?我做错了吗?这是一个错误吗?
非常感谢:)
fehguy 是对的,通过在我的对象上添加 "type: string" 解决了问题 :)
我在使用 Swagger 时遇到了一个小问题 UI,我不确定这是否是错误...
我已经使用 Swagger Editor 描述了我的 API,并且我有一个包含枚举参数的方法。
现在,问题是:在生成的 Swagger-UI 文档中,在 'model' 选项卡中,我有一个 'messageType' 对象的空定义:( 我想显示允许的值(BRAND、VISITOR、COMMENT 和 RESPONSE)
要重现的代码片段:
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
有什么想法吗?我做错了吗?这是一个错误吗? 非常感谢:)
fehguy 是对的,通过在我的对象上添加 "type: string" 解决了问题 :)