Skip to content

Allow disabling adding any generated servers to the OpenAPI servers list #1597

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mzeijen opened this issue Apr 6, 2022 · 7 comments
Closed
Labels
question Further information is requested

Comments

@mzeijen
Copy link

mzeijen commented Apr 6, 2022

We have a network setup where the host provided by the HTTP Request is not the actual host from which the user is requesting the OpenAPI definition. This results in a Server being added to the OpenAPI definition with the incorrect host name. Until now we have workaround this by simply not defining any servers, and in that case our SwaggerUI will figure out the correct one based on the browser URL.
However with SpringDoc I haven't found a way to prevent any servers from being added to the OpenAPI definition.

Can you add a property with which we can disable that a server is added to the OpenAPI definition automatically, when none is already present?

An alternative for us would be that we would need to require our developers to define the server manually per environment that they deploy their application on. However this is cumbersome and error prone. Simply not providing any servers is an easier and more reliable solution.
I have also tried overriding the server list with a server that uses an empty url string. Although Swagger UI can deal with this, it looks rather weird within the API definition and IMHO should not be the way to go.

@bnasslahsen
Copy link
Collaborator

@mzeijen,

use OpenApiCustomiser for that.

@bnasslahsen bnasslahsen added the question Further information is requested label Apr 6, 2022
@mzeijen
Copy link
Author

mzeijen commented Apr 6, 2022

@bnasslahsen Seriously! You don't even ask if I already tried that! Very rude to simply close this ticket without asking some feedback first!

Anyways, the problem with the OpenApiCustomiser is that it only gets executed when the OpenAPI definition is first created. After it is cached, and retrieved from the cache, the servers are added again. See the code here that does this: https://github.com/springdoc/springdoc-openapi/blob/master/springdoc-openapi-common/src/main/java/org/springdoc/api/AbstractOpenApiResource.java#L364

So, either that behaviour is a bug that needs to be fixed, which I am not sure of, or a property would be nice that disables the behaviour of a generated server.

@bnasslahsen
Copy link
Collaborator

@mzeijen,

Your initial comment is not even respecting the provided guidelines.

Remember, contributions to this repository should follow its contributing guidelines and code of conduct.

@mzeijen
Copy link
Author

mzeijen commented Apr 6, 2022

@bnasslahsen What do you mean, it doesn't follow the guidelines? I filled in the template as provided by Github, when I created this issue. What are you missing and I happily provide it.
Or do you mean that I forgot to mention that I already tried to use OpenApiCustomiser? I indeed didn't mention this explicitly in my initial story, but it was implied in the last paragraph with "I have also tried overriding the server list with a server that uses an empty url string". Sorry if that wasn't clear.

Also I am using Springdoc 1.6.6 (I should have mentioned this, but it wasn't being asked in the issue template).

@bnasslahsen
Copy link
Collaborator

@mzeijen,

Try reading the contributing guidelines.

@mzeijen
Copy link
Author

mzeijen commented Apr 7, 2022

@bnasslahsen I have read the contribution guidelines, and have believe I have complied to it in a reasonable fashion. But it seems you are not willing to tell what I did wrong. That is a pity, because this way I can't apply any corrections.

What I don't understand is that you do all this effort to provide this open source project and then you act like this against those that are using your project and are even willing to contribute to it (I wanted to contribute #1596 but in that case you where so friendly to actually already implement it). I understand you probably get a lot of issues reported that lack information because people didn't follow the your Github issue template (and please make sure that the Github template contains all the information that you want to get from someone , because people are not going to read the contribution guidelines all the time. That is just human nature), but I actually did my best to comply. I my self am a framework developer and I know this frustration all too well.

@wleese
Copy link

wleese commented Apr 21, 2022

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants