i have a requirement where i need to have a GET endpoint in my microservice that returns an io.swagger.v3.oas.models.OpenAPI
document, and i am wondering how to compose that object. The object in raw form looks like this:
{
"openapi": "3.0.1",
"info": {
"title": "MY API",
"description": "API for accessing stuff and other stuff.",
"termsOfService": "http://website.com",
"contact": {
"name": "Some chap",
"url": "https://website.com/s/url",
"email": "alwaysReplyAll@office.com"
},
"version": "1.0"
},
"paths": {
"/v1/user/{id}/properties": {
"get": { ...etc etc
ive tried this but the document is just coming up null/blank:
@GetMapping("/openapi3")
public @ResponseBody OpenAPI swag() {
OpenAPI swagDoc = new OpenAPI();
GenericOpenApiContextBuilder builder = new GenericOpenApiContextBuilder();
try {
swagDoc = builder.buildContext(true).read();
} catch (OpenApiConfigurationException e) {
// handle error
}
return swagDoc;
}
i have read about springfox but the examples in their docs arent very clear ... and im wondering if that is even necessary. what am i not doing right with this builder?
using Gradle btw