Class OpenApiConverter
- java.lang.Object
-
- software.amazon.smithy.openapi.fromsmithy.OpenApiConverter
-
public final class OpenApiConverter extends java.lang.ObjectConverts a Smithy model to OpenAPI.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description OpenApiConverteraddOpenApiMapper(OpenApiMapper mapper)Adds anOpenApiMapperto the converter.OpenApiConverterclassLoader(java.lang.ClassLoader classLoader)Sets aClassLoaderto use to discoverJsonSchemaMapper,OpenApiMapper, andOpenApiProtocolservice providers through SPI.OpenApiConverterconfig(OpenApiConfig config)Set the OpenAPI configuration settings.OpenApiconvert(Model model)Converts the Smithy model to OpenAPI.ObjectNodeconvertToNode(Model model)Converts the given service shape to a JSON/Node representation of an OpenAPI model using the given Smithy model.static OpenApiConvertercreate()OpenApiConfiggetConfig()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 anOpenApiMapperto the converter.This method is used to add custom OpenApiMappers to a converter that are not automatically added by
Smithy2OpenApiExtensionobjects detected through Java SPI.- Parameters:
mapper- Mapper to add.- Returns:
- Returns the converter.
-
classLoader
public OpenApiConverter classLoader(java.lang.ClassLoader classLoader)
Sets aClassLoaderto use to discoverJsonSchemaMapper,OpenApiMapper, andOpenApiProtocolservice providers through SPI.The
OpenApiConverterwill 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.
-
-