use of fish.payara.microprofile.openapi.api.OpenAPIBuildException in project Payara by payara.
the class OpenApiResource method getResponse.
@GET
@Produces({ APPLICATION_YAML, APPLICATION_JSON })
public Response getResponse(@Context HttpServletRequest request, @Context HttpServletResponse response) throws IOException {
OpenApiService openApiService = OpenApiService.getInstance();
// If the server is disabled, throw an error
if (!openApiService.isEnabled()) {
response.sendError(FORBIDDEN.getStatusCode(), "MicroProfile OpenAPI Service is disabled.");
return Response.status(FORBIDDEN).build();
}
// Get the OpenAPI document
OpenAPI document = null;
try {
document = openApiService.getDocument();
} catch (OpenAPIBuildException | IOException ex) {
LOGGER.log(WARNING, "OpenAPI document creation failed.", ex);
}
// If there are none, return an empty OpenAPI document
if (document == null) {
LOGGER.info("No OpenAPI document found.");
OpenAPI result = new BaseProcessor(new ArrayList<>()).process(new OpenAPIImpl(), null);
return Response.status(Status.NOT_FOUND).entity(result).build();
}
// Return the document
return Response.ok(document).build();
}
Aggregations