Skip to content

Commit c3555ac

Browse files
committed
NullPointerException: Cannot invoke "java.util.Map.forEach(java.util.function.BiConsumer)" because "properties" is null. fixes #1098
1 parent 2cb6627 commit c3555ac

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

springdoc-openapi-data-rest/src/main/java/org/springdoc/data/rest/utils/SpringDocDataRestUtils.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ public void enhanceRequestBodyContent(OpenAPI openAPI, ResourceMetadata resource
114114
Schema newSchema = new ObjectSchema();
115115
newSchema.setRequired(existingSchema.getRequired());
116116
Map<String, Schema> properties = existingSchema.getProperties();
117-
properties.forEach((propId, val) -> updateRequestBodySchema(associationsFields, newSchema, propId, val));
117+
if (!CollectionUtils.isEmpty(properties))
118+
properties.forEach((propId, val) -> updateRequestBodySchema(associationsFields, newSchema, propId, val));
118119
schemas.put(newKey, newSchema);
119120
schema.set$ref(Components.COMPONENTS_SCHEMAS_REF + newKey);
120121
}
@@ -208,7 +209,7 @@ private void updateRequestBodySchema(List<String> associationsFields, Schema new
208209
* @param propId the prop id
209210
* @param val the val
210211
*/
211-
private void updateResponseSchema(Schema newSchema, Class<?> returnType, List<String> ignoredFields, String propId, Schema val) {
212+
private void updateResponseSchema(Schema newSchema, Class<?> returnType, List<String> ignoredFields, String propId, Schema val) {
212213
if (EMBEDDED.equals(propId)) {
213214
String entityClassName = linkRelationProvider.getCollectionResourceRelFor(returnType).value();
214215
ArraySchema arraySchema = (ArraySchema) ((ObjectSchema) val).getProperties().get(entityClassName);

0 commit comments

Comments
 (0)