Skip to content

Commit

Permalink
improvement: expose system object in swagger-ui-react's onComplete ca…
Browse files Browse the repository at this point in the history
…llback (via #5221)

* expose swagger object so it can be controlled in the onComplete function

* docs: swagger-ui-react onComplete system argument
  • Loading branch information
gschrader authored and shockey committed Mar 15, 2019
1 parent 65e8abd commit ccf17e9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions flavors/swagger-ui-react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,12 @@ Remote URL to an OpenAPI document that Swagger UI will fetch, parse, and display

#### `onComplete`: PropTypes.func

> `(system) => void`
A callback function that is triggered when Swagger-UI finishes rendering an OpenAPI document.

Swagger UI's `system` object is passed as an argument.

#### `requestInterceptor`: PropTypes.func

> `req => req` or `req => Promise<req>`.
Expand Down
4 changes: 2 additions & 2 deletions flavors/swagger-ui-react/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export default class SwaggerUI extends React.Component {

onComplete = () => {
if (typeof this.props.onComplete === "function") {
return this.props.onComplete()
return this.props.onComplete(this.system)
}
}
}
Expand All @@ -80,4 +80,4 @@ SwaggerUI.propTypes = {
requestInterceptor: PropTypes.func,
responseInterceptor: PropTypes.func,
onComplete: PropTypes.func,
}
}

0 comments on commit ccf17e9

Please sign in to comment.