Servers Section not working with openapi 3.*.* version
See original GitHub issueWhen switching to OpenApi 3.0.2, it is not possible to use servers section inside specification. https://swagger.io/docs/specification/api-host-and-base-path/
In OpenAPI 3.0, you use the servers array to specify one or more base URLs for your API. servers replaces the host, basePath and schemes keywords used in OpenAPI 2.0. Each server has an url and an optional Markdown-formatted description.
It would be nice if we can add this one (or any other OAS3 field) to swagger configuration.
Something like https://github.com/flasgger/flasgger/issues/318 can be done or even better add OPTIONAL_OAS3_FIELDS similar to OPTIONAL_FIELDS in https://github.com/flasgger/flasgger/blob/master/flasgger/constants.py.
Something like this: in base.py: instead of:
# enable 'components' when openapi_version is 3.*.*
if is_openapi3() and self.config.get("components"):
data["components"] = self.config.get(
'components'
)
->
# enable oas3 fields when openapi_version is 3.*.*
optional_oas3_fields = self.config.get('optional_oas3_fields') or \
OPTIONAL_OAS3_FIELDS
for key in optional_oas3_fields:
if is_openapi3() and self.config.get(key):
data[key] = self.config.get(key)
in constants.py:
OPTIONAL_OAS3_FIELDS = [
'components', 'servers'
]
Does anybody know how to bypass this issue until some change is introduced to the code base?
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (4 by maintainers)
I can definitely grant that if you want to continue to work on features related to OpenAPI 3. You can submit this pull request for now and then we can see where to go from there ☺️
Hi, @aleksvidak . The solution you offered seems good to me! Would you like to submit a pull request for that? I’ll definitely merge it.