Skip to content

Commit

Permalink
fix(swagger-ui-react): use correct default prop values (#8976)
Browse files Browse the repository at this point in the history
  • Loading branch information
char0n authored Jun 30, 2023
1 parent cf5cfde commit f287339
Showing 1 changed file with 19 additions and 22 deletions.
41 changes: 19 additions & 22 deletions flavors/swagger-ui-react/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ export default class SwaggerUI extends React.Component {
layout: this.props.layout,
defaultModelsExpandDepth: this.props.defaultModelsExpandDepth,
defaultModelRendering: this.props.defaultModelRendering,
presets: [swaggerUIConstructor.presets.apis,...this.props.presets],
requestInterceptor: this.requestInterceptor,
responseInterceptor: this.responseInterceptor,
presets: [swaggerUIConstructor.presets.apis, ...this.props.presets],
requestInterceptor: this.props.requestInterceptor,
responseInterceptor: this.props.responseInterceptor,
onComplete: this.onComplete,
docExpansion: this.props.docExpansion,
supportedSubmitMethods: this.props.supportedSubmitMethods,
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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: {
Expand All @@ -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
Expand Down

0 comments on commit f287339

Please sign in to comment.