mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2026-03-22 19:29:08 +00:00
better NPE handling for undefined request body (#1896)
This commit is contained in:
@@ -4580,6 +4580,10 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
String name = null;
|
||||
LOGGER.debug("Request body = " + 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);
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(schema.get$ref())) {
|
||||
name = ModelUtils.getSimpleRef(schema.get$ref());
|
||||
schema = schemas.get(name);
|
||||
|
||||
Reference in New Issue
Block a user