本文介绍了我们可以设置全局“消耗"吗?和“产生"在招摇?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在每个路径中我需要设置consumes
和produces
.我可以全局设置它们吗?
In the each path I need to set consumes
and produces
. Can I set them globally?
post:
summary: ""
description: ""
consumes:
- "application/json"
- "application/xml"
produces:
- "application/xml"
- "application/json"
推荐答案
好的.您可以在规范的根级别指定 consumes
和 produces
,它们将被所有操作继承.如果需要,可以在操作级别覆盖全局 consumes
和 produces
.
Sure. You can specify consumes
and produces
on the root level of the spec, and they will be inherited by all operations. Global consumes
and produces
can be overridden on the operation level if needed.
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/specification/2-0/mime-types/
这篇关于我们可以设置全局“消耗"吗?和“产生"在招摇?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!