flask-restx icon indicating copy to clipboard operation
flask-restx copied to clipboard

Improve Swagger UI Config Support

Open SteadBytes opened this issue 6 years ago • 8 comments

https://github.com/python-restx/flask-restx/pull/14#issuecomment-575570447

A general solution to configuring Swagger UI JavaScript options will eliminate the need for adding in one off Flask config options whenevr a user requests them.

TODO: Further details and document current ideas. This is mainly here as a placeholder so the issue doesn't get lost.

SteadBytes avatar Jan 17 '20 10:01 SteadBytes

Hello, following up the discussion on #100. What do you think about the following solution. Firstly, we have SWAGGER_UI_OPTIONS in config whic is a dict object. The keys of the dict have to be valid swagger options e.g:

SWAGGER_UI_OPTIONS = {
    displayOperationId: false,
    docExpansion: 'none'
    ....
}

Then when parsing the options in swagger-ui.html, we can make use of the spread operator in case a default option is being overriden like so:

const options = {{ config.SWAGGER_UI_OPTIONS | default({}) | tojson }}
const ui = window.ui = new SwaggerUIBundle({
    // Other options
    ...options
})

michaelbukachi avatar Mar 25 '20 15:03 michaelbukachi

I like this idea. I'll give it a try when I have a moment.

Thanks for the suggestion.

ziirish avatar Mar 29 '20 17:03 ziirish

@ziirish Have you been able to take a look at this?

michaelbukachi avatar May 31 '20 19:05 michaelbukachi

Is there any discussion to add this configuration?

DEFAULT_MODELS_EXPAND_DEPTH = -1

engmsilva avatar Aug 16 '20 01:08 engmsilva

@engmsilva The plan is to support all configurations so that developers can specify what configurations they want to pass into swagger.

michaelbukachi avatar Aug 16 '20 18:08 michaelbukachi

+1

fjbf avatar Dec 27 '20 08:12 fjbf

Is there any news about support additional Swagger options?

dshein-alt avatar Oct 29 '21 10:10 dshein-alt

Hi, any updates on this? +1 I would use this feature

If we're just waiting on someone to implement it, I can do it

kjwill avatar Aug 29 '22 23:08 kjwill