public final class OpenApiConverter
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
OpenApiConverter |
addOpenApiMapper(OpenApiMapper mapper)
Adds an
OpenApiMapper to the converter. |
OpenApiConverter |
classLoader(java.lang.ClassLoader classLoader)
Sets a
ClassLoader to use to discover JsonSchemaMapper ,
OpenApiMapper , and OpenApiProtocol service providers
through SPI. |
OpenApiConverter |
config(OpenApiConfig config)
Set the OpenAPI configuration settings.
|
OpenApi |
convert(Model model)
Converts the Smithy model to OpenAPI.
|
ObjectNode |
convertToNode(Model model)
Converts the given service shape to a JSON/Node representation of an
OpenAPI model using the given Smithy model.
|
static OpenApiConverter |
create() |
OpenApiConfig |
getConfig()
Get the OpenAPI configuration settings.
|
public static OpenApiConverter create()
public OpenApiConfig getConfig()
public OpenApiConverter config(OpenApiConfig config)
This also updates the configuration object of any previously set
JsonSchemaConfig
.
config
- Config object to set.public OpenApiConverter addOpenApiMapper(OpenApiMapper mapper)
OpenApiMapper
to the converter.
This method is used to add custom OpenApiMappers to a converter that
are not automatically added by Smithy2OpenApiExtension
objects
detected through Java SPI.
mapper
- Mapper to add.public OpenApiConverter classLoader(java.lang.ClassLoader classLoader)
ClassLoader
to use to discover JsonSchemaMapper
,
OpenApiMapper
, and OpenApiProtocol
service providers
through SPI.
The OpenApiConverter
will use its own ClassLoader by default.
classLoader
- ClassLoader to use.public OpenApi convert(Model model)
model
- Smithy model to convert.public ObjectNode convertToNode(Model model)
The result of this method may differ from the result of calling
Component.toNode()
because this method will pass the Node
representation of the OpenAPI through the OpenApiMapper.updateNode(software.amazon.smithy.openapi.fromsmithy.Context<? extends software.amazon.smithy.model.traits.Trait>, software.amazon.smithy.openapi.model.OpenApi, software.amazon.smithy.model.node.ObjectNode)
method of each registered OpenApiMapper
. This may cause
the returned value to no longer be a valid OpenAPI model but still
representative of the desired artifact (for example, an OpenAPI model
used with Amazon CloudFormation might used intrinsic JSON functions or
variable expressions that are replaced when synthesized).
model
- Smithy model to convert.