Skip to content

Commit e978295

Browse files
authored
Merge pull request swagger-api#2541 from swagger-api/javadocs
improved annotations javadocs
2 parents c56e8ad + d7fc8fd commit e978295

31 files changed

+218
-30
lines changed

modules/swagger-annotations/src/main/java/io/swagger/v3/oas/annotations/ExternalDocumentation.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,14 @@
2323
import java.lang.annotation.Target;
2424

2525
/**
26-
* Allows referencing an external resource for extended documentation.
26+
* The annotation may be used at method level or as field of {@link Operation} to add a reference to an external
27+
* resource for extended documentation of an <a target="_new" href="https://github.com/OAI/OpenAPI-Specification/blob/OpenAPI.next/versions/3.0.0.md#operationObject">Operation (OpenAPI specification)</a>.
28+
* <p>It may also be used to add external documentation to {@link io.swagger.v3.oas.annotations.tags.Tag},
29+
* {@link io.swagger.v3.oas.annotations.headers.Header} or {@link io.swagger.v3.oas.annotations.media.Schema},
30+
* or as field of {@link OpenAPIDefinition}.</p>
31+
*
32+
* @see <a target="_new" href="https://github.com/OAI/OpenAPI-Specification/blob/OpenAPI.next/versions/3.0.0.md#externalDocumentationObject">External Documentation (OpenAPI specification)</a>
33+
* @see OpenAPIDefinition
2734
**/
2835
@Target({ElementType.METHOD, ElementType.TYPE})
2936
@Retention(RetentionPolicy.RUNTIME)

modules/swagger-annotations/src/main/java/io/swagger/v3/oas/annotations/OpenAPIDefinition.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@
2727
import java.lang.annotation.RetentionPolicy;
2828
import java.lang.annotation.Target;
2929

30+
/**
31+
* The annotation that may be used to populate OpenAPI Object fields info, tags, servers, security and externalDocs
32+
* If more than one class is annotated with {@link OpenAPIDefinition}, with the same fields defined, behaviour is inconsistent.
33+
*
34+
* @see <a target="_new" href="https://github.com/OAI/OpenAPI-Specification/blob/OpenAPI.next/versions/3.0.0.md#oasObject">OpenAPI (OpenAPI specification)</a>
35+
*/
3036
@Target({ElementType.TYPE, ElementType.PACKAGE})
3137
@Retention(RetentionPolicy.RUNTIME)
3238
@Inherited

modules/swagger-annotations/src/main/java/io/swagger/v3/oas/annotations/Operation.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,30 @@
2828
import java.lang.annotation.Target;
2929

3030
/**
31-
* Describes a single API operation on a path.
31+
* The annotation may be used to define a resource method as an OpenAPI Operation, and/or to define additional
32+
* properties for the Operation.
33+
*
34+
* <p>Note: swagger-jaxrs2 reader engine includes by default also methods of scanned resources which are not annotated
35+
* with @Operation, as long as a jax-rs @Path is defined at class and/or method level, together with the http method
36+
* annotation (@GET, @POST, etc).</p>
37+
* <p>This behaviour is controlled by configuration property `scanAllResources` which defaults to true. By setting this
38+
* flag to false only @{@link Operation} annotated methods are considered.</p>
39+
*
40+
* <p>The following fields can also alternatively be defined at method level (as repeatable annotations in case of arrays),
41+
* in this case method level annotations take precedence over @{@link Operation} annotation fields:</p>
42+
*
43+
* <ul>
44+
* <li>tags: @{@link io.swagger.v3.oas.annotations.tags.Tag}</li>
45+
* <li>externalDocs: @{@link ExternalDocumentation}</li>
46+
* <li>parameters: @{@link Parameter}</li>
47+
* <li>responses: @{@link ApiResponse}</li>
48+
* <li>security: @{@link SecurityRequirement}</li>
49+
* <li>servers: @{@link Server}</li>
50+
* <li>extensions: @{@link Extension}</li>
51+
* <li>hidden: @{@link Hidden}</li>
52+
* </ul>
53+
*
54+
* @see <a target="_new" href="https://github.com/OAI/OpenAPI-Specification/blob/OpenAPI.next/versions/3.0.0.md#operationObject">Operation (OpenAPI specification)</a>
3255
**/
3356
@Target({ElementType.METHOD})
3457
@Retention(RetentionPolicy.RUNTIME)

modules/swagger-annotations/src/main/java/io/swagger/v3/oas/annotations/Parameter.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,19 @@
3232
import java.lang.annotation.Target;
3333

