Class JsonSchemaConfig
- java.lang.Object
-
- software.amazon.smithy.jsonschema.JsonSchemaConfig
-
- Direct Known Subclasses:
CfnConfig
,OpenApiConfig
public class JsonSchemaConfig extends java.lang.Object
JSON Schema configuration options.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class 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 Summary
Constructors Constructor Description JsonSchemaConfig()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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 theextensions
into the targeted type using aNodeMapper
.JsonSchemaConfig.MapStrategy
getMapStrategy()
ObjectNode
getSchemaDocumentExtensions()
JsonSchemaConfig.UnionStrategy
getUnionStrategy()
boolean
getUseJsonName()
void
putExtension(java.lang.String key, boolean 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
putExtension(java.lang.String key, Node 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 name (e.g., "allOf").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
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.
-
-
-
Method Detail
-
getAlphanumericOnlyRefs
public boolean getAlphanumericOnlyRefs()
-
setAlphanumericOnlyRefs
public void setAlphanumericOnlyRefs(boolean alphanumericOnlyRefs)
Creates shape name pointers that strip out non-alphanumeric characters.This is necessary for compatibility with some vendors like Amazon API Gateway that only allow alphanumeric shape names.
- Parameters:
alphanumericOnlyRefs
- Set to true to strip non-alphanumeric characters.
-
getUseJsonName
public boolean getUseJsonName()
-
setUseJsonName
public void setUseJsonName(boolean useJsonName)
Uses the value of the jsonName trait when creating JSON schema properties for structure and union shapes.This property has no effect if a
PropertyNamingStrategy
is manually configured on aJsonSchemaConverter
.- Parameters:
useJsonName
- Set to true to use jsonName traits when creating refs..
-
getDefaultTimestampFormat
public TimestampFormatTrait.Format getDefaultTimestampFormat()
-
setDefaultTimestampFormat
public void setDefaultTimestampFormat(TimestampFormatTrait.Format defaultTimestampFormat)
Sets the assumed timestampFormat trait for timestamps with no timestampFormat trait. The provided value is expected to be a string.Defaults to "date-time" if not set. Can be set to "date-time", "epoch-seconds", or "http-date".
- Parameters:
defaultTimestampFormat
- The default timestamp format to use when none is set.
-
getUnionStrategy
public JsonSchemaConfig.UnionStrategy getUnionStrategy()
-
setUnionStrategy
public void setUnionStrategy(JsonSchemaConfig.UnionStrategy unionStrategy)
Configures how Smithy union shapes are converted to JSON Schema.- Parameters:
unionStrategy
- The union strategy to use.
-
getMapStrategy
public JsonSchemaConfig.MapStrategy getMapStrategy()
-
setMapStrategy
public void setMapStrategy(JsonSchemaConfig.MapStrategy mapStrategy)
Configures how Smithy map shapes are converted to JSON Schema.- Parameters:
mapStrategy
- The map strategy to use.
-
getDefinitionPointer
public java.lang.String getDefinitionPointer()
-
setDefinitionPointer
public void setDefinitionPointer(java.lang.String definitionPointer)
Configures location of where definitions are written using JSON Pointer.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".
- Parameters:
definitionPointer
- The root definition pointer to use.
-
getSchemaDocumentExtensions
public ObjectNode getSchemaDocumentExtensions()
-
setSchemaDocumentExtensions
public void setSchemaDocumentExtensions(ObjectNode schemaDocumentExtensions)
Adds custom key-value pairs to the JSON Schema document generated from a Smithy model.- Parameters:
schemaDocumentExtensions
- Custom extensions to merge into the created schema.
-
getDisableFeatures
public java.util.Set<java.lang.String> getDisableFeatures()
-
setDisableFeatures
public void setDisableFeatures(java.util.Set<java.lang.String> disableFeatures)
Disables OpenAPI features by their property name name (e.g., "allOf").- Parameters:
disableFeatures
- Feature names to disable.
-
getExtensions
public ObjectNode getExtensions()
-
getExtensions
public <T> T getExtensions(java.lang.Class<T> as)
Attempts to deserialize theextensions
into the targeted type using aNodeMapper
.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.
- Type Parameters:
T
- Type to deserialize extensions into.- Parameters:
as
- Type to deserialize extensions into.- Returns:
- Returns the deserialized type.
-
setExtensions
public void setExtensions(ObjectNode extensions)
Sets an arbitrary map of "extensions" used by plugins that need configuration.- Parameters:
extensions
- Extensions to set.
-
putExtensions
public void putExtensions(java.lang.Object extensionContainer)
Add an extension to the "extensions" object node using a POJO.- Parameters:
extensionContainer
- POJO to serialize and merge into extensions.
-
putExtension
public void putExtension(java.lang.String key, Node value)
Add an extension to the "extensions" object node.- Parameters:
key
- Property name to set.value
- Value to assigned.
-
putExtension
public void putExtension(java.lang.String key, boolean value)
Add an extension to the "extensions" object node.- Parameters:
key
- Property name to set.value
- Value to assigned.
-
putExtension
public void putExtension(java.lang.String key, java.lang.String value)
Add an extension to the "extensions" object node.- Parameters:
key
- Property name to set.value
- Value to assigned.
-
-