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

Commit

Permalink
Grab schema for response schema table
Browse files Browse the repository at this point in the history
  • Loading branch information
uppal101 committed Oct 17, 2017
1 parent 1a651af commit 42a89e6
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 11 deletions.
6 changes: 2 additions & 4 deletions packages/api-explorer-ui/src/CodeSampleResponse.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ class CodeSampleResponse extends React.Component {
let allSecurities;
try {
allSecurities = operation.prepareSecurity();
} catch (e) {
console.log('No security endpoint here');
}
} catch (e) {} // eslint-disable-line no-empty

return (
<div
Expand Down Expand Up @@ -116,7 +114,7 @@ class CodeSampleResponse extends React.Component {

{result.statusCode[0] === 401 && (
<div className="text-center hub-expired-token">
{allSecurities.OAuth2[0] &&
{allSecurities &&
(allSecurities.OAuth2[0].flows.implicit.authorizationUrl &&
<div>
<p>Your OAuth2 token has expired</p>
Expand Down
1 change: 0 additions & 1 deletion packages/api-explorer-ui/src/Doc.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ class Doc extends React.Component {
});
})
.then(({ responseBody, res }) => {
console.log(res);
this.setState({
loading: false,
result: result(res, responseBody, req),
Expand Down
35 changes: 29 additions & 6 deletions packages/api-explorer-ui/src/Response.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,31 @@ class ResponseSchema extends React.Component {
const { operation } = this.props;
const keys = Object.keys(operation.responses);

let schema;

try {
if (operation.responses[this.state.selectedStatus].content) {
if (
operation.responses[this.state.selectedStatus].content['application/json'].schema.type ===
'object' &&
operation.responses[this.state.selectedStatus].content['application/json'].schema
.properties
) {
schema =
operation.responses[this.state.selectedStatus].content['application/json'].schema
.properties;
}
} else if (
operation.responses[this.state.selectedStatus].content['application/xml'].schema.type ===
'object' &&
operation.responses[this.state.selectedStatus].content['application/xml'].schema.properties
) {
schema =
operation.responses[this.state.selectedStatus].content['application/xml'].schema
.properties;
}
} catch (e) {} // eslint-disable-line no-empty

return (
<div className="hub-reference-response-definitions">
<h3>
Expand All @@ -49,21 +74,19 @@ class ResponseSchema extends React.Component {
{operation.responses[this.state.selectedStatus].description && (
<p className="desc">{operation.responses[this.state.selectedStatus].description}</p>
)}
{/* {operation.responses[this.state.selectedStatus].content.schema &&
operation.responses.schema.type === 'object' &&
operation.responses.schema.properties && (
{schema && (
<table>
{swaggerUtils.convertToParams([response], 'response').forEach(param => {
{/* {swaggerUtils.convertToParams([response], 'response').forEach(param => {
<tr>
<th>param.name</th>
<td>
param.type
{param.description && marked(param.description)}
</td>
</tr>;
})}
})} */}
</table>
)} */}
)}
</div>
</div>
);
Expand Down

0 comments on commit 42a89e6

Please sign in to comment.