public Status validateResponseContent ( Object responseContent , OpenApiOperation openApiOperation , String statusCode , String mediaTypeName ) { //try to convert json string to structured object if ( responseContent instanceof String ) { responseContent = convertStrToObjTree ( ( String ) responseContent ) ; } JsonNode schema = getContentSchema ( openApiOperation , statusCode , mediaTypeName ) ; //if cannot find schema based on status code, try to get from "default" if ( schema == null || schema . isMissingNode ( ) ) { // if corresponding response exist but also does not contain any schema, pass validation if ( openApiOperation . getOperation ( ) . getResponses ( ) . containsKey ( String . valueOf ( statusCode ) ) ) { return null ; } schema = getContentSchema ( openApiOperation , DEFAULT_STATUS_CODE , mediaTypeName ) ; // if default also does not contain any schema, pass validation if ( schema == null || schema . isMissingNode ( ) ) return null ; } if ( ( responseContent != null && schema == null ) || ( responseContent == null && schema != null ) ) { return new Status ( VALIDATOR_RESPONSE_CONTENT_UNEXPECTED , openApiOperation . getMethod ( ) , openApiOperation . getPathString ( ) . original ( ) ) ; } config . setTypeLoose ( false ) ; return schemaValidator . validate ( responseContent , schema , config ) ; }
validate a given response content object