Class Schema
- java.lang.Object
-
- software.amazon.smithy.jsonschema.Schema
-
- All Implemented Interfaces:
ToNode
,ToSmithyBuilder<Schema>
public final class Schema extends java.lang.Object implements ToNode, ToSmithyBuilder<Schema>
Defines a single JSON schema.This supports a subset of the "draft-handrews-json-schema-validation-01" version of JSON Schema. The following properties are not supported:
- dependencies
- if
- then
- else
- examples
Custom properties can be added to the scheme using the
Schema.Builder.putExtension(java.lang.String, software.amazon.smithy.model.node.ToNode)
method. Custom properties are merged with the schema document when serializing it to aNode
object. Any extension properties that conflict with built-in properties overwrite the built-in property.- See Also:
- JSON Schema Validation
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Schema.Builder
Abstract class used to build Schema components.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Schema.Builder
builder()
boolean
equals(java.lang.Object o)
java.util.Optional<Schema>
getAdditionalProperties()
java.util.Map<java.lang.String,ToNode>
getAllExtensions()
java.util.List<Schema>
getAllOf()
java.util.List<Schema>
getAnyOf()
java.util.Optional<java.lang.String>
getComment()
java.util.Optional<Node>
getConstValue()
java.util.Optional<java.lang.String>
getContentEncoding()
java.util.Optional<java.lang.String>
getContentMediaType()
java.util.Optional<Node>
getDefaultValue()
java.util.Optional<java.lang.String>
getDescription()
java.util.Optional<java.util.Collection<java.lang.String>>
getEnumValues()
java.util.Optional<Node>
getExamples()
java.util.Optional<java.lang.Number>
getExclusiveMaximum()
java.util.Optional<java.lang.Number>
getExclusiveMinimum()
java.util.Optional<ToNode>
getExtension(java.lang.String key)
java.util.Optional<java.lang.String>
getFormat()
java.util.Optional<java.util.Collection<java.lang.Integer>>
getIntEnumValues()
java.util.Optional<Schema>
getItems()
java.util.Optional<java.lang.Number>
getMaximum()
java.util.Optional<java.lang.Integer>
getMaxItems()
java.util.Optional<java.lang.Long>
getMaxLength()
java.util.Optional<java.lang.Integer>
getMaxProperties()
java.util.Optional<java.lang.Number>
getMinimum()
java.util.Optional<java.lang.Integer>
getMinItems()
java.util.Optional<java.lang.Long>
getMinLength()
java.util.Optional<java.lang.Integer>
getMinProperties()
java.util.Optional<java.lang.Number>
getMultipleOf()
java.util.Optional<Schema>
getNot()
java.util.List<Schema>
getOneOf()
java.util.Optional<java.lang.String>
getPattern()
java.util.Map<java.lang.String,Schema>
getPatternProperties()
java.util.Map<java.lang.String,Schema>
getProperties()
java.util.Optional<Schema>
getProperty(java.lang.String key)
java.util.Optional<Schema>
getPropertyNames()
boolean
getReadOnly()
java.util.Optional<java.lang.String>
getRef()
java.util.Collection<java.lang.String>
getRequired()
java.util.Optional<java.lang.String>
getTitle()
java.util.Optional<java.lang.String>
getType()
boolean
getUniqueItems()
boolean
getWriteOnly()
int
hashCode()
java.util.Optional<Schema>
selectSchema(java.lang.String... segments)
Selects a nested schema using a variadic list of property names to descend into.Schema.Builder
toBuilder()
Take this object and create a builder that contains all of the current property values of this object.Node
toNode()
Converts a value to aNode
.
-
-
-
Method Detail
-
builder
public static Schema.Builder builder()
-
getRef
public java.util.Optional<java.lang.String> getRef()
-
getType
public java.util.Optional<java.lang.String> getType()
-
getEnumValues
public java.util.Optional<java.util.Collection<java.lang.String>> getEnumValues()
-
getIntEnumValues
public java.util.Optional<java.util.Collection<java.lang.Integer>> getIntEnumValues()
-
getConstValue
public java.util.Optional<Node> getConstValue()
-
getDefaultValue
public java.util.Optional<Node> getDefaultValue()
-
getMultipleOf
public java.util.Optional<java.lang.Number> getMultipleOf()
-
getMaximum
public java.util.Optional<java.lang.Number> getMaximum()
-
getExclusiveMaximum
public java.util.Optional<java.lang.Number> getExclusiveMaximum()
-
getMinimum
public java.util.Optional<java.lang.Number> getMinimum()
-
getExclusiveMinimum
public java.util.Optional<java.lang.Number> getExclusiveMinimum()
-
getMaxLength
public java.util.Optional<java.lang.Long> getMaxLength()
-
getMinLength
public java.util.Optional<java.lang.Long> getMinLength()
-
getPattern
public java.util.Optional<java.lang.String> getPattern()
-
getItems
public java.util.Optional<Schema> getItems()
-
getMaxItems
public java.util.Optional<java.lang.Integer> getMaxItems()
-
getMinItems
public java.util.Optional<java.lang.Integer> getMinItems()
-
getUniqueItems
public boolean getUniqueItems()
-
getMaxProperties
public java.util.Optional<java.lang.Integer> getMaxProperties()
-
getMinProperties
public java.util.Optional<java.lang.Integer> getMinProperties()
-
getRequired
public java.util.Collection<java.lang.String> getRequired()
-
getProperties
public java.util.Map<java.lang.String,Schema> getProperties()
-
getProperty
public java.util.Optional<Schema> getProperty(java.lang.String key)
-
getAdditionalProperties
public java.util.Optional<Schema> getAdditionalProperties()
-
getPropertyNames
public java.util.Optional<Schema> getPropertyNames()
-
getPatternProperties
public java.util.Map<java.lang.String,Schema> getPatternProperties()
-
getAllOf
public java.util.List<Schema> getAllOf()
-
getAnyOf
public java.util.List<Schema> getAnyOf()
-
getOneOf
public java.util.List<Schema> getOneOf()
-
getNot
public java.util.Optional<Schema> getNot()
-
getTitle
public java.util.Optional<java.lang.String> getTitle()
-
getDescription
public java.util.Optional<java.lang.String> getDescription()
-
getFormat
public java.util.Optional<java.lang.String> getFormat()
-
getReadOnly
public boolean getReadOnly()
-
getWriteOnly
public boolean getWriteOnly()
-
getComment
public java.util.Optional<java.lang.String> getComment()
-
getExamples
public java.util.Optional<Node> getExamples()
-
getContentEncoding
public java.util.Optional<java.lang.String> getContentEncoding()
-
getContentMediaType
public java.util.Optional<java.lang.String> getContentMediaType()
-
getExtension
public java.util.Optional<ToNode> getExtension(java.lang.String key)
-
getAllExtensions
public java.util.Map<java.lang.String,ToNode> getAllExtensions()
-
selectSchema
public java.util.Optional<Schema> selectSchema(java.lang.String... segments)
Selects a nested schema using a variadic list of property names to descend into.For example, this method can be used to get the items schema nested inside of an array inside of an object:
Schema itemsSchema = schema.selectSchema("properties", "foo", "items").get();
- Parameters:
segments
- The properties names to retrieve.- Returns:
- Returns the selected Schema.
-
toBuilder
public Schema.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 interfaceToSmithyBuilder<Schema>
- Returns:
- a builder for type T
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-