Interface OpenApiProtocol<T extends Trait>

  • Type Parameters:
    T - Type of Smithy protocol to convert.
    All Known Implementing Classes:
    AwsRestJson1Protocol

    public interface OpenApiProtocol<T extends Trait>
    An OpenAPI protocol is used to convert a Smithy protocol into HTTP-specific bindings.

    Instances of OpenApiProtocol are discovered using SPI and matched with configuration settings based on the result of matching a protocol against getProtocolType().

    • Method Detail

      • getProtocolType

        java.lang.Class<T> getProtocolType()
        Gets the protocol type that this converter handles.
        Returns:
        Returns the shape ID.
      • updateDefaultSettings

        default void updateDefaultSettings​(Model model,
                                           OpenApiConfig config)
        Sets protocol-specific default values on the OpenAPI configuration object.
        Parameters:
        model - Model being converted.
        config - Configuration object to modify.
      • getOperationUri

        default java.lang.String getOperationUri​(Context<T> context,
                                                 OperationShape operation)
        Gets the URI of an 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.

        Parameters:
        context - The build context.
        operation - The operation to get the URI of.
        Returns:
        Returns the operation URI.
      • getOperationMethod

        default java.lang.String getOperationMethod​(Context<T> context,
                                                    OperationShape operation)
        Gets the HTTP method of an 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.

        Parameters:
        context - The build context.
        operation - The operation to get the method of.
        Returns:
        Returns the method.
      • getOperationResponseStatusCode

        default java.lang.String getOperationResponseStatusCode​(Context<T> context,
                                                                ToShapeId operationOrError)
        Gets the response status code of an operation or error shape.

        The default implementation will attempt to use HTTP binding traits to determine the HTTP status code of an operation or error structure.

        Parameters:
        context - The build context.
        operationOrError - Operation or error shape ID.
        Returns:
        Returns the status code as a string.
      • getProtocolRequestHeaders

        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.

        These protocol specific headers are not automatically added to requests, but are used when integrating with things like CORS.

        Parameters:
        context - OpenAPI context
        operationShape - Smithy operation
        Returns:
        Returns a set of header names.
      • getProtocolResponseHeaders

        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.

        These protocol specific headers are not automatically added to responses, but are used when integrating with things like CORS.

        Parameters:
        context - OpenAPI context
        operationShape - Smithy operation
        Returns:
        Returns a set of header names.