public class OpenAPIGenerator extends Object
OpenAPI model from a Jooby application.
Optionally exports an OpenAPI model to a json or yaml file.
Usage: https://jooby.io/modules/openapi| Modifier and Type | Class and Description |
|---|---|
static class |
OpenAPIGenerator.Format
Supported formats.
|
| Constructor and Description |
|---|
OpenAPIGenerator() |
| Modifier and Type | Method and Description |
|---|---|
Path |
export(io.swagger.v3.oas.models.OpenAPI openAPI,
OpenAPIGenerator.Format format)
Export an
OpenAPI model to the given format. |
io.swagger.v3.oas.models.OpenAPI |
generate(String classname)
Generate an
OpenAPI model from Jooby class. |
Path |
getBasedir()
Base directory used it for loading openAPI template file name.
|
String |
getExcludes()
Regular expression used to excludes route.
|
String |
getIncludes()
Regular expression used to includes/keep route.
|
Path |
getOutputDir()
Set output directory used by
export(OpenAPI, Format) operation. |
String |
getTemplateName()
OpenAPI template file name, defaults is:
openapi.yaml. |
void |
setBasedir(Path basedir)
Set base directory used it for loading openAPI template file name.
|
void |
setClassLoader(ClassLoader classLoader)
Use a custom classloader for resolving class files.
|
void |
setDebug(Set<DebugOption> debug)
Set debug options.
|
void |
setExcludes(String excludes)
Set Regular expression used to excludes route.
|
void |
setIncludes(String includes)
Set regular expression used to includes/keep route.
|
void |
setOutputDir(Path outputDir)
Set output directory used by
export(OpenAPI, Format). |
void |
setTemplateName(String templateName)
Set openAPI template file name, defaults is:
openapi.yaml. |
String |
toJson(io.swagger.v3.oas.models.OpenAPI openAPI)
Generates a JSON version of the given model.
|
String |
toYaml(io.swagger.v3.oas.models.OpenAPI openAPI)
Generates a YAML version of the given model.
|
@Nonnull public Path export(@Nonnull io.swagger.v3.oas.models.OpenAPI openAPI, @Nonnull OpenAPIGenerator.Format format) throws IOException
OpenAPI model to the given format.openAPI - Model.format - Format.IOException@Nonnull public io.swagger.v3.oas.models.OpenAPI generate(@Nonnull String classname)
OpenAPI model 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.yaml is used as template and get merged into the
final model.classname - Application class name.@Nonnull public String toYaml(@Nonnull io.swagger.v3.oas.models.OpenAPI openAPI)
openAPI - Model.@Nonnull public String toJson(@Nonnull io.swagger.v3.oas.models.OpenAPI openAPI)
openAPI - Model.public void setClassLoader(@Nonnull ClassLoader classLoader)
classLoader - Class loader.public void setDebug(Set<DebugOption> debug)
debug - Debug options.public String getTemplateName()
openapi.yaml.openapi.yaml.public void setTemplateName(@Nonnull String templateName)
openapi.yaml.templateName - OpenAPI template file name, defaults is: openapi.yaml.public void setBasedir(@Nonnull Path basedir)
user.dir.basedir - Base directory.public Path getBasedir()
user.dir.public Path getOutputDir()
export(OpenAPI, Format) operation.
Defaults to getBasedir().@Nullable public String getIncludes()
/api/.*./api/.*.public void setIncludes(@Nullable String includes)
/api/.*.includes - Regular expression.@Nullable public String getExcludes()
/web./web.public void setExcludes(@Nullable String excludes)
/web.excludes - Regular expression used to excludes route. Example: /web.public void setOutputDir(@Nonnull Path outputDir)
export(OpenAPI, Format).outputDir - Output directory.Copyright © 2020. All rights reserved.