在每个路径中,我需要设置consumes
和produces
。我可以在全球范围内设置它们吗?
post:
summary: ""
description: ""
consumes:
- "application/json"
- "application/xml"
produces:
- "application/xml"
- "application/json"
答案 0 :(得分:7)
不确定。您可以在规范的根级别指定consumes
和produces
,并且它们将由所有操作继承。如果需要,可以在操作级别覆盖全局consumes
和produces
。
consumes:
- application/json
- application/xml
produces:
- application/xml
- application/json
paths:
/foo:
get:
# This inherits global `produces`
...
post:
# Here we override global `consumes`
consumes:
- application/x-www-form-urlencoded
...