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

Commit

Permalink
Attempt to convert Response schema from jade to jsx
Browse files Browse the repository at this point in the history
  • Loading branch information
uppal101 committed Oct 2, 2017
1 parent bbe9386 commit 134756f
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/api-explorer-ui/src/Doc.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const extensions = require('../../readme-oas-extensions');
const PathUrl = require('./PathUrl');
const Params = require('./Params');
const CodeSample = require('./CodeSample');
const Response = require('./Response');

const Oas = require('./lib/Oas');
const showCode = require('./lib/show-code');
Expand Down Expand Up @@ -88,7 +89,9 @@ class Doc extends React.Component {
onSubmit={this.onSubmit}
/>
</div>
<div className="hub-reference-right switcher" />
<div className="hub-reference-right switcher">
<Response operation={operation} />
</div>
</div>
</div>
);
Expand Down
50 changes: 50 additions & 0 deletions packages/api-explorer-ui/src/Response.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
const React = require('react');
const PropTypes = require('prop-types');
const marked = require('./lib/markdown/index');
const convertToParams = require('../../../legacy-stuff/swagger');

function ResponseSchema({ swagger }) {
const i = 0;
return (
<div className="hub-reference-response-definitions">
<h3>
<div className="pull-right">
<select className="switcher-switch">
{swagger._endpoint.response.forEach((response, status) => (
<option value={status}>status</option>
))}
</select>
Response
{swagger._endpoint.response.forEach((response, status) => {
<div switcher={status} style={i === 0 ? '' : 'display: none'}>
{response.description &&
<p desc={response.description} />(
response.schema &&
response.schema.type === 'object' &&
response.schema.properties,
)(
<table>
{swaggerUtils.convertToParams([response], 'response').forEach(param => {
<tr>
<th>param.name</th>
<td>
param.type
{param.description && marked(param.description)}
</td>
</tr>;
})}
</table>,
)}
</div>;
})}
</div>
</h3>
</div>
);
}

ResponseSchema.PropTypes = {
swagger: PropTypes.shape({}).isRequired,
};

module.exports = ResponseSchema;

0 comments on commit 134756f

Please sign in to comment.