Class JsonSchemaConverter

All Implemented Interfaces:

public final class JsonSchemaConverter extends Object implements ToSmithyBuilder<JsonSchemaConverter>
Converts a Smithy model index to a JSON schema document.
  • Method Details

    • builder

      public static JsonSchemaConverter.Builder builder()
    • getConfig

      public JsonSchemaConfig getConfig()
      Gets the configuration object.
      Returns the config object.
    • setConfig

      public void setConfig(JsonSchemaConfig config)
      Set the JSON Schema configuration settings.
      config - Config object to set.
    • toPropertyName

      public String toPropertyName(MemberShape member)
      Gets the property naming strategy of the converter.
      member - Member to convert to a property name.
      Returns the PropertyNamingStrategy.
    • toPointer

      public String toPointer(ToShapeId id)
      Given a shape ID, returns the value used in a $ref to refer to it.

      The return value is expected to be a JSON pointer.

      id - Shape ID to convert to a $ref string.
      Returns the $ref string (e.g., "#/responses/MyShape").
    • isTopLevelPointer

      public boolean isTopLevelPointer(String pointer)
      Checks if the given JSON pointer points to a top-level definition.

      Note that this expects the pointer to exactly start with the same string that is configured as JsonSchemaConfig.getDefinitionPointer(), or the default value of "#/definitions". If the number of segments in the provided pointer is also equal to the number of segments in the default pointer + 1, then it is considered a top-level pointer.

      pointer - Pointer to check.
      Returns true if this is a top-level definition pointer.
    • isInlined

      public boolean isInlined(Shape shape)
      Checks if the given shape is inlined into its container when targeted by a member.
      shape - Shape to check.
      Returns true if this shape is inlined into its containing shape.
    • convert

      public SchemaDocument convert()
      Perform the conversion of the entire shape index.
      Returns the created SchemaDocument.
    • convertShape

      public SchemaDocument convertShape(Shape shape)
      Perform the conversion of a single shape.

      The root shape of the created document is set to the given shape. No schema extensions are added to the converted schema. This conversion also doesn't take the shape predicate or private controls into account.

      shape - Shape to convert.
      Returns the created SchemaDocument.
    • toBuilder

      public JsonSchemaConverter.Builder toBuilder()
      Description copied from interface: ToSmithyBuilder
      Take this object and create a builder that contains all of the current property values of this object.
      Specified by:
      toBuilder in interface ToSmithyBuilder<JsonSchemaConverter>
      a builder for type T