Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
Fix issue where a security scheme not existing causing the render to …
Browse files Browse the repository at this point in the history
…fail

Also added support to the Demo where you can either give it a swagger or an OAS file
  • Loading branch information
Dom Harrington committed Oct 31, 2017
1 parent 8e09a1c commit cffa392
Show file tree
Hide file tree
Showing 5 changed files with 155 additions and 289 deletions.
31 changes: 17 additions & 14 deletions example/src/Demo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,28 @@ class Demo extends React.Component {
this.updateStatus('Fetching swagger file', () => {
fetch(url)
.then(res => res.json())
.then(this.convertSwagger);
.then((json) => {
if (json.swagger) return this.convertSwagger(json);

return this.dereference(json);
});
});
}
dereference(oas) {
this.createDocs(oas);
this.updateStatus('Dereferencing swagger file', async () => {
this.setState({ oas: await refParser.dereference(oas) });
this.updateStatus('Done!', () => {
setTimeout(() => {
this.setState({ status: [] });
}, 1000);
});
});
}
convertSwagger(swagger) {
this.updateStatus('Converting swagger file to OAS 3', () => {
swagger2openapi.convertObj(swagger, {})
.then((result) => {
const oas = result.openapi;
this.createDocs(oas);

this.updateStatus('Dereferencing swagger file', async () => {
this.setState({ oas: await refParser.dereference(oas) });
this.updateStatus('Done!', () => {
setTimeout(() => {
this.setState({ status: [] });
}, 1000);
});
});
});
.then(({ openapi }) => this.dereference(openapi));
});
}
createDocs(oas) {
Expand Down
Loading

0 comments on commit cffa392

Please sign in to comment.