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

[openapi] Add Ability to Configure Swagger UI #5639

Closed
valones opened this issue Nov 20, 2019 · 9 comments · Fixed by #12782
Closed

[openapi] Add Ability to Configure Swagger UI #5639

valones opened this issue Nov 20, 2019 · 9 comments · Fixed by #12782
Assignees
Labels
Milestone

Comments

@valones
Copy link

valones commented Nov 20, 2019

I can configure Swagger UI via URL query params, but would be nice if I could configure some params in application.properties file, like the docExpansion param for example.

swagger oficial doc: https://swagger.io/docs/open-source-tools/swagger-ui/usage/configuration/

@valones valones added the kind/enhancement New feature or request label Nov 20, 2019
@valones valones changed the title [openapi] Add Hability to Configure Swagger UI [openapi] Add Ability to Configure Swagger UI Nov 20, 2019
@gsmet
Copy link
Member

gsmet commented Nov 20, 2019

If you're familiar with Swagger UI, that could be a nice first issue to start contributing!

@valones
Copy link
Author

valones commented Nov 20, 2019

To be honest, my first contact with swagger was thanks to quarkus! :)
I just investigated how I could load the interface with the elements collapsed:
http://localhost:8080/swagger-ui/?docExpansion=none

@aoudiamoncef
Copy link
Contributor

@gsmet, what approach would you like to implement for configuring Swagger UI ?

Swagger UI accepts configuration parameters in four locations.
From lowest to highest precedence:

  1. The swagger-config.yaml in the project root directory, if it exists, is baked into the application
  2. configuration object passed as an argument to Swagger UI (SwaggerUI({ ... }))
  3. configuration document fetched from a specified configUrl
  4. configuration items passed as key/value pairs in the URL query string

Thanks

@aoudiamoncef
Copy link
Contributor

Hi @dmlloyd,
I studied the swagger-ui extension in order add this feature.
We could add all available customisations customisations as query parameters(All tagged as Docker variables in the doc).
Could i use an existing URL builder from Apache common for example or, i should build own utility class to avoid adding external dependencies ?

Thanks

@dmlloyd
Copy link
Member

dmlloyd commented Nov 25, 2019

Fewer dependencies is better, but other than that, I don't have an opinion. The most important thing is that it's correct (meaning, all URL components are correctly encoded).

@gsmet
Copy link
Member

gsmet commented Nov 25, 2019

Wouldn't The swagger-config.yaml in the project root directory, if it exists, is baked into the application be the more practical for us? We could generate it based on the configuration while building the application?

@gsmet
Copy link
Member

gsmet commented Nov 25, 2019

Oh wait, wouldn't it work to just have the user add a swagger-config.yaml to the src/main/resources/ directory?

If so, I would say let's just document it properly. I don't think it's a big problem if the file is only used in dev mode but still present in the prod application.

@aoudiamoncef
Copy link
Contributor

aoudiamoncef commented Nov 25, 2019

@gsmet,
I thought exactly like you, after adding it to the extension, it didn't work, why ? the swagger-config.yaml is inject when you build the hole project, we are using only the result of the project build in our web-jars.

We could inject at runtime all available variables in this file.

@misaunde
Copy link

I'd like to configure swagger-ui to display the request duration. It's just one tiny line of configuration. I'm new to Quarkus, but I was hoping I could just put displayRequestDuration=true in application.properties (the one config file to rule them all) and have it work, but it didn't appear to.

I also tried adding a swagger-config.yaml file at project root and even under the resources folder, but it didn't look like Quarkus paid attention to the file, contrary to swagger-ui's docs.

I even tried making an .evn file located at project root with the docker env varible, DISPLAY_REQUEST_DURATION=true, but that also appears to have been ignored.

Any updates on this or known workarounds?

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

Successfully merging a pull request may close this issue.

6 participants