Search in sources :

Example 1 with ReDocOptions

use of io.javalin.plugin.openapi.ui.ReDocOptions 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);
}
Also used : Javalin(io.javalin.Javalin) HttpMethod(io.javalin.plugin.openapi.annotations.HttpMethod) OpenApiPlugin(io.javalin.plugin.openapi.OpenApiPlugin) ReDocOptions(io.javalin.plugin.openapi.ui.ReDocOptions) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) RedocOptionsObject(io.javalin.plugin.openapi.ui.RedocOptionsObject) Info(io.swagger.v3.oas.models.info.Info) OpenApiContent(io.javalin.plugin.openapi.annotations.OpenApiContent) Javalin(io.javalin.Javalin) OpenApiOptions(io.javalin.plugin.openapi.OpenApiOptions) JavalinJackson(io.javalin.plugin.json.JavalinJackson) RedocOptionsTheme(io.javalin.plugin.openapi.ui.RedocOptionsTheme) OpenApiParam(io.javalin.plugin.openapi.annotations.OpenApiParam) Context(io.javalin.http.Context) OpenApiResponse(io.javalin.plugin.openapi.annotations.OpenApiResponse) JsonInclude(com.fasterxml.jackson.annotation.JsonInclude) SwaggerOptions(io.javalin.plugin.openapi.ui.SwaggerOptions) OpenApi(io.javalin.plugin.openapi.annotations.OpenApi) OpenApiOptions(io.javalin.plugin.openapi.OpenApiOptions) SwaggerOptions(io.javalin.plugin.openapi.ui.SwaggerOptions) JavalinJackson(io.javalin.plugin.json.JavalinJackson) ReDocOptions(io.javalin.plugin.openapi.ui.ReDocOptions) Info(io.swagger.v3.oas.models.info.Info) OpenApiPlugin(io.javalin.plugin.openapi.OpenApiPlugin) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 2 with ReDocOptions

use of io.javalin.plugin.openapi.ui.ReDocOptions 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"));
}
Also used : OpenApiOptions(io.javalin.plugin.openapi.OpenApiOptions) SwaggerOptions(io.javalin.plugin.openapi.ui.SwaggerOptions) JacksonToJsonMapper(io.javalin.plugin.openapi.jackson.JacksonToJsonMapper) ReDocOptions(io.javalin.plugin.openapi.ui.ReDocOptions) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ModelResolver(io.swagger.v3.core.jackson.ModelResolver)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 OpenApiOptions (io.javalin.plugin.openapi.OpenApiOptions)2 ReDocOptions (io.javalin.plugin.openapi.ui.ReDocOptions)2 SwaggerOptions (io.javalin.plugin.openapi.ui.SwaggerOptions)2 JsonInclude (com.fasterxml.jackson.annotation.JsonInclude)1 Javalin (io.javalin.Javalin)1 Context (io.javalin.http.Context)1 JavalinJackson (io.javalin.plugin.json.JavalinJackson)1 OpenApiPlugin (io.javalin.plugin.openapi.OpenApiPlugin)1 HttpMethod (io.javalin.plugin.openapi.annotations.HttpMethod)1 OpenApi (io.javalin.plugin.openapi.annotations.OpenApi)1 OpenApiContent (io.javalin.plugin.openapi.annotations.OpenApiContent)1 OpenApiParam (io.javalin.plugin.openapi.annotations.OpenApiParam)1 OpenApiResponse (io.javalin.plugin.openapi.annotations.OpenApiResponse)1 JacksonToJsonMapper (io.javalin.plugin.openapi.jackson.JacksonToJsonMapper)1 RedocOptionsObject (io.javalin.plugin.openapi.ui.RedocOptionsObject)1 RedocOptionsTheme (io.javalin.plugin.openapi.ui.RedocOptionsTheme)1 ModelResolver (io.swagger.v3.core.jackson.ModelResolver)1 Info (io.swagger.v3.oas.models.info.Info)1