diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/Components.java b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/Components.java index f0037480f..c1eeacd84 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/Components.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/Components.java @@ -22,6 +22,7 @@ import java.lang.annotation.Target; import org.eclipse.microprofile.openapi.annotations.callbacks.Callback; +import org.eclipse.microprofile.openapi.annotations.extensions.Extension; import org.eclipse.microprofile.openapi.annotations.headers.Header; import org.eclipse.microprofile.openapi.annotations.links.Link; import org.eclipse.microprofile.openapi.annotations.media.ExampleObject; @@ -105,4 +106,15 @@ * @return the reusable Callback objects. */ Callback[] callbacks() default {}; + + /** + * List of extensions to be added to the {@link org.eclipse.microprofile.openapi.models.Components Components} model + * corresponding to the containing annotation. + * + * @return array of extensions + * + * @since 3.1 + */ + Extension[] extensions() default {}; + } diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/ExternalDocumentation.java b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/ExternalDocumentation.java index 6653cff13..6b1fff0cf 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/ExternalDocumentation.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/ExternalDocumentation.java @@ -23,6 +23,8 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import org.eclipse.microprofile.openapi.annotations.extensions.Extension; + /** * This annotation allows referencing an external resource for extended documentation. *

@@ -56,4 +58,13 @@ **/ String url() default ""; + /** + * List of extensions to be added to the {@link org.eclipse.microprofile.openapi.models.ExternalDocumentation + * ExternalDocumentation} model corresponding to the containing annotation. + * + * @return array of extensions + * + * @since 3.1 + */ + Extension[] extensions() default {}; } diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/OpenAPIDefinition.java b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/OpenAPIDefinition.java index 6b971ab90..a42dd9f47 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/OpenAPIDefinition.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/OpenAPIDefinition.java @@ -23,6 +23,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import org.eclipse.microprofile.openapi.annotations.extensions.Extension; import org.eclipse.microprofile.openapi.annotations.info.Info; import org.eclipse.microprofile.openapi.annotations.security.SecurityRequirement; import org.eclipse.microprofile.openapi.annotations.servers.Server; @@ -87,4 +88,14 @@ * @return the element with a set of reusable objects for different aspects of the OAS. */ Components components() default @Components; + + /** + * List of extensions to be added to the {@link org.eclipse.microprofile.openapi.models.OpenAPI OpenAPI} model + * corresponding to the containing annotation. + * + * @return array of extensions + * + * @since 3.1 + */ + Extension[] extensions() default {}; } diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/Operation.java b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/Operation.java index 6fb327355..a3d8297f6 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/Operation.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/Operation.java @@ -23,6 +23,8 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import org.eclipse.microprofile.openapi.annotations.extensions.Extension; + /** * Describes a single API operation on a path. * @@ -75,4 +77,14 @@ * @return whether or not this operation is hidden */ boolean hidden() default false; + + /** + * List of extensions to be added to the {@link org.eclipse.microprofile.openapi.models.Operation Operation} model + * corresponding to the containing annotation. + * + * @return array of extensions + * + * @since 3.1 + */ + Extension[] extensions() default {}; } diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/callbacks/Callback.java b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/callbacks/Callback.java index c77f03aa5..0a09d7cf7 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/callbacks/Callback.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/callbacks/Callback.java @@ -24,6 +24,8 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import org.eclipse.microprofile.openapi.annotations.extensions.Extension; + /** * This object represents a callback URL that will be invoked. * @@ -74,4 +76,14 @@ * @return reference to a callback object definition **/ String ref() default ""; + + /** + * List of extensions to be added to the {@link org.eclipse.microprofile.openapi.models.callbacks.Callback Callback} + * model corresponding to the containing annotation. + * + * @return array of extensions + * + * @since 3.1 + */ + Extension[] extensions() default {}; } diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/callbacks/CallbackOperation.java b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/callbacks/CallbackOperation.java index 291ed01c3..376113c30 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/callbacks/CallbackOperation.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/callbacks/CallbackOperation.java @@ -109,9 +109,12 @@ SecurityRequirement[] security() default {}; /** - * The list of optional extensions. + * List of extensions to be added to the {@link org.eclipse.microprofile.openapi.models.Operation Operation} model + * corresponding to the containing annotation. * - * @return an optional array of extensions + * @return array of extensions + * + * @since 3.1 */ Extension[] extensions() default {}; } \ No newline at end of file diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/callbacks/package-info.java b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/callbacks/package-info.java index 1044a066d..e405149b6 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/callbacks/package-info.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/callbacks/package-info.java @@ -44,6 +44,6 @@ * */ -@org.osgi.annotation.versioning.Version("1.0") +@org.osgi.annotation.versioning.Version("1.1") @org.osgi.annotation.versioning.ProviderType package org.eclipse.microprofile.openapi.annotations.callbacks; \ No newline at end of file diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/extensions/Extension.java b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/extensions/Extension.java index cd5016356..691ffd8ca 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/extensions/Extension.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/extensions/Extension.java @@ -24,7 +24,51 @@ import java.lang.annotation.Target; /** - * A named extension that should be added to the OpenAPI definition. + * A named extension that should be added to the OpenAPI definition. The names of all extensions MUST begin with + * {@code 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 {@code 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 {@code @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 {@code @Extension} nested within an {@code @Schema} annotation: + * + *

+ * class MyPojo {
+ *
+ *     {@literal @}Schema(
+ *         type = SchemaType.STRING,
+ *         extensions = {@literal @}Extension(
+ *             name = "x-custom-property",
+ *             value = "custom-value")
+ *     String property1;
+ * 
+ * }
+ * 
+ * + *

+ * Example of deprecated use with {@code @Extension} placed directly on a field implied to be a schema + * property: + * + *

+ * class MyPojo {
+ *
+ *     {@literal @}Extension(
+ *         name = "x-custom-property",
+ *         value = "custom-value")
+ *     String property1;
+ *
+ * }
+ * 
+ * */ @Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @@ -32,9 +76,10 @@ public @interface Extension { /** - * A name for the extension. + * A name for the extension. The names of all extensions MUST begin with {@code x-} or else an invalid document will + * potentially be created. * - * @return an option name for these extensions - will be prefixed with "x-" + * @return an option name for these extensions - must be prefixed with {@code x-} */ String name(); diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/headers/Header.java b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/headers/Header.java index eb36e6687..c142c5524 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/headers/Header.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/headers/Header.java @@ -22,6 +22,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import org.eclipse.microprofile.openapi.annotations.extensions.Extension; import org.eclipse.microprofile.openapi.annotations.media.Schema; /** @@ -92,4 +93,13 @@ **/ String ref() default ""; + /** + * List of extensions to be added to the {@link org.eclipse.microprofile.openapi.models.headers.Header Header} model + * corresponding to the containing annotation. + * + * @return array of extensions + * + * @since 3.1 + */ + Extension[] extensions() default {}; } diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/headers/package-info.java b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/headers/package-info.java index bd0855c28..5a5af99d3 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/headers/package-info.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/headers/package-info.java @@ -26,6 +26,6 @@ * */ -@org.osgi.annotation.versioning.Version("1.0") +@org.osgi.annotation.versioning.Version("1.1") @org.osgi.annotation.versioning.ProviderType package org.eclipse.microprofile.openapi.annotations.headers; \ No newline at end of file diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/info/Contact.java b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/info/Contact.java index aa31e00c5..81bf1cf28 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/info/Contact.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/info/Contact.java @@ -22,6 +22,8 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import org.eclipse.microprofile.openapi.annotations.extensions.Extension; + /** * Contact information for the exposed API. * @@ -52,4 +54,13 @@ **/ String email() default ""; + /** + * List of extensions to be added to the {@link org.eclipse.microprofile.openapi.models.info.Contact Contact} model + * corresponding to the containing annotation. + * + * @return array of extensions + * + * @since 3.1 + */ + Extension[] extensions() default {}; } diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/info/Info.java b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/info/Info.java index f3d280b03..e0fa5fafa 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/info/Info.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/info/Info.java @@ -22,6 +22,8 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import org.eclipse.microprofile.openapi.annotations.extensions.Extension; + /** * This annotation provides metadata about the API, and maps to the Info object in OpenAPI Specification 3. * @@ -73,4 +75,13 @@ **/ String version(); + /** + * List of extensions to be added to the {@link org.eclipse.microprofile.openapi.models.info.Info Info} model + * corresponding to the containing annotation. + * + * @return array of extensions + * + * @since 3.1 + */ + Extension[] extensions() default {}; } diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/info/License.java b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/info/License.java index 71d75663e..7048c0642 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/info/License.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/info/License.java @@ -22,6 +22,8 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import org.eclipse.microprofile.openapi.annotations.extensions.Extension; + /** * License information for the exposed API. * @@ -45,4 +47,13 @@ **/ String url() default ""; + /** + * List of extensions to be added to the {@link org.eclipse.microprofile.openapi.models.info.License License} model + * corresponding to the containing annotation. + * + * @return array of extensions + * + * @since 3.1 + */ + Extension[] extensions() default {}; } diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/info/package-info.java b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/info/package-info.java index b36d5ab2c..741338fe6 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/info/package-info.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/info/package-info.java @@ -34,6 +34,6 @@ * */ -@org.osgi.annotation.versioning.Version("1.0") +@org.osgi.annotation.versioning.Version("1.1") @org.osgi.annotation.versioning.ProviderType package org.eclipse.microprofile.openapi.annotations.info; \ No newline at end of file diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/links/Link.java b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/links/Link.java index 4e52227d2..24c864b5f 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/links/Link.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/links/Link.java @@ -22,6 +22,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import org.eclipse.microprofile.openapi.annotations.extensions.Extension; import org.eclipse.microprofile.openapi.annotations.servers.Server; /** @@ -103,4 +104,13 @@ **/ String ref() default ""; + /** + * List of extensions to be added to the {@link org.eclipse.microprofile.openapi.models.links.Link Link} model + * corresponding to the containing annotation. + * + * @return array of extensions + * + * @since 3.1 + */ + Extension[] extensions() default {}; } diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/links/package-info.java b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/links/package-info.java index e0c769487..a768ee637 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/links/package-info.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/links/package-info.java @@ -31,6 +31,6 @@ * */ -@org.osgi.annotation.versioning.Version("1.0") +@org.osgi.annotation.versioning.Version("1.1") @org.osgi.annotation.versioning.ProviderType package org.eclipse.microprofile.openapi.annotations.links; \ No newline at end of file diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/media/Content.java b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/media/Content.java index 71c799c1d..e46e899b5 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/media/Content.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/media/Content.java @@ -22,6 +22,8 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import org.eclipse.microprofile.openapi.annotations.extensions.Extension; + /** * This object provides schema and examples for a particular media type. * @@ -72,4 +74,13 @@ */ Encoding[] encoding() default {}; + /** + * List of extensions to be added to the {@link org.eclipse.microprofile.openapi.models.media.MediaType MediaType} + * model corresponding to the containing annotation. + * + * @return array of extensions + * + * @since 3.1 + */ + Extension[] extensions() default {}; } diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/media/Encoding.java b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/media/Encoding.java index 1f52052e7..e7095514f 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/media/Encoding.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/media/Encoding.java @@ -22,6 +22,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import org.eclipse.microprofile.openapi.annotations.extensions.Extension; import org.eclipse.microprofile.openapi.annotations.headers.Header; /** @@ -103,4 +104,13 @@ */ Header[] headers() default {}; + /** + * List of extensions to be added to the {@link org.eclipse.microprofile.openapi.models.media.Encoding Encoding} + * model corresponding to the containing annotation. + * + * @return array of extensions + * + * @since 3.1 + */ + Extension[] extensions() default {}; } diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/media/ExampleObject.java b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/media/ExampleObject.java index e902ec5fb..1197d3a4a 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/media/ExampleObject.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/media/ExampleObject.java @@ -22,6 +22,8 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import org.eclipse.microprofile.openapi.annotations.extensions.Extension; + /** * This object illustrates an example of a particular content * @@ -91,4 +93,13 @@ **/ String ref() default ""; + /** + * List of extensions to be added to the {@link org.eclipse.microprofile.openapi.models.examples.Example Example} + * model corresponding to the containing annotation. + * + * @return array of extensions + * + * @since 3.1 + */ + Extension[] extensions() default {}; } diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/media/Schema.java b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/media/Schema.java index 13dee5f4d..54df22e22 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/media/Schema.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/media/Schema.java @@ -25,6 +25,7 @@ import org.eclipse.microprofile.openapi.annotations.ExternalDocumentation; import org.eclipse.microprofile.openapi.annotations.enums.SchemaType; +import org.eclipse.microprofile.openapi.annotations.extensions.Extension; /** * The Schema Object allows the definition of input and output data types. These types can be objects, but also @@ -399,4 +400,14 @@ * @since 2.0 */ SchemaProperty[] properties() default {}; + + /** + * List of extensions to be added to the {@link org.eclipse.microprofile.openapi.models.media.Schema Schema} model + * corresponding to the containing annotation. + * + * @return array of extensions + * + * @since 3.1 + */ + Extension[] extensions() default {}; } diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/media/SchemaProperty.java b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/media/SchemaProperty.java index 1f962094d..33f5e9852 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/media/SchemaProperty.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/media/SchemaProperty.java @@ -22,6 +22,7 @@ import org.eclipse.microprofile.openapi.annotations.ExternalDocumentation; import org.eclipse.microprofile.openapi.annotations.enums.SchemaType; +import org.eclipse.microprofile.openapi.annotations.extensions.Extension; /** * The SchemaProperty Object allows the definition of input and output data types nested within the @@ -362,4 +363,15 @@ * @return whether the items in this array are unique **/ boolean uniqueItems() default false; + + /** + * List of extensions to be added to the {@link org.eclipse.microprofile.openapi.models.media.Schema Schema} model + * corresponding to the containing annotation. + * + * @return array of extensions + * + * @since 3.1 + */ + Extension[] extensions() default {}; + } diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/media/package-info.java b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/media/package-info.java index 7a67836e6..e0495c13a 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/media/package-info.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/media/package-info.java @@ -25,6 +25,6 @@ * */ -@org.osgi.annotation.versioning.Version("1.1") +@org.osgi.annotation.versioning.Version("1.2") @org.osgi.annotation.versioning.ProviderType package org.eclipse.microprofile.openapi.annotations.media; \ No newline at end of file diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/package-info.java b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/package-info.java index d02041969..27404b1c6 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/package-info.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/package-info.java @@ -34,5 +34,5 @@ * */ -@org.osgi.annotation.versioning.Version("1.0") +@org.osgi.annotation.versioning.Version("1.1") package org.eclipse.microprofile.openapi.annotations; \ No newline at end of file diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/parameters/Parameter.java b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/parameters/Parameter.java index 6ad39edd0..b20a96029 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/parameters/Parameter.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/parameters/Parameter.java @@ -27,6 +27,7 @@ import org.eclipse.microprofile.openapi.annotations.enums.Explode; import org.eclipse.microprofile.openapi.annotations.enums.ParameterIn; import org.eclipse.microprofile.openapi.annotations.enums.ParameterStyle; +import org.eclipse.microprofile.openapi.annotations.extensions.Extension; import org.eclipse.microprofile.openapi.annotations.media.Content; import org.eclipse.microprofile.openapi.annotations.media.ExampleObject; import org.eclipse.microprofile.openapi.annotations.media.Schema; @@ -206,4 +207,14 @@ * @return reference to a parameter **/ String ref() default ""; + + /** + * List of extensions to be added to the {@link org.eclipse.microprofile.openapi.models.parameters.Parameter + * Parameter} model corresponding to the containing annotation. + * + * @return array of extensions + * + * @since 3.1 + */ + Extension[] extensions() default {}; } diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/parameters/RequestBody.java b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/parameters/RequestBody.java index 0f17f2e5c..4c2f49d8c 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/parameters/RequestBody.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/parameters/RequestBody.java @@ -23,6 +23,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import org.eclipse.microprofile.openapi.annotations.extensions.Extension; import org.eclipse.microprofile.openapi.annotations.media.Content; /** @@ -81,4 +82,13 @@ **/ String ref() default ""; + /** + * List of extensions to be added to the {@link org.eclipse.microprofile.openapi.models.parameters.RequestBody + * RequestBody} model corresponding to the containing annotation. + * + * @return array of extensions + * + * @since 3.1 + */ + Extension[] extensions() default {}; } diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/parameters/package-info.java b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/parameters/package-info.java index 0363db867..ef05542d6 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/parameters/package-info.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/parameters/package-info.java @@ -32,6 +32,6 @@ * */ -@org.osgi.annotation.versioning.Version("1.1") +@org.osgi.annotation.versioning.Version("1.2") @org.osgi.annotation.versioning.ProviderType package org.eclipse.microprofile.openapi.annotations.parameters; \ No newline at end of file diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/responses/APIResponse.java b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/responses/APIResponse.java index e7b2d8b77..c047a9360 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/responses/APIResponse.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/responses/APIResponse.java @@ -24,6 +24,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import org.eclipse.microprofile.openapi.annotations.extensions.Extension; import org.eclipse.microprofile.openapi.annotations.headers.Header; import org.eclipse.microprofile.openapi.annotations.links.Link; import org.eclipse.microprofile.openapi.annotations.media.Content; @@ -129,4 +130,13 @@ **/ String ref() default ""; + /** + * List of extensions to be added to the {@link org.eclipse.microprofile.openapi.models.responses.APIResponse + * APIResponse} model corresponding to the containing annotation. + * + * @return array of extensions + * + * @since 3.1 + */ + Extension[] extensions() default {}; } diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/responses/APIResponses.java b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/responses/APIResponses.java index 21a218de6..d3dc34bc7 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/responses/APIResponses.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/responses/APIResponses.java @@ -22,6 +22,8 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import org.eclipse.microprofile.openapi.annotations.extensions.Extension; + /** * The ApiResponses annotation is a container for @ApiResponse annotations. When used on a method it is treated as if * each ApiResponse annotation were applied individually. @@ -40,4 +42,13 @@ **/ APIResponse[] value() default {}; -} \ No newline at end of file + /** + * List of extensions to be added to the {@link org.eclipse.microprofile.openapi.models.responses.APIResponses + * APIResponses} model corresponding to the containing annotation. + * + * @return array of extensions + * + * @since 3.1 + */ + Extension[] extensions() default {}; +} diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/responses/package-info.java b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/responses/package-info.java index 9b40274f6..e0a019d7e 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/responses/package-info.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/responses/package-info.java @@ -30,6 +30,6 @@ * */ -@org.osgi.annotation.versioning.Version("1.1") +@org.osgi.annotation.versioning.Version("1.2") @org.osgi.annotation.versioning.ProviderType package org.eclipse.microprofile.openapi.annotations.responses; \ No newline at end of file diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/security/OAuthFlow.java b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/security/OAuthFlow.java index 062812103..d54775220 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/security/OAuthFlow.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/security/OAuthFlow.java @@ -22,6 +22,8 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import org.eclipse.microprofile.openapi.annotations.extensions.Extension; + /** * Configuration details for a supported OAuth Flow. * @@ -74,4 +76,13 @@ **/ OAuthScope[] scopes() default {}; + /** + * List of extensions to be added to the {@link org.eclipse.microprofile.openapi.models.security.OAuthFlow + * OAuthFlow} model corresponding to the containing annotation. + * + * @return array of extensions + * + * @since 3.1 + */ + Extension[] extensions() default {}; } diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/security/OAuthFlows.java b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/security/OAuthFlows.java index 407ee360a..44ba2fb7e 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/security/OAuthFlows.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/security/OAuthFlows.java @@ -22,6 +22,8 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import org.eclipse.microprofile.openapi.annotations.extensions.Extension; + /** * Allows configuration of the supported OAuth Flows. * @@ -60,4 +62,13 @@ **/ OAuthFlow authorizationCode() default @OAuthFlow(); + /** + * List of extensions to be added to the {@link org.eclipse.microprofile.openapi.models.security.OAuthFlows + * OAuthFlows} model corresponding to the containing annotation. + * + * @return array of extensions + * + * @since 3.1 + */ + Extension[] extensions() default {}; } diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/security/SecurityScheme.java b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/security/SecurityScheme.java index 7e6efe051..6279f3fb3 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/security/SecurityScheme.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/security/SecurityScheme.java @@ -26,6 +26,7 @@ import org.eclipse.microprofile.openapi.annotations.enums.SecuritySchemeIn; import org.eclipse.microprofile.openapi.annotations.enums.SecuritySchemeType; +import org.eclipse.microprofile.openapi.annotations.extensions.Extension; /** * Defines a security scheme that can be used by the operations. Supported schemes are HTTP authentication, an API key @@ -137,4 +138,13 @@ **/ String ref() default ""; + /** + * List of extensions to be added to the {@link org.eclipse.microprofile.openapi.models.security.SecurityScheme + * SecurityScheme} model corresponding to the containing annotation. + * + * @return array of extensions + * + * @since 3.1 + */ + Extension[] extensions() default {}; } diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/security/package-info.java b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/security/package-info.java index 7b96f0169..27ed594f2 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/security/package-info.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/security/package-info.java @@ -36,6 +36,6 @@ * */ -@org.osgi.annotation.versioning.Version("1.0") +@org.osgi.annotation.versioning.Version("1.1") @org.osgi.annotation.versioning.ProviderType package org.eclipse.microprofile.openapi.annotations.security; \ No newline at end of file diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/servers/Server.java b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/servers/Server.java index 9581135e2..4113dd529 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/servers/Server.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/servers/Server.java @@ -24,6 +24,8 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import org.eclipse.microprofile.openapi.annotations.extensions.Extension; + /** * This annotation represents a Server used in an operation or used by all operations in an OpenAPI document. *

@@ -72,4 +74,13 @@ **/ ServerVariable[] variables() default {}; + /** + * List of extensions to be added to the {@link org.eclipse.microprofile.openapi.models.servers.Server Server} model + * corresponding to the containing annotation. + * + * @return array of extensions + * + * @since 3.1 + */ + Extension[] extensions() default {}; } diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/servers/ServerVariable.java b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/servers/ServerVariable.java index b63b85b22..1702d6f83 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/servers/ServerVariable.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/servers/ServerVariable.java @@ -22,6 +22,8 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import org.eclipse.microprofile.openapi.annotations.extensions.Extension; + /** * An object representing a Server Variable for server URL template substitution. * @@ -62,4 +64,13 @@ **/ String description() default ""; + /** + * List of extensions to be added to the {@link org.eclipse.microprofile.openapi.models.servers.ServerVariable + * ServerVariable} model corresponding to the containing annotation. + * + * @return array of extensions + * + * @since 3.1 + */ + Extension[] extensions() default {}; } diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/servers/package-info.java b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/servers/package-info.java index 6a6e5ccfb..1dba8cbbd 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/servers/package-info.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/servers/package-info.java @@ -28,6 +28,6 @@ * */ -@org.osgi.annotation.versioning.Version("1.0") +@org.osgi.annotation.versioning.Version("1.1") @org.osgi.annotation.versioning.ProviderType package org.eclipse.microprofile.openapi.annotations.servers; \ No newline at end of file diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/tags/Tag.java b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/tags/Tag.java index 90376ec88..1a0bd3f85 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/tags/Tag.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/tags/Tag.java @@ -25,6 +25,7 @@ import java.lang.annotation.Target; import org.eclipse.microprofile.openapi.annotations.ExternalDocumentation; +import org.eclipse.microprofile.openapi.annotations.extensions.Extension; /** * This object represents a tag. A tag is meta-information you can use to help organize your API end-points and it can @@ -107,4 +108,14 @@ * @return reference to a tag **/ String ref() default ""; + + /** + * List of extensions to be added to the {@link org.eclipse.microprofile.openapi.models.tags.Tag Tag} model + * corresponding to the containing annotation. + * + * @return array of extensions + * + * @since 3.1 + */ + Extension[] extensions() default {}; } diff --git a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/tags/package-info.java b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/tags/package-info.java index e28c46a91..6ab04f0ae 100644 --- a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/tags/package-info.java +++ b/api/src/main/java/org/eclipse/microprofile/openapi/annotations/tags/package-info.java @@ -35,5 +35,5 @@ * */ -@org.osgi.annotation.versioning.Version("1.0") +@org.osgi.annotation.versioning.Version("1.1") package org.eclipse.microprofile.openapi.annotations.tags; \ No newline at end of file diff --git a/tck/src/main/java/org/eclipse/microprofile/openapi/apps/petstore/resource/PetStoreResource.java b/tck/src/main/java/org/eclipse/microprofile/openapi/apps/petstore/resource/PetStoreResource.java index 992d121d3..6a2779ba5 100644 --- a/tck/src/main/java/org/eclipse/microprofile/openapi/apps/petstore/resource/PetStoreResource.java +++ b/tck/src/main/java/org/eclipse/microprofile/openapi/apps/petstore/resource/PetStoreResource.java @@ -22,6 +22,7 @@ import org.eclipse.microprofile.openapi.annotations.media.Schema; import org.eclipse.microprofile.openapi.annotations.parameters.Parameter; import org.eclipse.microprofile.openapi.annotations.responses.APIResponse; +import org.eclipse.microprofile.openapi.annotations.responses.APIResponses; import org.eclipse.microprofile.openapi.annotations.security.SecurityRequirement; import org.eclipse.microprofile.openapi.annotations.security.SecurityRequirements; import org.eclipse.microprofile.openapi.annotations.security.SecurityScheme; @@ -61,8 +62,13 @@ public class PetStoreResource { @GET @Path("/inventory") @Produces({"application/json", "application/xml"}) - @APIResponse(responseCode = "200", description = "successful operation") + @APIResponses(extensions = @Extension(name = "x-responses-ext", value = "test-responses-ext"), value = { + @APIResponse(responseCode = "200", description = "successful operation", extensions = @Extension(name = "x-response-ext", value = "test-response-ext")), + @APIResponse(responseCode = "500", description = "server error", extensions = {}), + @APIResponse(responseCode = "503", description = "service not available", content = @Content(extensions = @Extension(name = "x-notavailable-ext", value = "true"))), + }) @Operation(summary = "Returns pet inventories by status", description = "Returns a map of status codes to quantities") + @Extension(name = "x-operation-ext", value = "test-operation-ext") public java.util.Map getInventory() { return petData.getInventoryByStatus(); } diff --git a/tck/src/main/java/org/eclipse/microprofile/openapi/tck/PetStoreAppTest.java b/tck/src/main/java/org/eclipse/microprofile/openapi/tck/PetStoreAppTest.java index dceeb240e..5c0eecd58 100644 --- a/tck/src/main/java/org/eclipse/microprofile/openapi/tck/PetStoreAppTest.java +++ b/tck/src/main/java/org/eclipse/microprofile/openapi/tck/PetStoreAppTest.java @@ -24,6 +24,7 @@ import static org.hamcrest.Matchers.hasItems; import static org.hamcrest.Matchers.hasKey; import static org.hamcrest.Matchers.hasSize; +import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.Matchers.startsWith; @@ -303,4 +304,26 @@ public void testAPIResponseSchemaDefaultResponseCode(String type) { hasEntry(equalTo("type"), equalTo("object")), hasEntry(equalTo("properties"), notNullValue()))); } + + @RunAsClient + @Test(dataProvider = "formatProvider") + public void testExtensionPlacement(String type) { + ValidatableResponse vr = callEndpoint(type); + + final String X_OPERATION_EXT = "x-operation-ext"; + final String TEST_OPERATION_EXT = "test-operation-ext"; + String opPath = "paths.'/store/inventory'.get"; + + vr.body(opPath, hasEntry(equalTo(X_OPERATION_EXT), equalTo(TEST_OPERATION_EXT))); + + vr.body(opPath + ".responses", hasEntry(equalTo("x-responses-ext"), equalTo("test-responses-ext"))); + vr.body(opPath + ".responses.'200'", not(hasKey(X_OPERATION_EXT))); + vr.body(opPath + ".responses.'200'", hasEntry(equalTo("x-response-ext"), equalTo("test-response-ext"))); + vr.body(opPath + ".responses.'500'", not(hasKey(X_OPERATION_EXT))); + vr.body(opPath + ".responses.'503'", hasEntry(equalTo(X_OPERATION_EXT), equalTo(TEST_OPERATION_EXT))); + vr.body(opPath + ".responses.'503'.content.'application/json'", + hasEntry(equalTo("x-notavailable-ext"), equalTo("true"))); + vr.body(opPath + ".responses.'503'.content.'application/xml'", + hasEntry(equalTo("x-notavailable-ext"), equalTo("true"))); + } }