fix(oas3): switching media types should update schema properties (#6518)
* When the media-type is changed, there is a new `onChangeMediaType` method to handle actions. * If target schema properties key/value pairs does NOT equals current schema properties, clear the requestBodyValue, try-it-out request/response and validation params. * If target schema properties key/value pairs DOES equals current schema properties, do not change or re-render schema properties * oas3Selector `validateShallowRequired` now also validates required keys against target media-type Fixes #6201, #6250, #6476
This commit is contained in:
@@ -514,6 +514,17 @@ export const getOAS3RequiredRequestBodyContentType = (state, pathMethod) => {
|
||||
return requiredObj
|
||||
}
|
||||
|
||||
export const isMediaTypeSchemaPropertiesEqual = ( state, pathMethod, currentMediaType, targetMediaType) => {
|
||||
let requestBodyContent = state.getIn(["resolvedSubtrees", "paths", ...pathMethod, "requestBody", "content"], fromJS([]))
|
||||
if (requestBodyContent.size < 2 || !currentMediaType || !targetMediaType) {
|
||||
// nothing to compare
|
||||
return false
|
||||
}
|
||||
let currentMediaTypeSchemaProperties = requestBodyContent.getIn([currentMediaType, "schema", "properties"], fromJS([]))
|
||||
let targetMediaTypeSchemaProperties = requestBodyContent.getIn([targetMediaType, "schema", "properties"], fromJS([]))
|
||||
return currentMediaTypeSchemaProperties.equals(targetMediaTypeSchemaProperties) ? true: false
|
||||
}
|
||||
|
||||
function returnSelfOrNewMap(obj) {
|
||||
// returns obj if obj is an Immutable map, else returns a new Map
|
||||
return Map.isMap(obj) ? obj : new Map()
|
||||
|
||||
Reference in New Issue
Block a user