Skip to content

[Feature request]: Remove inline code in Swagger UI index.html #2881

@cremor

Description

@cremor

Is your feature request related to a specific problem? Or an existing feature?

Not really a problem, but I noticed something:
2 years ago Swagger UI removed their inline CSS and JavaScript from the index.html file. The current file is here, the reason for the change can be found in swagger-api/swagger-ui#7295

It would be nice if Swashbuckle.AspNetCore.SwaggerUI would also do it this way.

Describe the solution you'd like

The inline CSS can simply be replaced by a link to the index.css file, just like the original index.html does it now. This also has the benefit that future updates in the index.css file are available in Swashbuckle.AspNetCore.SwaggerUI automatically.

The inline JavaScript code in Swashbuckle.AspNetCore.SwaggerUI is heavily modified compared to the original code (now in the file swagger-initializer.js). The modified code could be extracted to a custom js file, but then SwaggerUIMiddleware would need to be changed to process that file instead of index.html.
Note: This might need additional consideration concerning Browser-side caching.

Additional context

The same might be true for Redoc UI, I haven't checked that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature suggestionhelp-wantedA change up for grabs for contributions from the community

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions