scottie1984 / swagger-ui-express

Adds middleware to your express app to serve the Swagger UI bound to your Swagger document. This acts as living documentation for your API hosted from within your app.
MIT License
1.43k stars 228 forks source link

Add a better way of UI customization (customJS) #292

Closed OSA413 closed 2 years ago

OSA413 commented 2 years ago

Moved from https://github.com/nestjs/swagger/issues/1881

Is your feature request related to a problem? Please describe it

I've been trying to implement an SSO (OAuth2) login on the API page opening, unfortunately I only found how to add it to headers, so that's not exactly what I needed. After some search I found that it's possible to customize page with customCss, customCssUrl, and customJs which with some effort should help me solve my issue.

Unfortunately, it "accepts absolute or relative path. Value must be the public url of the js file". So I'll have to write a pure JS script and put it somewhere on backend to accomplish my goal.

Describe the solution you'd like

For example, it can accept a function that will be converted into a JS file. Or it can accept a function and run it directly after the API page is loaded.

Or probably improve the feature as it was done with customCss https://github.com/scottie1984/swagger-ui-express/pull/9

scottie1984 commented 2 years ago

Added the ability to do customJsStr to the options:

Released: https://github.com/scottie1984/swagger-ui-express/releases/tag/4.4.0

Close from now.

jm12131415 commented 2 years ago

Please update TypeScript version as well.

scottie1984 commented 2 years ago

Typescript module isn’t maintained by myself