Skip to content

Commit 33f8338

Browse files
committed
Prevent RequestBody from accessing a media type that ceased to exist
1 parent 44bd85a commit 33f8338

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/core/components/content-type.jsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ export default class ContentType extends React.Component {
2727
}
2828
}
2929

30+
componentWillReceiveProps(nextProps) {
31+
if(!nextProps.contentTypes || !nextProps.contentTypes.size) {
32+
return
33+
}
34+
35+
if(!nextProps.contentTypes.includes(nextProps.value)) {
36+
nextProps.onChange(nextProps.contentTypes.first())
37+
}
38+
}
39+
3040
onChangeWrapper = e => this.props.onChange(e.target.value)
3141

3242
render() {

src/core/plugins/oas3/components/request-body.jsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ const RequestBody = ({
2222

2323
const mediaTypeValue = requestBodyContent.get(contentType)
2424

25+
if(!mediaTypeValue) {
26+
return null
27+
}
28+
2529
return <div>
2630
{ requestBodyDescription &&
2731
<Markdown source={requestBodyDescription} />

0 commit comments

Comments
 (0)