-
public final class OpenApiOptions
-
-
Field Summary
Fields Modifier and Type Field Description private Stringpathprivate Set<RouteRole>rolesprivate SwaggerOptionsswaggerprivate ReDocOptionsreDocprivate DefaultDocumentationdefaultprivate ObjectMapperjacksonMapperprivate ModelConverterFactorymodelConverterFactoryprivate ToJsonMappertoJsonMapperprivate OpenApiModelModifierresponseModifierprivate Set<String>packagePrefixesToScanprivate List<HandlerMetaInfo>overriddenDocumentationprivate List<Pair<String, List<HttpMethod>>>ignoredPathsprivate final List<Pair<String, List<HttpMethod>>>includedPathsprivate BooleanvalidateSchemaprivate BooleancacheSchemaprivate final InitialConfigurationCreatorinitialConfigurationCreator
-
Constructor Summary
Constructors Constructor Description OpenApiOptions(Info info)OpenApiOptions(InitialConfigurationCreator initialConfigurationCreator)
-
Method Summary
Modifier and Type Method Description final StringgetPath()If not null, creates a GET route to get the schema as a json final UnitsetPath(String path)If not null, creates a GET route to get the schema as a json final Set<RouteRole>getRoles()final UnitsetRoles(Set<RouteRole> roles)final SwaggerOptionsgetSwagger()If not null, creates a GET route to the swagger ui final UnitsetSwagger(SwaggerOptions swagger)If not null, creates a GET route to the swagger ui final ReDocOptionsgetReDoc()If not null, creates a GET route to the reDoc ui final UnitsetReDoc(ReDocOptions reDoc)If not null, creates a GET route to the reDoc ui final DefaultDocumentationgetDefault()Function that is applied to every new operation. final UnitsetDefault(DefaultDocumentation default)Function that is applied to every new operation. final ObjectMappergetJacksonMapper()The default jackson mapper used, for "modelConverterFactory" and "toJsonMapper" if not overridden. final UnitsetJacksonMapper(ObjectMapper jacksonMapper)The default jackson mapper used, for "modelConverterFactory" and "toJsonMapper" if not overridden. final ModelConverterFactorygetModelConverterFactory()Creates a model converter, which converts a class to an open api schema. final UnitsetModelConverterFactory(ModelConverterFactory modelConverterFactory)Creates a model converter, which converts a class to an open api schema. final ToJsonMappergetToJsonMapper()The json mapper for creating the object api schema json. final UnitsetToJsonMapper(ToJsonMapper toJsonMapper)The json mapper for creating the object api schema json. final OpenApiModelModifiergetResponseModifier()Function that allows modification of the OpenAPI model before it is sent to the client. final UnitsetResponseModifier(OpenApiModelModifier responseModifier)Function that allows modification of the OpenAPI model before it is sent to the client. final Set<String>getPackagePrefixesToScan()A list of package prefixes to scan for annotations. final UnitsetPackagePrefixesToScan(Set<String> packagePrefixesToScan)A list of package prefixes to scan for annotations. final List<HandlerMetaInfo>getOverriddenDocumentation()Manual set the documentation of specific paths final UnitsetOverriddenDocumentation(List<HandlerMetaInfo> overriddenDocumentation)Manual set the documentation of specific paths final List<Pair<String, List<HttpMethod>>>getIgnoredPaths()A list of paths to ignore in documentation final UnitsetIgnoredPaths(List<Pair<String, List<HttpMethod>>> ignoredPaths)A list of paths to ignore in documentation final List<Pair<String, List<HttpMethod>>>getIncludedPaths()A list of the only paths which will be considered as part of the OpenAPI documentation. final BooleangetValidateSchema()Validate the generated schema with the swagger parser (prints warnings if schema is invalid) final UnitsetValidateSchema(Boolean validateSchema)Validate the generated schema with the swagger parser (prints warnings if schema is invalid) final BooleangetCacheSchema()Flag indicating whether or not the generated schema should be cached. final UnitsetCacheSchema(Boolean cacheSchema)Flag indicating whether or not the generated schema should be cached. final InitialConfigurationCreatorgetInitialConfigurationCreator()final OpenApiOptionspath(String value)final OpenApiOptionsdisableCaching()final OpenApiOptionsresponseModifier(OpenApiModelModifier value)final OpenApiOptionsswagger(SwaggerOptions value)final OpenApiOptionsreDoc(ReDocOptions value)final OpenApiOptionsroles(RouteRole value)final OpenApiOptionsdefaultDocumentation(DefaultDocumentation value)final OpenApiOptionsdefaultDocumentation(Function1<OpenApiDocumentation, Unit> apply)final Unitexamples(Map<Class<?>, Map<String, Example>> examples)final <T extends Any> UnitaddExample(Class<T> clazz, String name, Example example)final OpenApiOptionsactivateAnnotationScanningFor(String packagePrefixes)Activate annotation scanning for specific package prefixes. final OpenApiOptionsjacksonMapper(ObjectMapper value)final OpenApiOptionsmodelConverterFactory(ModelConverterFactory value)final OpenApiOptionstoJsonMapper(ToJsonMapper value)final StringgetFullDocumentationUrl(Context ctx)final OpenApiOptionssetDocumentation(String path, HttpMethod method, OpenApiDocumentation documentation)final OpenApiOptionsvalidateSchema(Boolean validate)final OpenApiOptionsignorePath(String path, HttpMethod httpMethod)final OpenApiOptionsincludePath(String path, HttpMethod httpMethod)adds the given path and methods to the list of paths which should be scanned by OpenAPI -
-
Constructor Detail
-
OpenApiOptions
OpenApiOptions(Info info)
-
OpenApiOptions
OpenApiOptions(InitialConfigurationCreator initialConfigurationCreator)
-
-
Method Detail
-
setPath
final Unit setPath(String path)
If not null, creates a GET route to get the schema as a json
-
getSwagger
final SwaggerOptions getSwagger()
If not null, creates a GET route to the swagger ui
-
setSwagger
final Unit setSwagger(SwaggerOptions swagger)
If not null, creates a GET route to the swagger ui
-
getReDoc
final ReDocOptions getReDoc()
If not null, creates a GET route to the reDoc ui
-
setReDoc
final Unit setReDoc(ReDocOptions reDoc)
If not null, creates a GET route to the reDoc ui
-
getDefault
final DefaultDocumentation getDefault()
Function that is applied to every new operation. You can use this to set defaults (like a 500 response).
-
setDefault
final Unit setDefault(DefaultDocumentation default)
Function that is applied to every new operation. You can use this to set defaults (like a 500 response).
-
getJacksonMapper
final ObjectMapper getJacksonMapper()
The default jackson mapper used, for "modelConverterFactory" and "toJsonMapper" if not overridden.
-
setJacksonMapper
final Unit setJacksonMapper(ObjectMapper jacksonMapper)
The default jackson mapper used, for "modelConverterFactory" and "toJsonMapper" if not overridden.
-
getModelConverterFactory
final ModelConverterFactory getModelConverterFactory()
Creates a model converter, which converts a class to an open api schema. Defaults to the jackson converter.
-
setModelConverterFactory
final Unit setModelConverterFactory(ModelConverterFactory modelConverterFactory)
Creates a model converter, which converts a class to an open api schema. Defaults to the jackson converter.
-
getToJsonMapper
final ToJsonMapper getToJsonMapper()
The json mapper for creating the object api schema json. This is separated from the default JavalinJson mappers.
-
setToJsonMapper
final Unit setToJsonMapper(ToJsonMapper toJsonMapper)
The json mapper for creating the object api schema json. This is separated from the default JavalinJson mappers.
-
getResponseModifier
final OpenApiModelModifier getResponseModifier()
Function that allows modification of the OpenAPI model before it is sent to the client. Since the OpenAPI model is mutable, care should be taken to make sure any modifications are idempotent. If this is not possible, caching of the model may be disabled, but this incurs a performance penalty.
-
setResponseModifier
final Unit setResponseModifier(OpenApiModelModifier responseModifier)
Function that allows modification of the OpenAPI model before it is sent to the client. Since the OpenAPI model is mutable, care should be taken to make sure any modifications are idempotent. If this is not possible, caching of the model may be disabled, but this incurs a performance penalty.
-
getPackagePrefixesToScan
final Set<String> getPackagePrefixesToScan()
A list of package prefixes to scan for annotations.
-
setPackagePrefixesToScan
final Unit setPackagePrefixesToScan(Set<String> packagePrefixesToScan)
A list of package prefixes to scan for annotations.
-
getOverriddenDocumentation
final List<HandlerMetaInfo> getOverriddenDocumentation()
Manual set the documentation of specific paths
-
setOverriddenDocumentation
final Unit setOverriddenDocumentation(List<HandlerMetaInfo> overriddenDocumentation)
Manual set the documentation of specific paths
-
getIgnoredPaths
final List<Pair<String, List<HttpMethod>>> getIgnoredPaths()
A list of paths to ignore in documentation
-
setIgnoredPaths
final Unit setIgnoredPaths(List<Pair<String, List<HttpMethod>>> ignoredPaths)
A list of paths to ignore in documentation
-
getIncludedPaths
final List<Pair<String, List<HttpMethod>>> getIncludedPaths()
A list of the only paths which will be considered as part of the OpenAPI documentation. If this list is empty it will be considered as meaning that all paths should be included with the exception of the ignored paths
-
getValidateSchema
final Boolean getValidateSchema()
Validate the generated schema with the swagger parser (prints warnings if schema is invalid)
-
setValidateSchema
final Unit setValidateSchema(Boolean validateSchema)
Validate the generated schema with the swagger parser (prints warnings if schema is invalid)
-
getCacheSchema
final Boolean getCacheSchema()
Flag indicating whether or not the generated schema should be cached. Caching is enabled by default.
-
setCacheSchema
final Unit setCacheSchema(Boolean cacheSchema)
Flag indicating whether or not the generated schema should be cached. Caching is enabled by default.
-
getInitialConfigurationCreator
final InitialConfigurationCreator getInitialConfigurationCreator()
-
path
final OpenApiOptions path(String value)
-
disableCaching
final OpenApiOptions disableCaching()
-
responseModifier
final OpenApiOptions responseModifier(OpenApiModelModifier value)
-
swagger
final OpenApiOptions swagger(SwaggerOptions value)
-
reDoc
final OpenApiOptions reDoc(ReDocOptions value)
-
roles
final OpenApiOptions roles(RouteRole value)
-
defaultDocumentation
final OpenApiOptions defaultDocumentation(DefaultDocumentation value)
-
defaultDocumentation
final OpenApiOptions defaultDocumentation(Function1<OpenApiDocumentation, Unit> apply)
-
activateAnnotationScanningFor
final OpenApiOptions activateAnnotationScanningFor(String packagePrefixes)
Activate annotation scanning for specific package prefixes. This will search for
OpenApiannotations which define thepathandmethod* property. If an handler with the same path and method is added and the handler doesn't have any documentation or the documentation cannot be accessed by reflection, the annotation will be used. Currently this is just required for java method references.
-
jacksonMapper
final OpenApiOptions jacksonMapper(ObjectMapper value)
-
modelConverterFactory
final OpenApiOptions modelConverterFactory(ModelConverterFactory value)
-
toJsonMapper
final OpenApiOptions toJsonMapper(ToJsonMapper value)
-
getFullDocumentationUrl
final String getFullDocumentationUrl(Context ctx)
-
setDocumentation
final OpenApiOptions setDocumentation(String path, HttpMethod method, OpenApiDocumentation documentation)
-
validateSchema
final OpenApiOptions validateSchema(Boolean validate)
-
ignorePath
final OpenApiOptions ignorePath(String path, HttpMethod httpMethod)
-
includePath
final OpenApiOptions includePath(String path, HttpMethod httpMethod)
adds the given path and methods to the list of paths which should be scanned by OpenAPI
- Parameters:
path- : the path to include in the paths to scanhttpMethod- : the list of http methods to include in the scan (as a vararg)
-
-
-
-