From bcd7388a2d6416973074ba0a04e3a1a1e4ef7991 Mon Sep 17 00:00:00 2001 From: Oliwia Rogala Date: Thu, 18 Apr 2024 16:09:39 +0200 Subject: [PATCH] fix(config): sync SwaggerUI default options with swagger-ui-react (#9843) Refs #9838 --- flavors/swagger-ui-react/index.jsx | 67 +++++++++++------------------- src/core/index.js | 2 + 2 files changed, 27 insertions(+), 42 deletions(-) diff --git a/flavors/swagger-ui-react/index.jsx b/flavors/swagger-ui-react/index.jsx index 43aff411e1b..eeb687d02ad 100644 --- a/flavors/swagger-ui-react/index.jsx +++ b/flavors/swagger-ui-react/index.jsx @@ -124,48 +124,31 @@ SwaggerUI.propTypes = { } SwaggerUI.defaultProps = { - spec: "", - url: "", - layout: "BaseLayout", - requestInterceptor: req => req, - responseInterceptor: res => res, - supportedSubmitMethods: ["get", "put", "post", "delete", "options", "head", "patch", "trace"], - queryConfigEnabled: false, - plugins: [], - displayOperationId: false, - showMutatedRequest: true, - docExpansion: "list", - defaultModelExpandDepth: 1, - defaultModelsExpandDepth: 1, - defaultModelRendering: "example", - presets: [], - deepLinking: false, - showExtensions: false, - showCommonExtensions: false, - filter: false, - requestSnippetsEnabled: false, - requestSnippets: { - generators: { - "curl_bash": { - title: "cURL (bash)", - syntax: "bash" - }, - "curl_powershell": { - title: "cURL (PowerShell)", - syntax: "powershell" - }, - "curl_cmd": { - title: "cURL (CMD)", - syntax: "bash" - }, - }, - defaultExpanded: true, - languages: null, // e.g. only show curl bash = ["curl_bash"] - }, - tryItOutEnabled: false, - displayRequestDuration: false, - withCredentials: false, - persistAuthorization: false, + spec: SwaggerUIConstructor.defaultOptions.spec, + url: SwaggerUIConstructor.defaultOptions.url, + layout: SwaggerUIConstructor.defaultOptions.layout, + requestInterceptor: SwaggerUIConstructor.defaultOptions.requestInterceptor, + responseInterceptor: SwaggerUIConstructor.defaultOptions.responseInterceptor, + supportedSubmitMethods: SwaggerUIConstructor.defaultOptions.supportedSubmitMethods, + queryConfigEnabled: SwaggerUIConstructor.defaultOptions.queryConfigEnabled, + plugins: SwaggerUIConstructor.defaultOptions.plugins, + displayOperationId: SwaggerUIConstructor.defaultOptions.displayOperationId, + showMutatedRequest: SwaggerUIConstructor.defaultOptions.showMutatedRequest, + docExpansion: SwaggerUIConstructor.defaultOptions.docExpansion, + defaultModelExpandDepth: SwaggerUIConstructor.defaultOptions.defaultModelExpandDepth, + defaultModelsExpandDepth: SwaggerUIConstructor.defaultOptions.defaultModelsExpandDepth, + defaultModelRendering: SwaggerUIConstructor.defaultOptions.defaultModelRendering, + presets: SwaggerUIConstructor.defaultOptions.presets, + deepLinking: SwaggerUIConstructor.defaultOptions.deepLinking, + showExtensions: SwaggerUIConstructor.defaultOptions.showExtensions, + showCommonExtensions: SwaggerUIConstructor.defaultOptions.showCommonExtensions, + filter: SwaggerUIConstructor.defaultOptions.filter, + requestSnippetsEnabled: SwaggerUIConstructor.defaultOptions.requestSnippetsEnabled, + requestSnippets: SwaggerUIConstructor.defaultOptions.requestSnippets, + tryItOutEnabled: SwaggerUIConstructor.defaultOptions.tryItOutEnabled, + displayRequestDuration: SwaggerUIConstructor.defaultOptions.displayRequestDuration, + withCredentials: SwaggerUIConstructor.defaultOptions.withCredentials, + persistAuthorization: SwaggerUIConstructor.defaultOptions.persistAuthorization, oauth2RedirectUrl: undefined, } diff --git a/src/core/index.js b/src/core/index.js index 1cc4ac493f1..1274d332487 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -90,6 +90,8 @@ export default function SwaggerUI(userOptions) { SwaggerUI.System = System +SwaggerUI.defaultOptions = defaultOptions + SwaggerUI.presets = { base: BasePreset, apis: ApisPreset,