Я создаю REST-сервис с JAX-RS, Microprofile и Payara 5. Мой метод возвращает объект типа Response
.Сам ответ содержит список MyClass
.Реализация выглядит следующим образом:
import org.eclipse.microprofile.openapi.annotations.enums.SchemaType;
import org.eclipse.microprofile.openapi.annotations.media.Content;
import org.eclipse.microprofile.openapi.annotations.media.Schema;
import org.eclipse.microprofile.openapi.annotations.responses.APIResponse;
@GET
@Path("/{a}/{b}/{c}")
@APIResponse(content = @Content(schema = @Schema(type = SchemaType.ARRAY, implementation = MyClass.class)))
public Response getMyClass(@PathParam("a") String a,
@PathParam("b") String b,
@PathParam("c") String c) {
return Response
.ok()
.entity(new ArrayList<>())
.build();
}
Сгенерированное определение OpenAPI выглядит следующим образом:
/api/translations/{a}/{b}/{c}:
get:
operationId: getMyClass
parameters:
- name: a
in: path
required: true
style: simple
schema:
type: string
- [...]
responses:
default:
description: Default Response.
content:
'*/*':
schema:
type: array
items: {}
Как видите, определение MyClass.class отсутствует в типе ответа.Как я могу добавить этот тип в определение?Является ли аннотация @ApiResponse
правильным способом для достижения этой цели?