Package dev.relism.flash.ext.openapi
Class OpenApiExtension
java.lang.Object
dev.relism.flash.ext.openapi.OpenApiExtension
- All Implemented Interfaces:
FlashExtension
Generates and serves an OpenAPI 3.0 spec and Swagger UI under a configurable base path.
Given basePath = "/openapi" (the default), three routes are registered:
GET /openapi.json— OpenAPI 3.0 spec as JSONGET /openapi.yaml— OpenAPI 3.0 spec as YAMLGET /openapi/swagger— Swagger UI pointing at/openapi.json
If flash-ext-jackson is installed, this extension reuses its
ObjectMapper. Otherwise it uses a local default mapper.
Operations are collected at boot from handlers annotated with ApiOperation
that also have route metadata (Route or shorthand verb annotations).
FlashApp.create(8080)
.install(new JacksonExtension())
.install(new OpenApiExtension("/openapi", "My API", "2.0.0"))
.start();
-
Constructor Summary
ConstructorsConstructorDescriptionOpenApiExtension(String basePath) OpenApiExtension(String basePath, String title, String version) OpenApiExtension(String basePath, String title, String version, String description) -
Method Summary
Modifier and TypeMethodDescriptionvoidprovide(FlashContext ctx) Phase 1 — register services and processors.voidroutes(FlashRegistrar<?> app, FlashContext ctx) Phase 2 — register routes.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dev.relism.flash.extension.FlashExtension
priority
-
Constructor Details
-
OpenApiExtension
public OpenApiExtension() -
OpenApiExtension
-
OpenApiExtension
-
OpenApiExtension
-
-
Method Details
-
provide
Description copied from interface:FlashExtensionPhase 1 — register services and processors. Safe:FlashContext.provide(java.lang.Class<T>, T),FlashContext.supply(java.lang.Class<T>, java.util.function.Supplier<T>),FlashContext.addAnnotationProcessor(dev.relism.flash.extension.AnnotationProcessor),FlashContext.addRouteListener(dev.relism.flash.extension.RouteListener). Unsafe:FlashContext.require(java.lang.Class<T>)(services not yet resolved).- Specified by:
providein interfaceFlashExtension
-
routes
Description copied from interface:FlashExtensionPhase 2 — register routes. All services are fully resolved.FlashContext.require(java.lang.Class<T>)is safe here.- Specified by:
routesin interfaceFlashExtension
-