forked from loafle/openapi-generator-original
Fix null request body issue (#16376)
* suggestion how to fix #9217 * removed check for versions V2/v3 * removed useless import
This commit is contained in:
parent
134dc98a71
commit
35f5852cc0
@ -7496,9 +7496,6 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
String name = null;
|
String name = null;
|
||||||
LOGGER.debug("Request body = {}", body);
|
LOGGER.debug("Request body = {}", body);
|
||||||
Schema schema = ModelUtils.getSchemaFromRequestBody(body);
|
Schema schema = ModelUtils.getSchemaFromRequestBody(body);
|
||||||
if (schema == null) {
|
|
||||||
throw new RuntimeException("Request body cannot be null. Possible cause: missing schema in body parameter (OAS v2): " + body);
|
|
||||||
}
|
|
||||||
codegenParameter.setContent(getContent(body.getContent(), imports, "RequestBody"));
|
codegenParameter.setContent(getContent(body.getContent(), imports, "RequestBody"));
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(schema.get$ref())) {
|
if (StringUtils.isNotBlank(schema.get$ref())) {
|
||||||
@ -7563,7 +7560,6 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
updateRequestBodyForPrimitiveType(codegenParameter, schema, bodyParameterName, imports);
|
updateRequestBodyForPrimitiveType(codegenParameter, schema, bodyParameterName, imports);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
addJsonSchemaForBodyRequestInCaseItsNotPresent(codegenParameter, body);
|
addJsonSchemaForBodyRequestInCaseItsNotPresent(codegenParameter, body);
|
||||||
|
|
||||||
// set the parameter's example value
|
// set the parameter's example value
|
||||||
|
Loading…
x
Reference in New Issue
Block a user