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 response schemas wouldn't always change states (#1081)
Browse files Browse the repository at this point in the history
resolves #1042
  • Loading branch information
erunion authored Dec 4, 2020
1 parent c9ebcee commit f2b2bd7
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/api-explorer/src/ResponseSchema.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,14 @@ class ResponseSchema extends React.Component {

render() {
const { operation, oas, useNewMarkdownEngine } = this.props;
const { selectedStatus } = this.state;
if (!operation.schema || !operation.schema.responses || Object.keys(operation.schema.responses).length === 0) {
return null;
}

const schema = this.getSchema(operation);

let response = operation.getResponseByStatusCode(this.state.selectedStatus);
let response = operation.getResponseByStatusCode(selectedStatus);

// @todo This should really be called higher up when the OAS is processed within the Doc component.
if (response.$ref) {
Expand All @@ -108,7 +109,14 @@ class ResponseSchema extends React.Component {
<div className="desc">{markdownMagic(response.description)}</div>
))}

{schema && <ResponseSchemaBody oas={oas} schema={schema} useNewMarkdownEngine={useNewMarkdownEngine} />}
{schema && (
<ResponseSchemaBody
key={`statusCode-${selectedStatus}`}
oas={oas}
schema={schema}
useNewMarkdownEngine={useNewMarkdownEngine}
/>
)}
</div>
</div>
);
Expand Down

0 comments on commit f2b2bd7

Please sign in to comment.