question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Servers Section not working with openapi 3.*.* version

See original GitHub issue

When 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:closed
  • Created 4 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
billyrrrcommented, Feb 27, 2020

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 ☺️

1reaction
billyrrrcommented, Feb 26, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

API Server and Base Path - Swagger
In OpenAPI 3.0, you use the servers array to specify one or more base URLs for your API. ... Note: Server URL must...
Read more >
Step 3: The servers object (OpenAPI tutorial)
In the servers object, you specify the basepath used in your API requests. The basepath is the part of the URL that appears...
Read more >
REST API and Resource Versions - Tableau Help
The API version defines a set of resource versions that ship with a given release of Tableau Server (such as 2019.4). Versions of...
Read more >
Using OpenAPI and Swagger UI - Quarkus
Another option, that is a feature provided by SmallRye and not part of the specification, ... version: "1.0" servers: - url: http://localhost:8080/q/openapi ......
Read more >
SpringDoc openAPI tool not scanning for APIs in Spring Boot ...
I faced same problem when i try to develop in Spring Boot 3 env. Swagger-UI and docs not working ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found