Class JsonSchemaConverter

    • Method Detail

      • getConfig

        public JsonSchemaConfig getConfig()
        Gets the configuration object.
        Returns:
        Returns the config object.
      • setConfig

        public void setConfig​(JsonSchemaConfig config)
        Set the JSON Schema configuration settings.
        Parameters:
        config - Config object to set.
      • toPropertyName

        public java.lang.String toPropertyName​(MemberShape member)
        Gets the property naming strategy of the converter.
        Parameters:
        member - Member to convert to a property name.
        Returns:
        Returns the PropertyNamingStrategy.
      • toPointer

        public java.lang.String toPointer​(ToShapeId id)
        Given a shape ID, returns the value used in a $ref to refer to it.

        The return value is expected to be a JSON pointer.

        Parameters:
        id - Shape ID to convert to a $ref string.
        Returns:
        Returns the $ref string (e.g., "#/responses/MyShape").
      • isTopLevelPointer

        public boolean isTopLevelPointer​(java.lang.String pointer)
        Checks if the given JSON pointer points to a top-level definition.

        Note that this expects the pointer to exactly start with the same string that is configured as JsonSchemaConfig.getDefinitionPointer(), or the default value of "#/definitions". If the number of segments in the provided pointer is also equal to the number of segments in the default pointer + 1, then it is considered a top-level pointer.

        Parameters:
        pointer - Pointer to check.
        Returns:
        Returns true if this is a top-level definition pointer.
      • isInlined

        public boolean isInlined​(Shape shape)
        Checks if the given shape is inlined into its container when targeted by a member.
        Parameters:
        shape - Shape to check.
        Returns:
        Returns true if this shape is inlined into its containing shape.
      • convert

        public SchemaDocument convert()
        Perform the conversion of the entire shape index.
        Returns:
        Returns the created SchemaDocument.
      • convertShape

        public SchemaDocument convertShape​(Shape shape)
        Perform the conversion of a single shape.

        The root shape of the created document is set to the given shape. No schema extensions are added to the converted schema. This conversion also doesn't take the shape predicate or private controls into account.

        Parameters:
        shape - Shape to convert.
        Returns:
        Returns the created SchemaDocument.