Class JsonSchemaConfig
- Direct Known Subclasses:
CfnConfig
,OpenApiConfig
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Configures how Smithy map shapes are converted to JSON Schema.static enum
Configures how Smithy union shapes are converted to JSON Schema. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiondetectJsonTimestampFormat
(Shape shape) Detects the TimestampFormat of the given shape, falling back to the configured default format specified insetDefaultTimestampFormat(TimestampFormatTrait.Format)
.boolean
<T> T
getExtensions
(Class<T> as) Attempts to deserialize theextensions
into the targeted type using aNodeMapper
.Gets the service shape ID that is used to contextualize the created schemas by using things like the "rename" property of the service.boolean
boolean
boolean
boolean
void
putExtension
(String key, boolean value) Add an extension to the "extensions" object node.void
putExtension
(String key, String value) Add an extension to the "extensions" object node.void
putExtension
(String key, Node value) Add an extension to the "extensions" object node.void
putExtensions
(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
(String definitionPointer) Configures location of where definitions are written using JSON Pointer.void
setDisableFeatures
(Set<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
setUseIntegerType
(boolean useIntegerType) Set to true to use the "integer" type when convertingbyte
,short
,integer
, andlong
shapes to Json Schema.void
setUseJsonName
(boolean useJsonName) Uses the value of the jsonName trait when creating JSON schema properties for structure and union shapes.
-
Constructor Details
-
JsonSchemaConfig
public JsonSchemaConfig()
-
-
Method Details
-
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
-
setDefaultTimestampFormat
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
-
setUnionStrategy
Configures how Smithy union shapes are converted to JSON Schema.- Parameters:
unionStrategy
- The union strategy to use.
-
getMapStrategy
-
setMapStrategy
Configures how Smithy map shapes are converted to JSON Schema.- Parameters:
mapStrategy
- The map strategy to use.
-
getDefinitionPointer
-
setDefinitionPointer
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
-
setSchemaDocumentExtensions
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
-
setDisableFeatures
Disables OpenAPI features by their property name (e.g., "allOf").- Parameters:
disableFeatures
- Feature names to disable.
-
getExtensions
-
getExtensions
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
Sets an arbitrary map of "extensions" used by plugins that need configuration.- Parameters:
extensions
- Extensions to set.
-
putExtensions
Add an extension to the "extensions" object node using a POJO.- Parameters:
extensionContainer
- POJO to serialize and merge into extensions.
-
putExtension
Add an extension to the "extensions" object node.- Parameters:
key
- Property name to set.value
- Value to assigned.
-
putExtension
Add an extension to the "extensions" object node.- Parameters:
key
- Property name to set.value
- Value to assigned.
-
putExtension
Add an extension to the "extensions" object node.- Parameters:
key
- Property name to set.value
- Value to assigned.
-
getService
Gets the service shape ID that is used to contextualize the created schemas by using things like the "rename" property of the service.- Returns:
- the nullable Smithy service shape ID.
-
setService
Sets the service shape ID that is used to contextualize the created schemas by using things like the "rename" property of the service.- Parameters:
service
- the Smithy service shape ID.
-
detectJsonTimestampFormat
Detects the TimestampFormat of the given shape, falling back to the configured default format specified insetDefaultTimestampFormat(TimestampFormatTrait.Format)
.- Parameters:
shape
- Shape to extract the timestamp format from.- Returns:
- Returns the optionally detected format.
-
getSupportNonNumericFloats
public boolean getSupportNonNumericFloats() -
setSupportNonNumericFloats
public void setSupportNonNumericFloats(boolean supportNonNumericFloats) Set to true to add support for NaN, Infinity, and -Infinity in float and double shapes. These values will be serialized as strings. The OpenAPI document will be updated to refer to them as a "oneOf" of number and string.By default, non-numeric values are not supported.
- Parameters:
supportNonNumericFloats
- True if non-numeric float values should be supported.
-
isEnableOutOfServiceReferences
public boolean isEnableOutOfServiceReferences() -
setEnableOutOfServiceReferences
public void setEnableOutOfServiceReferences(boolean enableOutOfServiceReferences) Set to true to enable references to shapes outside the service closure. Setting this to true means that all the shapes in the model must not conflict, whereas leaving it at the default, false, means that only the shapes connected to the configured service viasetService(ShapeId)
must not conflict.- Parameters:
enableOutOfServiceReferences
- true if out-of-service references should be allowed. default: false
-
getUseIntegerType
public boolean getUseIntegerType() -
setUseIntegerType
public void setUseIntegerType(boolean useIntegerType) Set to true to use the "integer" type when convertingbyte
,short
,integer
, andlong
shapes to Json Schema.By default, these shape types are converted to Json Schema with a type of "number".
- Parameters:
useIntegerType
- True to use "integer".
-