3434
/**
35-
* Describes a single operation parameter
35+
* The annotation may be used on a method parameter to define it as a parameter for the operation, and/or to define
36+
* additional properties for the Parameter. It can also be used independently in {@link Operation#parameters()} or at
37+
* method level to add a parameter to the operation, even if not bound to any method parameter.
38+
*
39+
* <p>swagger-jaxrs2 reader engine considers this annotation along with JAX-RS annotations, parameter type and context
40+
* as input to resolve a method parameter into an OpenAPI Operation parameter.</p>
41+
*
42+
* <p>For method parameters bound to the request body, see {@link io.swagger.v3.oas.annotations.parameters.RequestBody}</p>
43+
*
44+
* @see <a target="_new" href="https://github.com/OAI/OpenAPI-Specification/blob/OpenAPI.next/versions/3.0.0.md#parameterObject">Parameter (OpenAPI specification)</a>
45+
* @see io.swagger.v3.oas.annotations.parameters.RequestBody
46+
* @see Operation
47+
* @see Schema
3648
**/
3749
@Target({ElementType.PARAMETER,
3850
ElementType.METHOD,

modules/swagger-annotations/src/main/java/io/swagger/v3/oas/annotations/Parameters.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@
2121
import java.lang.annotation.RetentionPolicy;
2222
import java.lang.annotation.Target;
2323

24+
/**
25+
* Container for repeatable {@link Parameter} annotation
26+
*
27+
* @see Parameter
28+
*/
2429
@Target({ElementType.METHOD})
2530
@Retention(RetentionPolicy.RUNTIME)
2631
@Inherited

modules/swagger-annotations/src/main/java/io/swagger/v3/oas/annotations/callbacks/Callback.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
import java.lang.annotation.Target;
2727

2828
/**
29-
* This object represents a callback URL that will be invoked.
29+
* The annotation may be used at method level to add one ore more callbacks to the operation definition.
30+
*
31+
* @see <a target="_new" href="https://github.com/OAI/OpenAPI-Specification/blob/OpenAPI.next/versions/3.0.0.md#callbackObject">Callback (OpenAPI specification)</a>
3032
**/
3133
@Target({ElementType.FIELD,
3234
ElementType.METHOD,

modules/swagger-annotations/src/main/java/io/swagger/v3/oas/annotations/callbacks/Callbacks.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@
2323
import java.lang.annotation.Target;
2424

2525
/**
26-
* This object represents an array of Callback URLs that can be invoked.
27-
**/
26+
* Container for repeatable {@link Callback} annotation
27+
*
28+
* @see Callback
29+
*/
2830
@Target({ElementType.METHOD})
2931
@Retention(RetentionPolicy.RUNTIME)
3032
@Inherited

modules/swagger-annotations/src/main/java/io/swagger/v3/oas/annotations/extensions/Extension.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
/**
1010
* An optionally named list of extension properties.
11+
*
12+
* @see <a target="_new" href="https://github.com/OAI/OpenAPI-Specification/blob/OpenAPI.next/versions/3.0.0.md#specificationExtensions">Specification extensions (OpenAPI specification)</a>
1113
*/
1214
@Target({ElementType.FIELD,
1315
ElementType.METHOD,

modules/swagger-annotations/src/main/java/io/swagger/v3/oas/annotations/extensions/Extensions.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@
2323
import java.lang.annotation.Target;
2424

2525
/**
26-
* This object represents an array of extensions that can be added to the element.
27-
**/
26+
* Container for repeatable {@link Extension} annotation
27+
*
28+
* @see Extension
29+
*/
2830
@Target({ElementType.FIELD,
2931
ElementType.METHOD,
3032
ElementType.PARAMETER,

modules/swagger-annotations/src/main/java/io/swagger/v3/oas/annotations/headers/Header.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,14 @@
2424
import java.lang.annotation.Target;
2525

2626
/**
27-
* Describes a single header object
27+
* The annotation may be used to add one or more headers to the definition of a response or as attribute of content
28+
* encoding by definining it as field {@link io.swagger.v3.oas.annotations.responses.ApiResponse#headers()} or {@link io.swagger.v3.oas.annotations.media.Content#encoding()}.
29+
* <p>Please note that request headers are defined as Header {@link io.swagger.v3.oas.annotations.Parameter}.</p>
30+
*
31+
* @see <a target="_new" href="https://github.com/OAI/OpenAPI-Specification/blob/OpenAPI.next/versions/3.0.0.md#headerObject">Header (OpenAPI specification)</a>
32+
* @see io.swagger.v3.oas.annotations.responses.ApiResponse
33+
* @see io.swagger.v3.oas.annotations.Parameter
34+
* @see io.swagger.v3.oas.annotations.media.Encoding
2835
**/
2936
@Target({})
3037
@Retention(RetentionPolicy.RUNTIME)

0 commit comments

Comments
 (0)