diff --git a/src/main/java/io/swagger/codegen/v3/generators/DefaultCodegenConfig.java b/src/main/java/io/swagger/codegen/v3/generators/DefaultCodegenConfig.java index d6f59b9711..e4ff43f023 100644 --- a/src/main/java/io/swagger/codegen/v3/generators/DefaultCodegenConfig.java +++ b/src/main/java/io/swagger/codegen/v3/generators/DefaultCodegenConfig.java @@ -3770,7 +3770,9 @@ protected Schema getSchemaFromResponse(ApiResponse response) { Schema schema = null; for (String contentType : response.getContent().keySet()) { schema = response.getContent().get(contentType).getSchema(); - schema.addExtension("x-content-type", contentType); + if (schema != null) { + schema.addExtension("x-content-type", contentType); + } break; } return schema;