Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This PR allows additional configuration to be use in swagger-ui-react #5456

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions flavors/swagger-ui-react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ export default App = () => <SwaggerUI url="https://petstore.swagger.io/v2/swagge

These props map to [Swagger UI configuration options](https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/configuration.md) of the same name.

Not all the configuration options are described here. See [Swagger UI configuration options](https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/configuration.md) for the full set.

#### `spec`: PropTypes.object

An OpenAPI document respresented as a JavaScript object, JSON string, or YAML string for Swagger UI to display.
An OpenAPI document represented as a JavaScript object, JSON string, or YAML string for Swagger UI to display.

⚠️ Don't use this in conjunction with `url` - unpredictable behavior may occur.

Expand Down Expand Up @@ -73,7 +75,7 @@ Controls the default expansion setting for the operations and tags. It can be 'l

## Limitations

* Not all configuration bindings are available.
* Not all configuration bindings have been tested.
* Some props are only applied on mount, and cannot be updated reliably.
* OAuth redirection handling is not supported.
* Topbar/Standalone mode is not supported.
Expand Down
10 changes: 7 additions & 3 deletions flavors/swagger-ui-react/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,17 @@ export default class SwaggerUI extends React.Component {
}

componentDidMount() {
const {
requestInterceptor,
responseInterceptor,
onComplete,
...otherProps
} = this.props;
const ui = swaggerUIConstructor({
spec: this.props.spec,
url: this.props.url,
requestInterceptor: this.requestInterceptor,
responseInterceptor: this.responseInterceptor,
onComplete: this.onComplete,
docExpansion: this.props.docExpansion,
...otherProps
})

this.system = ui
Expand Down