Package org.sdase.commons.server.openapi
Class OpenApiBundle
java.lang.Object
org.sdase.commons.server.openapi.OpenApiBundle
- All Implemented Interfaces:
io.dropwizard.core.ConfiguredBundle<io.dropwizard.core.Configuration>
public final class OpenApiBundle
extends Object
implements io.dropwizard.core.ConfiguredBundle<io.dropwizard.core.Configuration>
A bundle used to generate and serve API-first or code-first OpenAPI 3 files at the
openapi.yaml or openapi.json HTTP resources.
Example Usage:
Minimal
@OpenAPIDefinition(info = @Info(title = "An example application"))
public class ExampleApplication extends Application<Configuration> {
// ...
@Override
public void initialize(Bootstrap<Configuration> bootstrap) {
// ...
bootstrap.addBundle(
OpenApiBundle.builder()
.addResourcePackageClass(getClass())
.build());
}
}
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classstatic interfacestatic interface -
Constructor Summary
ConstructorsConstructorDescriptionOpenApiBundle(Set<String> resourcePackages, io.swagger.v3.oas.models.OpenAPI existingOpenAPI) -
Method Summary
Modifier and TypeMethodDescriptionstatic OpenApiBundle.InitialBuilderbuilder()This method can be used to generate the OpenAPI specification as JSONThis method can be used to generate the OpenAPI specification as YAMLvoidinitialize(io.dropwizard.core.setup.Bootstrap<?> bootstrap) voidrun(io.dropwizard.core.Configuration configuration, io.dropwizard.core.setup.Environment environment)
-
Constructor Details
-
OpenApiBundle
-
-
Method Details
-
builder
-
initialize
public void initialize(io.dropwizard.core.setup.Bootstrap<?> bootstrap) - Specified by:
initializein interfaceio.dropwizard.core.ConfiguredBundle<io.dropwizard.core.Configuration>
-
run
public void run(io.dropwizard.core.Configuration configuration, io.dropwizard.core.setup.Environment environment) - Specified by:
runin interfaceio.dropwizard.core.ConfiguredBundle<io.dropwizard.core.Configuration>
-
generateOpenApiAsYaml
This method can be used to generate the OpenAPI specification as YAML- Returns:
- the OpenAPI specification as YAML
- Throws:
Exception
-
generateOpenApiAsJson
This method can be used to generate the OpenAPI specification as JSON- Returns:
- the OpenAPI specification as JSON
- Throws:
Exception
-