use of io.javalin.plugin.openapi.OpenApiOptions in project teku by ConsenSys.
the class BeaconRestApi method getOpenApiOptions.
private static OpenApiOptions getOpenApiOptions(final JsonProvider jsonProvider, final BeaconRestApiConfig config) {
final JacksonModelConverterFactory factory = new JacksonModelConverterFactory(jsonProvider.getObjectMapper());
final Info applicationInfo = new Info().title(StringUtils.capitalize(VersionProvider.CLIENT_IDENTITY)).version(VersionProvider.IMPLEMENTATION_VERSION).description("A minimal API specification for the beacon node, which enables a validator " + "to connect and perform its obligations on the Ethereum 2.0 phase 0 beacon chain.").license(new License().name("Apache 2.0").url("https://www.apache.org/licenses/LICENSE-2.0.html"));
final OpenApiOptions options = new OpenApiOptions(applicationInfo).modelConverterFactory(factory);
if (config.isRestApiDocsEnabled()) {
options.path("/swagger-docs").swagger(new SwaggerOptions("/swagger-ui"));
}
return options;
}
use of io.javalin.plugin.openapi.OpenApiOptions in project javalin by tipsy.
the class ExampleController method main.
public static void main(String[] args) {
ObjectMapper objectMapper = new ObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL);
OpenApiOptions openApiOptions = new OpenApiOptions(new Info().version("1.0").description("My Application")).activateAnnotationScanningFor("io.javalin.examples").path("/swagger-docs").swagger(new SwaggerOptions("/swagger").title("My Swagger Documentation")).reDoc(new ReDocOptions("/redoc", new RedocOptionsObject.Builder().setHideDownloadButton(true).setTheme(new RedocOptionsTheme.Builder().setSpacingUnit(10).setTypographyOptimizeSpeed(true).build()).build()).title("My ReDoc Documentation"));
Javalin app = Javalin.create(config -> {
config.registerPlugin(new OpenApiPlugin(openApiOptions));
config.jsonMapper(new JavalinJackson(objectMapper));
}).start(7070);
app.post("/users", ExampleController::create);
}
use of io.javalin.plugin.openapi.OpenApiOptions in project Jexxa by repplix.
the class OpenAPIConvention method initOpenAPI.
private void initOpenAPI() {
if (properties.containsKey(JEXXA_REST_OPEN_API_PATH)) {
var applicationInfo = new Info().version(properties.getProperty(JEXXA_CONTEXT_VERSION, "1.0")).description("Auto generated OpenAPI for " + properties.getProperty(JEXXA_CONTEXT_NAME, "Unknown Context")).title(properties.getProperty(JEXXA_CONTEXT_NAME, "Unknown Context"));
openApiOptions = new OpenApiOptions(applicationInfo).path("/" + properties.getProperty(JEXXA_REST_OPEN_API_PATH));
// Show all fields of an ValueObject
openApiOptions.getJacksonMapper().setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
javalinConfig.registerPlugin(new OpenApiPlugin(openApiOptions));
javalinConfig.enableCorsForAllOrigins();
openApiOptions.defaultDocumentation(doc -> {
doc.json(String.valueOf(HTTP_BAD_REQUEST), BadRequestResponse.class);
doc.json(String.valueOf(HTTP_BAD_REQUEST), BadRequestResponse.class);
});
}
}
use of io.javalin.plugin.openapi.OpenApiOptions in project cineast by vitrivr.
the class OpenApiCompatHelper method getJavalinOpenApiOptions.
/**
* Creates the Javalin options used to create an OpenAPI specification.
*/
public static OpenApiOptions getJavalinOpenApiOptions(APIConfig config) {
// Default Javalin JSON mapper includes all null values, which breakes the openapi specs.
ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
mapper.enable(SerializationFeature.INDENT_OUTPUT);
mapper.addMixIn(Schema.class, // Makes Schema.exampleFlagSet being ignored by jackson
SchemaMixin.class);
return new OpenApiOptions(() -> getOpenApi(config)).path("/openapi-specs").activateAnnotationScanningFor("org.vitrivr.cineast.api").toJsonMapper(new JacksonToJsonMapper(mapper)).modelConverterFactory(() -> new ModelResolver(mapper)).swagger(new SwaggerOptions("/swagger-ui").title("Swagger UI for Cineast Documentation")).reDoc(new ReDocOptions("/redoc").title("ReDoc for Cineast Documentation"));
}
use of io.javalin.plugin.openapi.OpenApiOptions in project Jexxa by jexxa-projects.
the class OpenAPIConvention method initOpenAPI.
private void initOpenAPI() {
if (properties.containsKey(JEXXA_REST_OPEN_API_PATH)) {
var applicationInfo = new Info().version(properties.getProperty(JEXXA_CONTEXT_VERSION, "1.0")).description("Auto generated OpenAPI for " + properties.getProperty(JEXXA_CONTEXT_NAME, "Unknown Context")).title(properties.getProperty(JEXXA_CONTEXT_NAME, "Unknown Context"));
openApiOptions = new OpenApiOptions(applicationInfo).path("/" + properties.getProperty(JEXXA_REST_OPEN_API_PATH));
// Show all fields of an ValueObject
openApiOptions.getJacksonMapper().setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
javalinConfig.registerPlugin(new OpenApiPlugin(openApiOptions));
javalinConfig.enableCorsForAllOrigins();
openApiOptions.defaultDocumentation(doc -> {
doc.json(String.valueOf(HTTP_BAD_REQUEST), BadRequestResponse.class);
doc.json(String.valueOf(HTTP_BAD_REQUEST), BadRequestResponse.class);
});
}
}
Aggregations