diff --git a/pom.xml b/pom.xml
index 068995751..698c0771d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -71,7 +71,7 @@
1.6
2.5.3
1.6.8
- 2.1.1
+ 2.1.2
3.25.0
2.3.8.RELEASE
4.8.44
diff --git a/springdoc-openapi-common/src/main/java/org/springdoc/core/SpringDocAnnotationsUtils.java b/springdoc-openapi-common/src/main/java/org/springdoc/core/SpringDocAnnotationsUtils.java
index df826fa8a..a5b05e507 100644
--- a/springdoc-openapi-common/src/main/java/org/springdoc/core/SpringDocAnnotationsUtils.java
+++ b/springdoc-openapi-common/src/main/java/org/springdoc/core/SpringDocAnnotationsUtils.java
@@ -31,9 +31,11 @@
import io.swagger.v3.core.util.AnnotationsUtils;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.models.Components;
+import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Content;
import io.swagger.v3.oas.models.media.MediaType;
import io.swagger.v3.oas.models.media.Schema;
+import io.swagger.v3.oas.models.media.StringSchema;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
@@ -148,7 +150,15 @@ private static MediaType getMediaType(Schema schema, Components components, Json
MediaType mediaType = new MediaType();
if (!annotationContent.schema().hidden()) {
if (components != null) {
- getSchema(annotationContent, components, jsonViewAnnotation).ifPresent(mediaType::setSchema);
+ try {
+ getSchema(annotationContent, components, jsonViewAnnotation).ifPresent(mediaType::setSchema);
+ }
+ catch (Exception e) {
+ if (isArray(annotationContent))
+ mediaType.setSchema(new ArraySchema().items(new StringSchema()));
+ else
+ mediaType.setSchema(new StringSchema());
+ }
}
else {
mediaType.setSchema(schema);
@@ -157,4 +167,16 @@ private static MediaType getMediaType(Schema schema, Components components, Json
return mediaType;
}
+ private static boolean isArray(io.swagger.v3.oas.annotations.media.Content annotationContent){
+ Class> schemaImplementation = annotationContent.schema().implementation();
+ boolean isArray = false;
+ if (schemaImplementation == Void.class) {
+ schemaImplementation = annotationContent.array().schema().implementation();
+ if (schemaImplementation != Void.class) {
+ isArray = true;
+ }
+ }
+ return isArray;
+ }
+
}
diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app41.json b/springdoc-openapi-webmvc-core/src/test/resources/results/app41.json
index 4bc6a8146..1dd5b7139 100644
--- a/springdoc-openapi-webmvc-core/src/test/resources/results/app41.json
+++ b/springdoc-openapi-webmvc-core/src/test/resources/results/app41.json
@@ -13,6 +13,9 @@
"paths": {
"/file": {
"get": {
+ "tags": [
+ "hello-controller"
+ ],
"description": "Download file",
"operationId": "getFile",
"parameters": [
@@ -27,33 +30,33 @@
}
],
"responses": {
- "200": {
- "description": "File resource",
+ "500": {
+ "description": "Unexpected error",
"content": {
"application/json": {
"schema": {
- "type": "string",
- "format": "binary"
+ "type": "string"
}
}
}
},
- "400": {
- "description": "Wrong request",
+ "200": {
+ "description": "File resource",
"content": {
"application/json": {
"schema": {
- "type": "error"
+ "type": "string",
+ "format": "binary"
}
}
}
},
- "500": {
- "description": "Unexpected error",
+ "400": {
+ "description": "Wrong request",
"content": {
"application/json": {
"schema": {
- "type": "error"
+ "type": "string"
}
}
}
@@ -62,6 +65,5 @@
}
}
},
- "components": {
- }
-}
\ No newline at end of file
+ "components": {}
+}
diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app6.json b/springdoc-openapi-webmvc-core/src/test/resources/results/app6.json
index e0349c5d3..92251c969 100644
--- a/springdoc-openapi-webmvc-core/src/test/resources/results/app6.json
+++ b/springdoc-openapi-webmvc-core/src/test/resources/results/app6.json
@@ -29,7 +29,8 @@
"type": "string"
},
{
- "type": "integer"
+ "type": "integer",
+ "format": "int32"
}
]
},