swagger-api / swagger-ui

Swagger UI is a collection of HTML, JavaScript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API.
https://swagger.io
Apache License 2.0
26.06k stars 8.87k forks source link

Add type casting for Swagger UI configuration options #9808

Closed glowcloud closed 3 months ago

glowcloud commented 3 months ago

When the configuration options are defined in the URL query parameters, we are actually getting strings. This causes issues if the value of the configuration parameter should not be a string.

For example, for deepLinking we should actually have a boolean value, but instead we'll have a string "true". This means that this configuration option won't actually be activated.

To fix this, we need to cast values into proper types if we can, ex. for number and boolean. We won't be parsing object and array type values.

char0n commented 3 months ago

Le'ts concentrate the type casting int config/type-cast module. We will map path to the typecaster to make the design declarative.

const Boolean = (string) => boolean

Map
 - syntaxHighlight.activated: Boolean

We want to apply the typecasting as a last operation in the merge function.

glowcloud commented 3 months ago

Addressed in https://github.com/swagger-api/swagger-ui/pull/9829

glowcloud commented 3 months ago

Released as https://github.com/swagger-api/swagger-ui/releases/tag/v5.16.0