假设我有以下路线:
paths:
/data:
get:
summary: Get list of securities based on filter
parameters:
- name: market
in: query
description: Filter securities by market id, default ```all```
type: string
default: all
我如何添加一个可以使用的值列表?
这甚至支持吗?我看到一个enum
字段,但在添加到任何参数时我一直都会遇到错误。
答案 0 :(得分:3)
enum
是要走的路。您可以在enum
下为参数和属性指定值列表。以下是一个例子:
---
swagger: '2.0'
info:
version: 0.0.0
title: Simple API
paths:
/data:
get:
summary: Get list of securities based on filter
parameters:
- name: market
in: query
description: Filter securities by market id, default ```all```
type: string
default: all
enum:
- all
- market1
- market2
responses:
200:
description: OK
您可以将上面的内容复制并粘贴到swagger-editor以查看输出。