Skip to content
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

An option to use static openapi definition file from resources instead of generated one #2929

Closed
bgalek opened this issue Mar 4, 2025 · 2 comments
Labels
question Further information is requested

Comments

@bgalek
Copy link

bgalek commented Mar 4, 2025

In my specific scenario, I would like to use springdoc so that my spring-boot application has swagger-ui nicely integrated, but I need to provide my own (manually created) OpenAPI definition file.

Describe the solution you'd like
I want to add the openapi.json file to my src/main/resources folder and set a springdoc property (a path to that file) so that /v3/api-docs endpoint returns my definition file for swagger-ui without any additional config. In other words, I want to override the automatically generated definition (so that the swagger-ui endpoint will return my file).

Describe alternatives you've considered

  • Adding a /v3/api-docs file to my src/main/resources/static files, so spring responds with it but it does not work as expected since spring will not set a proper content-type header (seems rather hacky)

Additional context
Having a generated file in the repository allows me to review changes reflected in openapi definition or I can use GithubApp that will do some validation/standardization on PR touching such file.

Do you think this feature request is valid?
Would you be ok with such feature added?

@bgalek bgalek changed the title Option to use static openapi definition file An option to use static openapi definition file from resources instead of generated one Mar 4, 2025
@bnasslahsen
Copy link
Collaborator

@bnasslahsen bnasslahsen added the question Further information is requested label Mar 22, 2025
@bgalek
Copy link
Author

bgalek commented Mar 22, 2025

@bnasslahsen Thank you for the reply. I tried this approach, but it requires some boilerplate code in my whole org (hundreds of repositories). This property springdoc.swagger-ui.url changes where the swagger frontend looks for the definition - instead - I'm looking for a way of changing the content of the existing endpoint - if that feature existed, I would not need to set an additional endpoint in my applications. We force each application (via k8s configmap) to serve their openapi on the same path - so we can scan it periodically and have a standard. I'm ok if you don't like this feature; just at least give it a thought :)

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

2 participants