fix(swagger-ui-react): use correct default prop values (#8976)

This commit is contained in:
Vladimír Gorej
2023-06-30 16:14:32 +02:00
committed by GitHub
parent cf5cfde690
commit f287339280

View File

@@ -18,8 +18,8 @@ export default class SwaggerUI extends React.Component {
defaultModelsExpandDepth: this.props.defaultModelsExpandDepth,
defaultModelRendering: this.props.defaultModelRendering,
presets: [swaggerUIConstructor.presets.apis, ...this.props.presets],
requestInterceptor: this.requestInterceptor,
responseInterceptor: this.responseInterceptor,
requestInterceptor: this.props.requestInterceptor,
responseInterceptor: this.props.responseInterceptor,
onComplete: this.onComplete,
docExpansion: this.props.docExpansion,
supportedSubmitMethods: this.props.supportedSubmitMethods,
@@ -30,11 +30,11 @@ export default class SwaggerUI extends React.Component {
displayRequestDuration: this.props.displayRequestDuration,
requestSnippetsEnabled: this.props.requestSnippetsEnabled,
requestSnippets: this.props.requestSnippets,
showMutatedRequest: typeof this.props.showMutatedRequest === "boolean" ? this.props.showMutatedRequest : true,
deepLinking: typeof this.props.deepLinking === "boolean" ? this.props.deepLinking : false,
showMutatedRequest: this.props.showMutatedRequest,
deepLinking: this.props.deepLinking,
showExtensions: this.props.showExtensions,
showCommonExtensions: this.props.showCommonExtensions,
filter: ["boolean", "string"].includes(typeof this.props.filter) ? this.props.filter : false,
filter: this.props.filter,
persistAuthorization: this.props.persistAuthorization,
withCredentials: this.props.withCredentials,
oauth2RedirectUrl: this.props.oauth2RedirectUrl
@@ -74,20 +74,6 @@ export default class SwaggerUI extends React.Component {
}
}
requestInterceptor = (req) => {
if (typeof this.props.requestInterceptor === "function") {
return this.props.requestInterceptor(req)
}
return req
}
responseInterceptor = (res) => {
if (typeof this.props.responseInterceptor === "function") {
return this.props.responseInterceptor(res)
}
return res
}
onComplete = () => {
if (typeof this.props.onComplete === "function") {
return this.props.onComplete(this.system)
@@ -138,18 +124,25 @@ 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,
displayRequestDuration: false,
showExtensions: false,
showCommonExtensions: false,
filter: false,
filter: null,
requestSnippetsEnabled: false,
requestSnippets: {
generators: {
@@ -169,7 +162,11 @@ SwaggerUI.defaultProps = {
defaultExpanded: true,
languages: null, // e.g. only show curl bash = ["curl_bash"]
},
tryItOutEnabled: false,
displayRequestDuration: false,
withCredentials: undefined,
persistAuthorization: false,
oauth2RedirectUrl: `${window.location.protocol}//${window.location.host}${window.location.pathname.substring(0, window.location.pathname.lastIndexOf("/"))}/oauth2-redirect.html`,
}
SwaggerUI.presets = swaggerUIConstructor.presets