Class ExpandedTypeDescription

java.lang.Object
org.yaml.snakeyaml.TypeDescription
io.helidon.microprofile.openapi.ExpandedTypeDescription

public class ExpandedTypeDescription extends org.yaml.snakeyaml.TypeDescription
Extension of TypeDescription that handles:
  • nested enums,
  • extensible types,
  • references, and
  • additional properties (which can be either Boolean or Schema).

The OpenAPI document format uses lower-case enum names and values, while the SmallRye definitions use upper-case. This class simplifies adding the special handling for enums declared within a particular class.

Some of the MP OpenAPI items are extensible, meaning they accept sub-item keys with the "x-" prefix. This class supports extensions. For scalars it delegates to the normal SnakeYAML processing to correctly type and parse the scalar. For sequences it creates Lists. For mappings it creates Maps. The sub-nodes of the lists and maps are handled by the normal SnakeYAML parsing, so the resulting elements in lists and maps are of the SnakeYAML-inferred types.

A sub-node $ref maps to the ref property on the MP OpenAPI types. This type description simplifies defining the $ref property to those types that support it.

In schemas, the additionalProperties value can be either a boolean or a schema. The MicroProfile Schema type exposes getAdditionalPropertiesBoolean, setAdditionalPropertiesBoolean, getAdditionalPropertiesSchema, and setAdditionalPropertiesSchema methods. We do not know until runtime and the value is available for each additionalProperties instance which type (Boolean or Schema) to use, so we cannot just prepare a smart SnakeYAML Property implementation. Instead we augment the schema-specific TypeDescription so it knows how to decide, at runtime, what to do.

We use this expanded version of TypeDescription with the generated SnakeYAMLParserHelper class.

  • Field Summary

    Fields inherited from class org.yaml.snakeyaml.TypeDescription

    beanAccess, excludes, includes
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addExcludes(String... propNames)
    Add property names excludes.
    Deprecated, for removal: This API element is subject to removal in a future version.
    No need to invoke addExtensions any longer; extensions are handled by the custom property utils implementation.
    Deprecated, for removal: This API element is subject to removal in a future version.
    No need to invoke addRef any longer; refs are handled by the custom property utils implementation.
    create(Class<?> clazz, Class<?> impl)
    Factory method for ease of chaining other method invocations.
    org.yaml.snakeyaml.introspector.Property
     
    boolean
    Whether a default value exists.
    Returns the implementation class associated with this type descr.
    newInstance(String propertyName, org.yaml.snakeyaml.nodes.Node node)
     
    boolean
    setupPropertyType(String key, org.yaml.snakeyaml.nodes.Node valueNode)
     

    Methods inherited from class org.yaml.snakeyaml.TypeDescription

    addPropertyParameters, finalizeConstruction, getProperties, getTag, getType, newInstance, putListPropertyType, putMapPropertyType, setExcludes, setIncludes, setProperty, setPropertyUtils, substituteProperty, substituteProperty, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Method Details

    • create

      public static ExpandedTypeDescription create(Class<?> clazz, Class<?> impl)
      Factory method for ease of chaining other method invocations.
      Parameters:
      clazz - interface type to describe
      impl - implementation class for the interface
      Returns:
      resulting TypeDescription
    • addRef

      @Deprecated(since="4.3.2", forRemoval=true) public ExpandedTypeDescription addRef()
      Deprecated, for removal: This API element is subject to removal in a future version.
      No need to invoke addRef any longer; refs are handled by the custom property utils implementation.
      Adds property handling for a $ref reference.
      Returns:
      this type description
    • addExtensions

      @Deprecated(since="4.3.2", forRemoval=true) public ExpandedTypeDescription addExtensions()
      Deprecated, for removal: This API element is subject to removal in a future version.
      No need to invoke addExtensions any longer; extensions are handled by the custom property utils implementation.
      Adds property handling for extensions.
      Returns:
      this type description
    • getProperty

      public org.yaml.snakeyaml.introspector.Property getProperty(String name)
      Overrides:
      getProperty in class org.yaml.snakeyaml.TypeDescription
    • setupPropertyType

      public boolean setupPropertyType(String key, org.yaml.snakeyaml.nodes.Node valueNode)
      Overrides:
      setupPropertyType in class org.yaml.snakeyaml.TypeDescription
    • newInstance

      public Object newInstance(String propertyName, org.yaml.snakeyaml.nodes.Node node)
      Overrides:
      newInstance in class org.yaml.snakeyaml.TypeDescription
    • addExcludes

      public void addExcludes(String... propNames)
      Add property names excludes.
      Parameters:
      propNames - names to exclude
    • impl

      public Class<?> impl()
      Returns the implementation class associated with this type descr.
      Returns:
      implementation class
    • hasDefaultProperty

      public boolean hasDefaultProperty()
      Whether a default value exists.
      Returns:
      true if default value property is defined