Skip to content

Commit

Permalink
fix(swagger-ui-react): load spec on initial render (#7856)
Browse files Browse the repository at this point in the history
Refs #7578
  • Loading branch information
char0n committed Feb 21, 2022
1 parent 2d4623a commit a81341d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions flavors/swagger-ui-react/index.jsx
Expand Up @@ -46,7 +46,8 @@ export default class SwaggerUI extends React.Component {
}

componentDidUpdate(prevProps) {
if(this.props.url !== prevProps.url) {
const prevStateUrl = this.system.specSelectors.url()
if(this.props.url !== prevStateUrl || this.props.url !== prevProps.url) {
// flush current content
this.system.specActions.updateSpec("")

Expand All @@ -58,7 +59,8 @@ export default class SwaggerUI extends React.Component {
}
}

if(this.props.spec !== prevProps.spec && this.props.spec) {
const prevStateSpec = this.system.specSelectors.specStr()
if(this.props.spec && (this.props.spec !== prevStateSpec || this.props.spec !== prevProps.spec)) {
if(typeof this.props.spec === "object") {
this.system.specActions.updateSpec(JSON.stringify(this.props.spec))
} else {
Expand Down

0 comments on commit a81341d

Please sign in to comment.