Class JsonSchemaConverter
java.lang.Object
software.amazon.smithy.jsonschema.JsonSchemaConverter
- All Implemented Interfaces:
ToSmithyBuilder<JsonSchemaConverter>
public final class JsonSchemaConverter
extends Object
implements ToSmithyBuilder<JsonSchemaConverter>
Converts a Smithy model index to a JSON schema document.
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic JsonSchemaConverter.Builder
builder()
convert()
Perform the conversion of the entire shape index.convertShape
(Shape shape) Perform the conversion of a single shape.Gets the configuration object.boolean
Checks if the given shape is inlined into its container when targeted by a member.boolean
isTopLevelPointer
(String pointer) Checks if the given JSON pointer points to a top-level definition.void
setConfig
(JsonSchemaConfig config) Set the JSON Schema configuration settings.Take this object and create a builder that contains all of the current property values of this object.Given a shape ID, returns the value used in a $ref to refer to it.toPropertyName
(MemberShape member) Gets the property naming strategy of the converter.
-
Method Details
-
builder
-
getConfig
Gets the configuration object.- Returns:
- Returns the config object.
-
setConfig
Set the JSON Schema configuration settings.- Parameters:
config
- Config object to set.
-
toPropertyName
Gets the property naming strategy of the converter.- Parameters:
member
- Member to convert to a property name.- Returns:
- Returns the PropertyNamingStrategy.
-
toPointer
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.
- Parameters:
id
- Shape ID to convert to a $ref string.- Returns:
- Returns the $ref string (e.g., "#/responses/MyShape").
-
isTopLevelPointer
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.- Parameters:
pointer
- Pointer to check.- Returns:
- Returns true if this is a top-level definition pointer.
-
isInlined
Checks if the given shape is inlined into its container when targeted by a member.- Parameters:
shape
- Shape to check.- Returns:
- Returns true if this shape is inlined into its containing shape.
-
convert
Perform the conversion of the entire shape index.- Returns:
- Returns the created SchemaDocument.
-
convertShape
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.
- Parameters:
shape
- Shape to convert.- Returns:
- Returns the created SchemaDocument.
-
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 interfaceToSmithyBuilder<JsonSchemaConverter>
- Returns:
- a builder for type T
-