in integrations/openapi/openapi-resource/src/main/java/org/apache/aries/jax/rs/openapi/OpenApiResource.java [72:112]
public Response getOpenApi(@Context HttpHeaders headers,
@Context UriInfo uriInfo,
@PathParam("type") String type) throws Exception {
String ctxId = app.getClass().getCanonicalName()
.concat("#").
concat(String.valueOf(System.identityHashCode(app))).
concat(String.valueOf(this.serviceId));
OpenApiContext ctx = new JaxrsOpenApiContextBuilder<>()
.servletConfig(config)
.application(app)
.configLocation(configLocation)
.openApiConfiguration(openApiConfiguration)
.ctxId(ctxId)
.buildContext(false);
ctx.setOpenApiScanner(new JaxrsWhiteboardScanner(app, applicationClasses));
ctx.init();
OpenAPI oas = ctx.read();
if (oas == null) {
return Response.status(404).build();
}
boolean pretty = Optional.ofNullable(ctx.getOpenApiConfiguration()).map(OpenAPIConfiguration::isPrettyPrint).orElse(Boolean.FALSE);
if (Optional.ofNullable(type).map(String::trim).map("yaml"::equalsIgnoreCase).orElse(Boolean.FALSE)) {
return Response.status(Response.Status.OK)
.entity(pretty ? Yaml.pretty(oas) : Yaml.mapper().writeValueAsString(oas))
.type("application/yaml")
.build();
} else {
return Response.status(Response.Status.OK)
.entity(pretty ? Json.pretty(oas) : Json.mapper().writeValueAsString(oas))
.type(MediaType.APPLICATION_JSON_TYPE)
.build();
}
}