Add missing default configuration options
There are configuration options, such as modelPropertyMacro and parameterMacro, which do not have any default values defined in:
https://github.com/swagger-api/swagger-ui/blob/d5e56e5d75be4edc777fb8432a484e22af690bf1/src/core/config/defaults.js#L6
We need to identify all of the missing options and assign them default values.
The missing configs are:
- operationsSorter
- tagsSorter
- onComplete
- modelPropertyMacro
- parameterMacro
I think there is additional request.curlOptions as well. But needs to be researched first.
request.curlOptions is set inside of requestInterceptor:
This can be set on the mutated request in the requestInterceptor function. For example request.curlOptions = ["-g", "--limit-rate 20k"]
The default for it is:
requestInterceptor: (a) => a
so perhaps it should be:
requestInterceptor: (request) => {
request.curlOptions = null;
return request;
}
Potential default values for each of them:
- onComplete:
() => {}- defined asFunction=NOOPin documentation, used here: https://github.com/swagger-api/swagger-ui/blob/d5e56e5d75be4edc777fb8432a484e22af690bf1/src/core/plugins/on-complete/index.js#L13-L23 - modelPropertyMacro:
null- so that we don't run visitors / plugins for these - parameterMacro:
null - requestInterceptor / request.curlOptions:
(request) => { request.curlOptions = []; return request; } - operationsSorter:
null - tagsSorter:
null
operationsSorter and tagsSorter are used here:
https://github.com/swagger-api/swagger-ui/blob/d5e56e5d75be4edc777fb8432a484e22af690bf1/src/core/plugins/spec/selectors.js#L263-L279
Considering that they are supposed to be sorting functions, I think we should have them as null so that they don't run at all. In our configuration, it says that they are: Function=(a => a) and making that default wouldn't sort anything as well, so it's also an option.
Yes, good choice for the defaults. I would also go for a nullable-function (typecaster) for the onComplete for consistency. There is a check in code present to assert if it's a function.
For the curlOptions, as established in the PR already, we want to go for:
requestInterceptor: (request) => {
request.curlOptions = [];
return request;
}
Addressed in https://github.com/swagger-api/swagger-ui/pull/9949