Class RpcV2JsonProtocolConverter

java.lang.Object
software.amazon.smithy.openapi.fromsmithy.protocols.RpcV2JsonProtocolConverter
All Implemented Interfaces:
OpenApiProtocol<Rpcv2JsonTrait>

public final class RpcV2JsonProtocolConverter extends Object implements OpenApiProtocol<Rpcv2JsonTrait>
Converts the smithy.protocols#rpcv2Json protocol to OpenAPI.

Each operation is mapped to a POST request with a path of /service/{serviceName}/operation/{operationName}, where serviceName is the service shape name (without namespace).

  • Constructor Details

    • RpcV2JsonProtocolConverter

      public RpcV2JsonProtocolConverter()
  • Method Details

    • getProtocolType

      public Class<Rpcv2JsonTrait> getProtocolType()
      Description copied from interface: OpenApiProtocol
      Gets the protocol type that this converter handles.
      Specified by:
      getProtocolType in interface OpenApiProtocol<Rpcv2JsonTrait>
      Returns:
      Returns the shape ID.
    • updateDefaultSettings

      public void updateDefaultSettings(Model model, OpenApiConfig config)
      Description copied from interface: OpenApiProtocol
      Sets protocol-specific default values on the OpenAPI configuration object.
      Specified by:
      updateDefaultSettings in interface OpenApiProtocol<Rpcv2JsonTrait>
      Parameters:
      model - Model being converted.
      config - Configuration object to modify.
    • createOperation

      public Optional<OpenApiProtocol.Operation> createOperation(Context<Rpcv2JsonTrait> context, OperationShape operation)
      Each operation will have a separate path in the format /service/{serviceName}/operation/{operationName}
      Specified by:
      createOperation in interface OpenApiProtocol<Rpcv2JsonTrait>
      Parameters:
      context - The build context.
      operation - The operation shape to create.
      Returns:
      Returns the optionally created operation entry.
    • getOperationResponseStatusCode

      public String getOperationResponseStatusCode(Context<Rpcv2JsonTrait> context, ToShapeId operationOrError)
      Description copied from interface: OpenApiProtocol
      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.

      Specified by:
      getOperationResponseStatusCode in interface OpenApiProtocol<Rpcv2JsonTrait>
      Parameters:
      context - The build context.
      operationOrError - Operation or error shape ID.
      Returns:
      Returns the status code as a string.
    • getOperationMethod

      public String getOperationMethod(Context<Rpcv2JsonTrait> context, OperationShape operation)
      Description copied from interface: OpenApiProtocol
      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.

      Specified by:
      getOperationMethod in interface OpenApiProtocol<Rpcv2JsonTrait>
      Parameters:
      context - The build context.
      operation - The operation to get the method of.
      Returns:
      Returns the method.
    • getOperationUri

      public String getOperationUri(Context<Rpcv2JsonTrait> context, OperationShape operation)
      Description copied from interface: OpenApiProtocol
      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.

      Specified by:
      getOperationUri in interface OpenApiProtocol<Rpcv2JsonTrait>
      Parameters:
      context - The build context.
      operation - The operation to get the URI of.
      Returns:
      Returns the operation URI.
    • getProtocolRequestHeaders

      public Set<String> getProtocolRequestHeaders(Context<Rpcv2JsonTrait> context, OperationShape operationShape)
      Description copied from interface: OpenApiProtocol
      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.

      Specified by:
      getProtocolRequestHeaders in interface OpenApiProtocol<Rpcv2JsonTrait>
      Parameters:
      context - OpenAPI context
      operationShape - Smithy operation
      Returns:
      Returns a set of header names.
    • getProtocolResponseHeaders

      public Set<String> getProtocolResponseHeaders(Context<Rpcv2JsonTrait> context, OperationShape operationShape)
      Description copied from interface: OpenApiProtocol
      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.

      Specified by:
      getProtocolResponseHeaders in interface OpenApiProtocol<Rpcv2JsonTrait>
      Parameters:
      context - OpenAPI context
      operationShape - Smithy operation
      Returns:
      Returns a set of header names.