public class JsonSchemaConfig
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
JsonSchemaConfig.MapStrategy
Configures how Smithy map shapes are converted to JSON Schema.
|
static class |
JsonSchemaConfig.UnionStrategy
Configures how Smithy union shapes are converted to JSON Schema.
|
Constructor and Description |
---|
JsonSchemaConfig() |
Modifier and Type | Method and Description |
---|---|
java.util.Optional<java.lang.String> |
detectJsonTimestampFormat(Shape shape)
Detects the TimestampFormat of the given shape, falling back to the
configured default format specified in
setDefaultTimestampFormat(TimestampFormatTrait.Format) . |
boolean |
getAlphanumericOnlyRefs() |
TimestampFormatTrait.Format |
getDefaultTimestampFormat() |
java.lang.String |
getDefinitionPointer() |
java.util.Set<java.lang.String> |
getDisableFeatures() |
ObjectNode |
getExtensions() |
<T> T |
getExtensions(java.lang.Class<T> as)
Attempts to deserialize the
extensions into the targeted
type using a NodeMapper . |
JsonSchemaConfig.MapStrategy |
getMapStrategy() |
ObjectNode |
getSchemaDocumentExtensions() |
ShapeId |
getService()
Gets the service shape ID that is used to contextualize the created
schemas by using things like the "rename" property of the service.
|
boolean |
getSupportNonNumericFloats() |
JsonSchemaConfig.UnionStrategy |
getUnionStrategy() |
boolean |
getUseJsonName() |
boolean |
isEnableOutOfServiceReferences() |
void |
putExtension(java.lang.String key,
boolean value)
Add an extension to the "extensions" object node.
|
void |
putExtension(java.lang.String key,
Node value)
Add an extension to the "extensions" object node.
|
void |
putExtension(java.lang.String key,
java.lang.String value)
Add an extension to the "extensions" object node.
|
void |
putExtensions(java.lang.Object extensionContainer)
Add an extension to the "extensions" object node using a POJO.
|
void |
setAlphanumericOnlyRefs(boolean alphanumericOnlyRefs)
Creates shape name pointers that strip out non-alphanumeric characters.
|
void |
setDefaultTimestampFormat(TimestampFormatTrait.Format defaultTimestampFormat)
Sets the assumed timestampFormat trait for timestamps with no
timestampFormat trait.
|
void |
setDefinitionPointer(java.lang.String definitionPointer)
Configures location of where definitions are written using JSON Pointer.
|
void |
setDisableFeatures(java.util.Set<java.lang.String> disableFeatures)
Disables OpenAPI features by their property name (e.g., "allOf").
|
void |
setEnableOutOfServiceReferences(boolean enableOutOfServiceReferences)
Set to true to enable references to shapes outside the service closure.
|
void |
setExtensions(ObjectNode extensions)
Sets an arbitrary map of "extensions" used by plugins that need
configuration.
|
void |
setMapStrategy(JsonSchemaConfig.MapStrategy mapStrategy)
Configures how Smithy map shapes are converted to JSON Schema.
|
void |
setSchemaDocumentExtensions(ObjectNode schemaDocumentExtensions)
Adds custom key-value pairs to the JSON Schema document generated from
a Smithy model.
|
void |
setService(ShapeId service)
Sets the service shape ID that is used to contextualize the created
schemas by using things like the "rename" property of the service.
|
void |
setSupportNonNumericFloats(boolean supportNonNumericFloats)
Set to true to add support for NaN, Infinity, and -Infinity in float
and double shapes.
|
void |
setUnionStrategy(JsonSchemaConfig.UnionStrategy unionStrategy)
Configures how Smithy union shapes are converted to JSON Schema.
|
void |
setUseJsonName(boolean useJsonName)
Uses the value of the jsonName trait when creating JSON schema
properties for structure and union shapes.
|
public boolean getAlphanumericOnlyRefs()
public void setAlphanumericOnlyRefs(boolean alphanumericOnlyRefs)
This is necessary for compatibility with some vendors like Amazon API Gateway that only allow alphanumeric shape names.
alphanumericOnlyRefs
- Set to true to strip non-alphanumeric characters.public boolean getUseJsonName()
public void setUseJsonName(boolean useJsonName)
This property has no effect if a PropertyNamingStrategy
is
manually configured on a JsonSchemaConverter
.
useJsonName
- Set to true to use jsonName traits when creating refs..public TimestampFormatTrait.Format getDefaultTimestampFormat()
public void setDefaultTimestampFormat(TimestampFormatTrait.Format defaultTimestampFormat)
Defaults to "date-time" if not set. Can be set to "date-time", "epoch-seconds", or "http-date".
defaultTimestampFormat
- The default timestamp format to use when none is set.public JsonSchemaConfig.UnionStrategy getUnionStrategy()
public void setUnionStrategy(JsonSchemaConfig.UnionStrategy unionStrategy)
unionStrategy
- The union strategy to use.public JsonSchemaConfig.MapStrategy getMapStrategy()
public void setMapStrategy(JsonSchemaConfig.MapStrategy mapStrategy)
mapStrategy
- The map strategy to use.public java.lang.String getDefinitionPointer()
public void setDefinitionPointer(java.lang.String definitionPointer)
The provided String value MUST start with "#/" and can use nested "/" characters to place schemas in nested object properties. The provided JSON Pointer does not support escaping.
Defaults to "#/definitions" if no value is specified. OpenAPI artifacts will want to use "#/components/schemas".
definitionPointer
- The root definition pointer to use.public ObjectNode getSchemaDocumentExtensions()
public void setSchemaDocumentExtensions(ObjectNode schemaDocumentExtensions)
schemaDocumentExtensions
- Custom extensions to merge into the created schema.public java.util.Set<java.lang.String> getDisableFeatures()
public void setDisableFeatures(java.util.Set<java.lang.String> disableFeatures)
disableFeatures
- Feature names to disable.public ObjectNode getExtensions()
public <T> T getExtensions(java.lang.Class<T> as)
extensions
into the targeted
type using a NodeMapper
.
Extraneous properties are ignored and not warned on because many different plugins could be used with different configuration POJOs.
The result of calling this method is cached for each type, and the cache is cleared when any mutation is made to extensions.
T
- Type to deserialize extensions into.as
- Type to deserialize extensions into.public void setExtensions(ObjectNode extensions)
extensions
- Extensions to set.public void putExtensions(java.lang.Object extensionContainer)
extensionContainer
- POJO to serialize and merge into extensions.public void putExtension(java.lang.String key, Node value)
key
- Property name to set.value
- Value to assigned.public void putExtension(java.lang.String key, boolean value)
key
- Property name to set.value
- Value to assigned.public void putExtension(java.lang.String key, java.lang.String value)
key
- Property name to set.value
- Value to assigned.public ShapeId getService()
public void setService(ShapeId service)
service
- the Smithy service shape ID.public java.util.Optional<java.lang.String> detectJsonTimestampFormat(Shape shape)
setDefaultTimestampFormat(TimestampFormatTrait.Format)
.shape
- Shape to extract the timestamp format from.public boolean getSupportNonNumericFloats()
public void setSupportNonNumericFloats(boolean supportNonNumericFloats)
By default, non-numeric values are not supported.
supportNonNumericFloats
- True if non-numeric float values should be supported.public boolean isEnableOutOfServiceReferences()
public void setEnableOutOfServiceReferences(boolean enableOutOfServiceReferences)
setService(ShapeId)
must not conflict.enableOutOfServiceReferences
- true if out-of-service references should be allowed. default: false