Annotation Interface Extension


A named extension that should be added to the OpenAPI definition. The names of all extensions MUST begin with x- or else an invalid document will potentially be created.

Although this annotation may currently be placed directly on a Java language element target, application developers should instead utilize the extensions property of the particular annotation that corresponds to the model being extended. Use of the annotation directly on a Java element is often ambiguous and it may result in the extension being added to an incorrect location in the OpenAPI model. Future releases of MicroProfile OpenAPI may remove the capability of placing this annotation directly on a Java element.

When @Extension annotations are used both directly on a Java element as well as within another annotation that targets the same Java element, implementations will apply only the nested extensions to the resulting model.

Example of preferred use with @Extension nested within an @Schema annotation:

 class MyPojo {

     @Schema(
         type = SchemaType.STRING,
         extensions = @Extension(
             name = "x-custom-property",
             value = "custom-value")
     String property1;
 
 }
 

Example of deprecated use with @Extension placed directly on a field implied to be a schema property:

 class MyPojo {

     @Extension(
         name = "x-custom-property",
         value = "custom-value")
     String property1;

 }
 
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    A name for the extension.
    The extension value.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    Should the value be parsed into an object/array or other simple type (number, boolean, etc) or left as a simple String.
  • Element Details

    • name

      String name
      A name for the extension. The names of all extensions MUST begin with x- or else an invalid document will potentially be created.
      Returns:
      an option name for these extensions - must be prefixed with x-
    • value

      String value
      The extension value. If the value should be parsed into an object or array, then the value should be stringified JSON suitable for parsing by a standard JSON parser.
      Returns:
      the actual extension value
    • parseValue

      boolean parseValue
      Should the value be parsed into an object/array or other simple type (number, boolean, etc) or left as a simple String. If this is true, then the value must be parseable as one of:
      • JSON object
      • JSON array
      • number
      • boolean
      Returns:
      true if the value should be parsed
      Default:
      false