Class JsonSchemaConfig

  • Direct Known Subclasses:
    CfnConfig, OpenApiConfig

    public class JsonSchemaConfig
    extends java.lang.Object
    JSON Schema configuration options.
    • Constructor Detail

      • JsonSchemaConfig

        public JsonSchemaConfig()
    • 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 a JsonSchemaConverter.

        Parameters:
        useJsonName - Set to true to use jsonName traits when creating refs..
      • 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.
      • setUnionStrategy

        public void setUnionStrategy​(JsonSchemaConfig.UnionStrategy unionStrategy)
        Configures how Smithy union shapes are converted to JSON Schema.
        Parameters:
        unionStrategy - The union strategy to use.
      • 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 the 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.

        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.