2 回答
TA贡献1946条经验 获得超4个赞
将命名类型添加到模式并使用它:
paths:
/echo:
get:
parameters:
- name: someEnum
in: query
required: true
schema:
$ref: '#/components/schemas/MyEnum'
responses:
200:
description: Success
content:
text/plain:
schema:
type: string
components:
schemas:
MyEnum:
type: string
enum: [A,B,C]
TA贡献1936条经验 获得超6个赞
在部分中定义您的枚举架构components/schemas,并$ref从参数定义中定义它,如下所示。在这种情况下,Swagger Codegen 会将枚举生成为实际的 Java 枚举。
openapi: 3.0.0
...
paths:
/echo:
get:
parameters:
- name: someEnum
in: query
required: true
schema:
$ref: '#/components/schemas/MyEnum'
...
components:
schemas:
MyEnum:
type: string
enum: [A, B, C]
添加回答
举报