T
- Type of Smithy protocol to convert.public interface OpenApiProtocol<T extends Trait>
Instances of OpenApiProtocol
are discovered using SPI and
matched with configuration settings based on the result of matching
a protocol against getProtocolType()
.
Modifier and Type | Interface and Description |
---|---|
static class |
OpenApiProtocol.Operation
Represents an operation entry to add to an
OpenApi.Builder . |
Modifier and Type | Method and Description |
---|---|
java.util.Optional<OpenApiProtocol.Operation> |
createOperation(Context<T> context,
OperationShape operation)
Creates an operation entry, including the method, URI, and operation
object builder.
|
default java.lang.String |
getOperationMethod(Context<T> context,
OperationShape operation)
Gets the HTTP method of an operation.
|
default java.lang.String |
getOperationResponseStatusCode(Context<T> context,
ToShapeId operationOrError)
Gets the response status code of an operation or error shape.
|
default java.lang.String |
getOperationUri(Context<T> context,
OperationShape operation)
Gets the URI of an operation.
|
default java.util.Set<java.lang.String> |
getProtocolRequestHeaders(Context<T> context,
OperationShape operationShape)
Gets the unmodeled protocol-specific HTTP headers of a request that are
considered significant for the provided operation.
|
default java.util.Set<java.lang.String> |
getProtocolResponseHeaders(Context<T> context,
OperationShape operationShape)
Gets the unmodeled protocol-specific HTTP headers of a response that
are considered significant for the provided operation.
|
java.lang.Class<T> |
getProtocolType()
Gets the protocol type that this converter handles.
|
default void |
updateDefaultSettings(Model model,
OpenApiConfig config)
Sets protocol-specific default values on the OpenAPI configuration
object.
|
java.lang.Class<T> getProtocolType()
default void updateDefaultSettings(Model model, OpenApiConfig config)
model
- Model being converted.config
- Configuration object to modify.java.util.Optional<OpenApiProtocol.Operation> createOperation(Context<T> context, OperationShape operation)
The operation is returned as an empty Optional if the operation is
not supported by the protocol. This method should make calls to
getOperationUri(software.amazon.smithy.openapi.fromsmithy.Context<T>, software.amazon.smithy.model.shapes.OperationShape)
and getOperationMethod(software.amazon.smithy.openapi.fromsmithy.Context<T>, software.amazon.smithy.model.shapes.OperationShape)
when creating
the Operation object.
context
- The build context.operation
- The operation shape to create.default java.lang.String getOperationUri(Context<T> context, OperationShape operation)
The default implementation will attempt to get the HTTP URI
defined by the HttpTrait
trait. If no HTTP trait can be
found, the default implementation will throw an exception.
context
- The build context.operation
- The operation to get the URI of.default java.lang.String getOperationMethod(Context<T> context, OperationShape operation)
The default implementation will attempt to get the HTTP method
defined by the HttpTrait
trait. If no HTTP trait can be
found, the default implementation will throw an exception.
context
- The build context.operation
- The operation to get the method of.default java.lang.String getOperationResponseStatusCode(Context<T> context, ToShapeId operationOrError)
The default implementation will attempt to use HTTP binding traits to determine the HTTP status code of an operation or error structure.
context
- The build context.operationOrError
- Operation or error shape ID.default java.util.Set<java.lang.String> getProtocolRequestHeaders(Context<T> context, OperationShape operationShape)
These protocol specific headers are not automatically added to requests, but are used when integrating with things like CORS.
context
- OpenAPI contextoperationShape
- Smithy operationdefault java.util.Set<java.lang.String> getProtocolResponseHeaders(Context<T> context, OperationShape operationShape)
These protocol specific headers are not automatically added to responses, but are used when integrating with things like CORS.
context
- OpenAPI contextoperationShape
- Smithy operation