Package com.jsgalactic.axiom.openapi
Class OpenApi.Builder
java.lang.Object
com.jsgalactic.axiom.openapi.OpenApi.Builder
- Enclosing class:
OpenApi
Configures an
OpenApi. Not thread-safe; build once at startup.-
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds the configuration.Adds defaults for every route whose path equalspathPrefixor lies below it, for example the tags, the security requirement or a 401 response of a whole group.description(String description) Sets the API description.maxDepth(int maxDepth) Limits how deeply described types may nest before generation fails; cycles never count because a type that refers to itself becomes a reference.<T> OpenApi.BuilderMaps the built-in rules of a rule set to schema constraints ontype's properties: not-null becomes required, length and size become min/max length and items, min/max/range become minimum and maximum, pattern, e-mail and one-of becomepattern,format: emailandenum.schemaName(Class<?> type, String name) Names the schema of a record, bean or enum, instead of its simple class name.securityScheme(String name, SecurityScheme scheme) Defines a security scheme that routes can require byname.Adds a server the API is reachable at.
-
Method Details
-
description
Sets the API description.- Parameters:
description- text- Returns:
- this builder
-
server
Adds a server the API is reachable at. A Swagger 2.0 document uses only the first.- Parameters:
url- absolute URL or a path such as/apidescription- what the server is, or null- Returns:
- this builder
-
securityScheme
Defines a security scheme that routes can require byname.- Parameters:
name- scheme name, letters, digits and. _ -scheme- the scheme- Returns:
- this builder
-
schemaName
Names the schema of a record, bean or enum, instead of its simple class name. Use it to hide an internal name or to resolve two classes that share a simple name. For a generic class the name is the prefix of the generated one.- Parameters:
type- described classname- schema name, letters, digits and. _ -- Returns:
- this builder
-
rules
Maps the built-in rules of a rule set to schema constraints ontype's properties: not-null becomes required, length and size become min/max length and items, min/max/range become minimum and maximum, pattern, e-mail and one-of becomepattern,format: emailandenum. A rule that cannot constrain its property's type, or a property the type does not have, fails generation. Custom rules are not described. Only the rules declared withfieldandeachare mapped; register the rule set of a nested type separately.- Type Parameters:
T- the type- Parameters:
type- described classrules- its rule set- Returns:
- this builder
-
defaults
Adds defaults for every route whose path equalspathPrefixor lies below it, for example the tags, the security requirement or a 401 response of a whole group. Tags are added to the route's own; security applies only to routes that declare none; responses and parameters apply where the route has none with the same status or name. Other settings ofdefaultsare ignored. Defaults apply in the order added.- Parameters:
pathPrefix-""for all routes, or a template prefix such as/api/v1defaults- the defaults- Returns:
- this builder
-
maxDepth
Limits how deeply described types may nest before generation fails; cycles never count because a type that refers to itself becomes a reference.- Parameters:
maxDepth- at least 1, 32 by default- Returns:
- this builder
-
build
Builds the configuration.- Returns:
- an immutable
OpenApi
-