fix(swagger-ui-react): use correct default prop values (#8976)
This commit is contained in:
@@ -17,9 +17,9 @@ export default class SwaggerUI extends React.Component {
|
|||||||
layout: this.props.layout,
|
layout: this.props.layout,
|
||||||
defaultModelsExpandDepth: this.props.defaultModelsExpandDepth,
|
defaultModelsExpandDepth: this.props.defaultModelsExpandDepth,
|
||||||
defaultModelRendering: this.props.defaultModelRendering,
|
defaultModelRendering: this.props.defaultModelRendering,
|
||||||
presets: [swaggerUIConstructor.presets.apis,...this.props.presets],
|
presets: [swaggerUIConstructor.presets.apis, ...this.props.presets],
|
||||||
requestInterceptor: this.requestInterceptor,
|
requestInterceptor: this.props.requestInterceptor,
|
||||||
responseInterceptor: this.responseInterceptor,
|
responseInterceptor: this.props.responseInterceptor,
|
||||||
onComplete: this.onComplete,
|
onComplete: this.onComplete,
|
||||||
docExpansion: this.props.docExpansion,
|
docExpansion: this.props.docExpansion,
|
||||||
supportedSubmitMethods: this.props.supportedSubmitMethods,
|
supportedSubmitMethods: this.props.supportedSubmitMethods,
|
||||||
@@ -30,11 +30,11 @@ export default class SwaggerUI extends React.Component {
|
|||||||
displayRequestDuration: this.props.displayRequestDuration,
|
displayRequestDuration: this.props.displayRequestDuration,
|
||||||
requestSnippetsEnabled: this.props.requestSnippetsEnabled,
|
requestSnippetsEnabled: this.props.requestSnippetsEnabled,
|
||||||
requestSnippets: this.props.requestSnippets,
|
requestSnippets: this.props.requestSnippets,
|
||||||
showMutatedRequest: typeof this.props.showMutatedRequest === "boolean" ? this.props.showMutatedRequest : true,
|
showMutatedRequest: this.props.showMutatedRequest,
|
||||||
deepLinking: typeof this.props.deepLinking === "boolean" ? this.props.deepLinking : false,
|
deepLinking: this.props.deepLinking,
|
||||||
showExtensions: this.props.showExtensions,
|
showExtensions: this.props.showExtensions,
|
||||||
showCommonExtensions: this.props.showCommonExtensions,
|
showCommonExtensions: this.props.showCommonExtensions,
|
||||||
filter: ["boolean", "string"].includes(typeof this.props.filter) ? this.props.filter : false,
|
filter: this.props.filter,
|
||||||
persistAuthorization: this.props.persistAuthorization,
|
persistAuthorization: this.props.persistAuthorization,
|
||||||
withCredentials: this.props.withCredentials,
|
withCredentials: this.props.withCredentials,
|
||||||
oauth2RedirectUrl: this.props.oauth2RedirectUrl
|
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 = () => {
|
onComplete = () => {
|
||||||
if (typeof this.props.onComplete === "function") {
|
if (typeof this.props.onComplete === "function") {
|
||||||
return this.props.onComplete(this.system)
|
return this.props.onComplete(this.system)
|
||||||
@@ -138,18 +124,25 @@ SwaggerUI.propTypes = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SwaggerUI.defaultProps = {
|
SwaggerUI.defaultProps = {
|
||||||
|
spec: {},
|
||||||
|
url: "",
|
||||||
layout: "BaseLayout",
|
layout: "BaseLayout",
|
||||||
|
requestInterceptor: req => req,
|
||||||
|
responseInterceptor: res => res,
|
||||||
supportedSubmitMethods: ["get", "put", "post", "delete", "options", "head", "patch", "trace"],
|
supportedSubmitMethods: ["get", "put", "post", "delete", "options", "head", "patch", "trace"],
|
||||||
queryConfigEnabled: false,
|
queryConfigEnabled: false,
|
||||||
|
plugins: [],
|
||||||
|
displayOperationId: false,
|
||||||
|
showMutatedRequest: true,
|
||||||
docExpansion: "list",
|
docExpansion: "list",
|
||||||
|
defaultModelExpandDepth: 1,
|
||||||
defaultModelsExpandDepth: 1,
|
defaultModelsExpandDepth: 1,
|
||||||
defaultModelRendering: "example",
|
defaultModelRendering: "example",
|
||||||
presets: [],
|
presets: [],
|
||||||
deepLinking: false,
|
deepLinking: false,
|
||||||
displayRequestDuration: false,
|
|
||||||
showExtensions: false,
|
showExtensions: false,
|
||||||
showCommonExtensions: false,
|
showCommonExtensions: false,
|
||||||
filter: false,
|
filter: null,
|
||||||
requestSnippetsEnabled: false,
|
requestSnippetsEnabled: false,
|
||||||
requestSnippets: {
|
requestSnippets: {
|
||||||
generators: {
|
generators: {
|
||||||
@@ -169,7 +162,11 @@ SwaggerUI.defaultProps = {
|
|||||||
defaultExpanded: true,
|
defaultExpanded: true,
|
||||||
languages: null, // e.g. only show curl bash = ["curl_bash"]
|
languages: null, // e.g. only show curl bash = ["curl_bash"]
|
||||||
},
|
},
|
||||||
|
tryItOutEnabled: false,
|
||||||
|
displayRequestDuration: false,
|
||||||
|
withCredentials: undefined,
|
||||||
persistAuthorization: false,
|
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
|
SwaggerUI.presets = swaggerUIConstructor.presets
|
||||||
|
|||||||
Reference in New Issue
Block a user