在我需要设置的每个路径中consumes
and produces
。我可以全局设置它们吗?
post:
summary: ""
description: ""
consumes:
- "application/json"
- "application/xml"
produces:
- "application/xml"
- "application/json"
当然。您可以指定consumes
and produces
在规范的根级别,它们将被所有操作继承。全球的consumes
and produces
如果需要,可以在操作级别上覆盖。
swagger: '2.0'
...
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
...
更多信息:https://swagger.io/docs/specation/2-0/mime-types/ https://swagger.io/docs/specification/2-0/mime-types/
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)