Top Description Methods
org.eclipse.microprofile.openapi.annotations.extensions

public @Interface Extension

extends Annotation
Annotations
@Target:FIELD, METHOD, PARAMETER, TYPE
@Retention:RUNTIME
@Repeatable:Extensions
Imports
java.lang.annotation.ElementType, .Repeatable, .Retention, .RetentionPolicy, .Target

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;

}

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

an option name for these extensions - must be prefixed with x-
name
()

A name for the extension.

public boolean

Returns:

true if the value should be parsed
parseValue
()

Should the value be parsed into an object/array or other simple type (number, boolean, etc) or left as a simple String.

public String

Returns:

the actual extension value
value
()

The extension value.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

nameback to summary
public 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:String

an option name for these extensions - must be prefixed with x-

parseValueback to summary
public 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:boolean

true if the value should be parsed

valueback to summary
public 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:String

the actual extension value