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"
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
...
More info: https://swagger.io/docs/specification/2-0/mime-types/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With