Class OpenApiConverter
- java.lang.Object
-
- software.amazon.smithy.openapi.fromsmithy.OpenApiConverter
-
public final class OpenApiConverter extends java.lang.Object
Converts a Smithy model to OpenAPI.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description OpenApiConverter
addOpenApiMapper(OpenApiMapper mapper)
Adds anOpenApiMapper
to the converter.OpenApiConverter
classLoader(java.lang.ClassLoader classLoader)
Sets aClassLoader
to use to discoverJsonSchemaMapper
,OpenApiMapper
, andOpenApiProtocol
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.
-
-
-
Method Detail
-
create
public static OpenApiConverter create()
-
getConfig
public OpenApiConfig getConfig()
Get the OpenAPI configuration settings.- Returns:
- Returns the config object.
-
config
public OpenApiConverter config(OpenApiConfig config)
Set the OpenAPI configuration settings.This also updates the configuration object of any previously set
JsonSchemaConfig
.- Parameters:
config
- Config object to set.- Returns:
- Returns the converter.
-
addOpenApiMapper
public OpenApiConverter addOpenApiMapper(OpenApiMapper mapper)
Adds anOpenApiMapper
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.- Parameters:
mapper
- Mapper to add.- Returns:
- Returns the converter.
-
classLoader
public OpenApiConverter classLoader(java.lang.ClassLoader classLoader)
Sets aClassLoader
to use to discoverJsonSchemaMapper
,OpenApiMapper
, andOpenApiProtocol
service providers through SPI.The
OpenApiConverter
will use its own ClassLoader by default.- Parameters:
classLoader
- ClassLoader to use.- Returns:
- Returns the OpenApiConverter.
-
convert
public OpenApi convert(Model model)
Converts the Smithy model to OpenAPI.- Parameters:
model
- Smithy model to convert.- Returns:
- Returns the converted model.
-
convertToNode
public ObjectNode convertToNode(Model model)
Converts the given service shape to a JSON/Node representation of an OpenAPI model using the given Smithy 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 theOpenApiMapper.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 registeredOpenApiMapper
. 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).- Parameters:
model
- Smithy model to convert.- Returns:
- Returns the converted model.
-
-