Skip to content

Commit

Permalink
Pass down oauthUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
uppal101 committed Oct 30, 2017
1 parent 8611ed7 commit 50263b0
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
9 changes: 9 additions & 0 deletions example/src/Demo.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const React = require('react');
const swagger2openapi = require('swagger2openapi');
const refParser = require('json-schema-ref-parser');
const PropTypes = require('prop-types');
const extensions = require('../../packages/readme-oas-extensions/');

const createDocs = require('../../packages/api-explorer-ui/lib/create-docs');
Expand Down Expand Up @@ -62,6 +63,7 @@ class Demo extends React.Component {
'api-setting': Object.assign(extensions.defaults, this.state.oas),
}}
flags={{ correctnewlines: false }}
oauthUrl={this.props.oauthUrl}
/>
)
}
Expand All @@ -70,4 +72,11 @@ class Demo extends React.Component {
}
}

Demo.propTypes = {
oauthUrl: PropTypes.string,
};

Demo.defaultProps = {
oauthUrl: '',
};
module.exports = Demo;
6 changes: 4 additions & 2 deletions packages/api-explorer-ui/src/CodeSampleResponse.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class CodeSampleResponse extends React.Component {
}

render() {
const { result, oas, operation } = this.props;
const { result, oas, operation, oauthUrl } = this.props;
let allSecurities;
try {
allSecurities = operation.prepareSecurity();
Expand Down Expand Up @@ -133,7 +133,7 @@ class CodeSampleResponse extends React.Component {
<div className="text-center hub-expired-token">
{allSecurities.OAuth2 ? (
() => {
if (allSecurities.OAuth2[0].flows.implicit.authorizationUrl) {
if (oauthUrl) {
return (
<div>
<p>Your OAuth2 token has expired</p>
Expand Down Expand Up @@ -279,8 +279,10 @@ CodeSampleResponse.propTypes = {
result: PropTypes.shape({}),
oas: PropTypes.instanceOf(Oas).isRequired,
operation: PropTypes.instanceOf(Operation).isRequired,
oauthUrl: PropTypes.string,
};

CodeSampleResponse.defaultProps = {
result: {},
oauthUrl: '',
};
4 changes: 3 additions & 1 deletion packages/api-explorer-ui/src/Doc.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class Doc extends React.Component {
result={this.state.result}
oas={oas}
operation={operation}
hideResults={this.hideResults}
oauthUrl={this.props.oauthUrl}
/>
</div>
)}
Expand Down Expand Up @@ -202,9 +202,11 @@ Doc.propTypes = {
setLanguage: PropTypes.func.isRequired,
flags: PropTypes.shape({}),
language: PropTypes.string.isRequired,
oauthUrl: PropTypes.string,
};

Doc.defaultProps = {
oas: {},
flags: {},
oauthUrl: '',
};
6 changes: 6 additions & 0 deletions packages/api-explorer-ui/src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class ApiExplorer extends React.Component {
setLanguage={this.setLanguage}
flags={this.props.flags}
language={this.state.language}
oauthUrl={this.props.oauthUrl}
/>
))}
</div>
Expand All @@ -50,6 +51,11 @@ ApiExplorer.propTypes = {
docs: PropTypes.arrayOf(PropTypes.object).isRequired,
oasFiles: PropTypes.shape({}).isRequired,
flags: PropTypes.shape({}).isRequired,
oauthUrl: PropTypes.string,
};

ApiExplorer.defaultProps = {
oauthUrl: '',
};

module.exports = ApiExplorer;

0 comments on commit 50263b0

Please sign in to comment.