java.lang.Object
io.jooby.openapi.OpenAPIGenerator
Generate an
OpenAPI model from a Jooby application.
Optionally exports an OpenAPI model to a json or yaml file.
Usage: https://jooby.io/modules/openapi
- Author:
- edgar
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionexport(io.swagger.v3.oas.models.OpenAPI openAPI, OpenAPIGenerator.Format format) Export anOpenAPImodel to the given format.io.swagger.v3.oas.models.OpenAPIGenerate anOpenAPImodel from Jooby class.Base directory used it for loading openAPI template file name.Regular expression used to excludes route.Regular expression used to includes/keep route.Set output directory used byexport(OpenAPI, Format)operation.OpenAPI template file name, defaults is:openapi.yaml.voidsetBasedir(Path basedir) Set base directory used it for loading openAPI template file name.voidsetClassLoader(ClassLoader classLoader) Use a custom classloader for resolving class files.voidsetDebug(Set<DebugOption> debug) Set debug options.voidsetExcludes(String excludes) Set Regular expression used to excludes route.voidsetIncludes(String includes) Set regular expression used to includes/keep route.voidsetOutputDir(Path outputDir) Set output directory used byexport(OpenAPI, Format).voidsetTemplateName(String templateName) Set openAPI template file name, defaults is:openapi.yaml.toJson(io.swagger.v3.oas.models.OpenAPI openAPI) Generates a JSON version of the given model.toYaml(io.swagger.v3.oas.models.OpenAPI openAPI) Generates a YAML version of the given model.
-
Constructor Details
-
OpenAPIGenerator
Test Only.- Parameters:
metaInf- Location of meta-inf directory.
-
OpenAPIGenerator
public OpenAPIGenerator()Creates a new instance.
-
-
Method Details
-
export
@NonNull public Path export(@NonNull io.swagger.v3.oas.models.OpenAPI openAPI, @NonNull OpenAPIGenerator.Format format) throws IOException Export anOpenAPImodel to the given format.- Parameters:
openAPI- Model.format- Format.- Returns:
- Output file.
- Throws:
IOException
-
generate
Generate anOpenAPImodel from Jooby class. This method parses class byte code and generates an open api model from it. Compilation must be done with debug information and parameters name available.Optionally, the
conf/openapi.yamlis used as template and get merged into the final model.- Parameters:
classname- Application class name.- Returns:
- Model.
-
toYaml
Generates a YAML version of the given model.- Parameters:
openAPI- Model.- Returns:
- YAML content.
-
toJson
Generates a JSON version of the given model.- Parameters:
openAPI- Model.- Returns:
- JSON content.
-
setClassLoader
Use a custom classloader for resolving class files.- Parameters:
classLoader- Class loader.
-
setDebug
Set debug options.- Parameters:
debug- Debug options.
-
getTemplateName
OpenAPI template file name, defaults is:openapi.yaml.- Returns:
- OpenAPI template file name, defaults is:
openapi.yaml.
-
setTemplateName
Set openAPI template file name, defaults is:openapi.yaml.- Parameters:
templateName- OpenAPI template file name, defaults is:openapi.yaml.
-
setBasedir
Set base directory used it for loading openAPI template file name. Defaults isuser.dir.- Parameters:
basedir- Base directory.
-
getBasedir
Base directory used it for loading openAPI template file name.Defaults is
user.dir.- Returns:
- Base directory used it for loading openAPI template file name.
-
getOutputDir
Set output directory used byexport(OpenAPI, Format)operation.Defaults to
getBasedir().- Returns:
- Get output directory.
-
getIncludes
Regular expression used to includes/keep route. Example:/api/.*.- Returns:
- Regular expression used to includes/keep route. Example:
/api/.*.
-
setIncludes
Set regular expression used to includes/keep route. Example:/api/.*.- Parameters:
includes- Regular expression.
-
getExcludes
Regular expression used to excludes route. Example:/web.- Returns:
- Regular expression used to excludes route. Example:
/web.
-
setExcludes
Set Regular expression used to excludes route. Example:/web.- Parameters:
excludes- Regular expression used to excludes route. Example:/web.
-
setOutputDir
Set output directory used byexport(OpenAPI, Format).- Parameters:
outputDir- Output directory.
-