Skip to content

Commit

Permalink
Use SchemaType.ARRAY instead of "ARRAY" for native support
Browse files Browse the repository at this point in the history
While "ARRAY" works in JVM, it does not in Native.
Fix #30919
  • Loading branch information
Sgitario committed Feb 7, 2023
1 parent 25470b6 commit 0bc09e7
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public abstract class StandardMethodImplementor implements MethodImplementor {
private static final String OPENAPI_RESPONSE_ANNOTATION = OPENAPI_PACKAGE + ".responses.APIResponse";
private static final String OPENAPI_CONTENT_ANNOTATION = OPENAPI_PACKAGE + ".media.Content";
private static final String OPENAPI_SCHEMA_ANNOTATION = OPENAPI_PACKAGE + ".media.Schema";
private static final String SCHEMA_TYPE_CLASS_NAME = "org.eclipse.microprofile.openapi.annotations.enums.SchemaType";
private static final String SCHEMA_TYPE_ARRAY = "ARRAY";
private static final String ROLES_ALLOWED_ANNOTATION = "jakarta.annotation.security.RolesAllowed";
private static final Logger LOGGER = Logger.getLogger(StandardMethodImplementor.class);
Expand Down Expand Up @@ -197,7 +198,7 @@ protected void addOpenApiResponseAnnotation(AnnotatedElement element, Response.S
.add("implementation", clazz);

if (isList) {
schemaAnnotation.add("type", SCHEMA_TYPE_ARRAY);
schemaAnnotation.add("type", schemaTypeArray());
}

element.addAnnotation(OPENAPI_RESPONSE_ANNOTATION)
Expand Down Expand Up @@ -235,6 +236,11 @@ protected boolean isNotReactivePanache() {
return !capabilities.isPresent(Capability.HIBERNATE_REACTIVE);
}

private static Enum schemaTypeArray() {
Class<?> schemaTypeClass = toClass(SCHEMA_TYPE_CLASS_NAME);
return Enum.valueOf((Class<Enum>) schemaTypeClass, SCHEMA_TYPE_ARRAY);
}

private static Class<?> toClass(String className) {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
try {
Expand Down

0 comments on commit 0bc09e7

Please sign in to comment.