public interface OpenApiMapper
The methods of a plugin are invoked by OpenApiConverter
during
the conversion of a model. There is no need to invoke these manually.
Implementations may choose to leverage configuration options of the
provided context to determine whether or not to enact the plugin.
default byte getOrder()
Plugins are applied according to this sort order. Lower values are executed before higher values (for example, -128 comes before 0, comes before 127). Plugins default to 0, which is the middle point between the minimum and maximum order values.
default void updateDefaultSettings(Model model, OpenApiConfig config)
Use this method and not before(software.amazon.smithy.openapi.fromsmithy.Context<? extends software.amazon.smithy.model.traits.Trait>, software.amazon.smithy.openapi.model.OpenApi.Builder)
to add default settings. Adding default settings in before()
is possible, but might be too late in the process for those
configuration changes to take effect.
model
- Model being converted.config
- Configuration object to modify.default OperationObject updateOperation(Context<? extends Trait> context, OperationShape shape, OperationObject operation, java.lang.String httpMethodName, java.lang.String path)
updateParameter(software.amazon.smithy.openapi.fromsmithy.Context<? extends software.amazon.smithy.model.traits.Trait>, software.amazon.smithy.model.shapes.OperationShape, java.lang.String, java.lang.String, software.amazon.smithy.openapi.model.ParameterObject)
,
updateRequestBody(software.amazon.smithy.openapi.fromsmithy.Context<? extends software.amazon.smithy.model.traits.Trait>, software.amazon.smithy.model.shapes.OperationShape, java.lang.String, java.lang.String, software.amazon.smithy.openapi.model.RequestBodyObject)
, updateResponse(software.amazon.smithy.openapi.fromsmithy.Context<? extends software.amazon.smithy.model.traits.Trait>, software.amazon.smithy.model.shapes.OperationShape, java.lang.String, java.lang.String, java.lang.String, software.amazon.smithy.openapi.model.ResponseObject)
,
updateRequestBody(software.amazon.smithy.openapi.fromsmithy.Context<? extends software.amazon.smithy.model.traits.Trait>, software.amazon.smithy.model.shapes.OperationShape, java.lang.String, java.lang.String, software.amazon.smithy.openapi.model.RequestBodyObject)
, and postProcessOperation(software.amazon.smithy.openapi.fromsmithy.Context<? extends software.amazon.smithy.model.traits.Trait>, software.amazon.smithy.model.shapes.OperationShape, software.amazon.smithy.openapi.model.OperationObject, java.lang.String, java.lang.String)
).context
- Conversion context.shape
- Operation being converted.operation
- OperationObject being built.httpMethodName
- The HTTP method of the operation.path
- The HTTP URI of the operation.default OperationObject postProcessOperation(Context<? extends Trait> context, OperationShape shape, OperationObject operation, java.lang.String httpMethodName, java.lang.String path)
updateOperation(software.amazon.smithy.openapi.fromsmithy.Context<? extends software.amazon.smithy.model.traits.Trait>, software.amazon.smithy.model.shapes.OperationShape, software.amazon.smithy.openapi.model.OperationObject, java.lang.String, java.lang.String)
,
updateParameter(software.amazon.smithy.openapi.fromsmithy.Context<? extends software.amazon.smithy.model.traits.Trait>, software.amazon.smithy.model.shapes.OperationShape, java.lang.String, java.lang.String, software.amazon.smithy.openapi.model.ParameterObject)
, updateRequestBody(software.amazon.smithy.openapi.fromsmithy.Context<? extends software.amazon.smithy.model.traits.Trait>, software.amazon.smithy.model.shapes.OperationShape, java.lang.String, java.lang.String, software.amazon.smithy.openapi.model.RequestBodyObject)
,
updateResponse(software.amazon.smithy.openapi.fromsmithy.Context<? extends software.amazon.smithy.model.traits.Trait>, software.amazon.smithy.model.shapes.OperationShape, java.lang.String, java.lang.String, java.lang.String, software.amazon.smithy.openapi.model.ResponseObject)
, and updateRequestBody(software.amazon.smithy.openapi.fromsmithy.Context<? extends software.amazon.smithy.model.traits.Trait>, software.amazon.smithy.model.shapes.OperationShape, java.lang.String, java.lang.String, software.amazon.smithy.openapi.model.RequestBodyObject)
).context
- Conversion context.shape
- Operation being converted.operation
- OperationObject being built.httpMethodName
- The HTTP method of the operation.path
- The HTTP URI of the operation.default PathItem updatePathItem(Context<? extends Trait> context, java.lang.String path, PathItem pathItem)
context
- Conversion context.path
- Path of the PathItem.pathItem
- Path item being converted.default ParameterObject updateParameter(Context<? extends Trait> context, OperationShape operation, java.lang.String httpMethodName, java.lang.String path, ParameterObject parameterObject)
context
- Conversion context.operation
- Smithy operation being converted.httpMethodName
- The HTTP method that this parameter is bound to.path
- The HTTP URI this parameter is bound to.parameterObject
- Parameter being updated.default RequestBodyObject updateRequestBody(Context<? extends Trait> context, OperationShape operation, java.lang.String httpMethodName, java.lang.String path, RequestBodyObject requestBody)
context
- Conversion context.operation
- Operation being converted.httpMethodName
- The HTTP method that this request is bound to.path
- The HTTP URI this request is bound to.requestBody
- Request body being updated.default ResponseObject updateResponse(Context<? extends Trait> context, OperationShape operation, java.lang.String status, java.lang.String httpMethodName, java.lang.String path, ResponseObject response)
context
- Conversion context.operation
- Operation shape being converted.status
- HTTP status of this response.httpMethodName
- The HTTP method that this response responds to.path
- The HTTP URI this response responds to.response
- Response object being updated.default void before(Context<? extends Trait> context, OpenApi.Builder builder)
context
- Conversion context.builder
- OpenAPI builder to modify.default SecurityScheme updateSecurityScheme(Context<? extends Trait> context, Trait authTrait, SecurityScheme securityScheme)
context
- Conversion context.authTrait
- Smithy authentication scheme trait.securityScheme
- Security scheme object to update.default java.util.Map<java.lang.String,java.util.List<java.lang.String>> updateSecurity(Context<? extends Trait> context, Shape shape, SecuritySchemeConverter<? extends Trait> converter, java.util.Map<java.lang.String,java.util.List<java.lang.String>> requirement)
The provided requirement Map
will never be null or empty,
but it may contain more than one key-value pair. A null or empty
return value will cause the security requirement to be omitted
from the converted shape.
context
- Conversion context.shape
- Shape that is getting a security requirement (a service or operation).converter
- Security scheme converter.requirement
- Security scheme requirement to update.default OpenApi after(Context<? extends Trait> context, OpenApi openapi)
context
- Conversion context.openapi
- OpenAPI object to modify.default ObjectNode updateNode(Context<? extends Trait> context, OpenApi openapi, ObjectNode node)
context
- Conversion context.openapi
- OpenAPI object being converted to a node.node
- OpenAPI object node.static OpenApiMapper compose(java.util.List<OpenApiMapper> mappers)
mappers
- Mappers to compose.