|
| 1 | +/* |
| 2 | + * Copyright (c) 2024 Contributors to the Eclipse Foundation |
| 3 | + * <p> |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * <p> |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * <p> |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | +package org.eclipse.microprofile.openapi.annotations; |
| 17 | + |
| 18 | +import java.lang.annotation.Retention; |
| 19 | +import java.lang.annotation.RetentionPolicy; |
| 20 | +import java.lang.annotation.Target; |
| 21 | + |
| 22 | +import org.eclipse.microprofile.openapi.annotations.callbacks.Callback; |
| 23 | +import org.eclipse.microprofile.openapi.annotations.extensions.Extension; |
| 24 | +import org.eclipse.microprofile.openapi.annotations.parameters.Parameter; |
| 25 | +import org.eclipse.microprofile.openapi.annotations.parameters.RequestBody; |
| 26 | +import org.eclipse.microprofile.openapi.annotations.responses.APIResponse; |
| 27 | +import org.eclipse.microprofile.openapi.annotations.security.SecurityRequirement; |
| 28 | +import org.eclipse.microprofile.openapi.annotations.security.SecurityRequirementsSet; |
| 29 | +import org.eclipse.microprofile.openapi.annotations.servers.Server; |
| 30 | + |
| 31 | +/** |
| 32 | + * Describes an Operation |
| 33 | + * <p> |
| 34 | + * This annotation is only used for operations defined under a {@link PathItem}. For operations provided by the API |
| 35 | + * itself, it's more common to use the {@link Operation} annotation applied to a Jakarta REST resource method instead. |
| 36 | + * |
| 37 | + * @since 4.0 |
| 38 | + */ |
| 39 | +@Target({}) |
| 40 | +@Retention(RetentionPolicy.RUNTIME) |
| 41 | +public @interface PathItemOperation { |
| 42 | + |
| 43 | + /** |
| 44 | + * The HTTP method for this operation. |
| 45 | + * |
| 46 | + * @return the HTTP method of this operation |
| 47 | + **/ |
| 48 | + String method(); |
| 49 | + |
| 50 | + /** |
| 51 | + * The tag names which apply to this operation. |
| 52 | + * |
| 53 | + * @return the list of tag names |
| 54 | + */ |
| 55 | + String[] tags() default {}; // Could be @Tag[] |
| 56 | + |
| 57 | + /** |
| 58 | + * Provides a brief description of what this operation does. |
| 59 | + * |
| 60 | + * @return a summary of this operation |
| 61 | + **/ |
| 62 | + String summary() default ""; |
| 63 | + |
| 64 | + /** |
| 65 | + * A verbose description of the operation behavior. CommonMark syntax MAY be used for rich text representation. |
| 66 | + * |
| 67 | + * @return a description of this operation |
| 68 | + **/ |
| 69 | + String description() default ""; |
| 70 | + |
| 71 | + /** |
| 72 | + * Additional external documentation for this operation. |
| 73 | + * |
| 74 | + * @return external documentation associated with this operation instance |
| 75 | + **/ |
| 76 | + ExternalDocumentation externalDocs() default @ExternalDocumentation(); |
| 77 | + |
| 78 | + /** |
| 79 | + * Unique string used to identify the operation. The id MUST be unique among all operations described in the API. |
| 80 | + * <p> |
| 81 | + * Tools and libraries MAY use the operationId to uniquely identify an operation, therefore, it is RECOMMENDED to |
| 82 | + * follow common programming naming conventions. |
| 83 | + * </p> |
| 84 | + * |
| 85 | + * @return the ID of this operation |
| 86 | + **/ |
| 87 | + String operationId() default ""; |
| 88 | + |
| 89 | + /** |
| 90 | + * An array of parameters applicable for this operation. |
| 91 | + * <p> |
| 92 | + * The list MUST NOT include duplicated parameters. A unique parameter is defined by a combination of a name and |
| 93 | + * location. |
| 94 | + * </p> |
| 95 | + * |
| 96 | + * @return the list of parameters for this operation |
| 97 | + **/ |
| 98 | + Parameter[] parameters() default {}; |
| 99 | + |
| 100 | + /** |
| 101 | + * The request body for this operation. |
| 102 | + * |
| 103 | + * @return the request body of this operation |
| 104 | + **/ |
| 105 | + RequestBody requestBody() default @RequestBody(); |
| 106 | + |
| 107 | + /** |
| 108 | + * The list of possible responses that can be returned when executing this operation. |
| 109 | + * |
| 110 | + * @return the list of responses for this operation |
| 111 | + **/ |
| 112 | + APIResponse[] responses() default {}; |
| 113 | + |
| 114 | + /** |
| 115 | + * A list of possible out-of-band callbacks related to this operation. Each entry represents a set of requests that |
| 116 | + * may be initiated by the API provided and an expression, evaluated at runtime, that identifies the URL used to |
| 117 | + * make those requests. |
| 118 | + * |
| 119 | + * @return the list of callbacks for this operation |
| 120 | + */ |
| 121 | + Callback[] callbacks() default {}; |
| 122 | + |
| 123 | + /** |
| 124 | + * Allows an operation to be marked as deprecated |
| 125 | + * <p> |
| 126 | + * Consumers SHOULD refrain from usage of a deprecated operation. |
| 127 | + * </p> |
| 128 | + * |
| 129 | + * @return whether or not this operation is deprecated |
| 130 | + **/ |
| 131 | + boolean deprecated() default false; |
| 132 | + |
| 133 | + /** |
| 134 | + * A declaration of which security mechanisms can be used for this callback operation. Only one of the security |
| 135 | + * requirement objects need to be satisfied to authorize a request. |
| 136 | + * <p> |
| 137 | + * Adding a {@code SecurityRequirement} to this array is equivalent to adding a {@code SecurityRequirementsSet} |
| 138 | + * containing a single {@code SecurityRequirement} to {@link #securitySets()}. |
| 139 | + * <p> |
| 140 | + * This definition overrides any declared top-level security. To remove a top-level security declaration, an empty |
| 141 | + * array can be used. |
| 142 | + * |
| 143 | + * @return the list of security mechanisms for this operation |
| 144 | + */ |
| 145 | + SecurityRequirement[] security() default {}; |
| 146 | + |
| 147 | + /** |
| 148 | + * A declaration of which security mechanisms can be used for this callback operation. All of the security |
| 149 | + * requirements within any one of the sets needs needs to be satisfied to authorize a request. |
| 150 | + * <p> |
| 151 | + * This definition overrides any declared top-level security. To remove a top-level security declaration, an empty |
| 152 | + * array can be used. |
| 153 | + * <p> |
| 154 | + * Including an empty set within this list indicates that the other requirements are optional. |
| 155 | + * |
| 156 | + * @return the list of security mechanisms for this operation |
| 157 | + */ |
| 158 | + SecurityRequirementsSet[] securitySets() default {}; |
| 159 | + |
| 160 | + /** |
| 161 | + * A list of servers to be used for this operation, overriding those defined for the parent path item or for the |
| 162 | + * whole API. |
| 163 | + * |
| 164 | + * @return the list of servers |
| 165 | + */ |
| 166 | + Server[] servers() default {}; |
| 167 | + |
| 168 | + /** |
| 169 | + * List of extensions to be added to the {@link org.eclipse.microprofile.openapi.models.Operation Operation} model |
| 170 | + * corresponding to the containing annotation. |
| 171 | + * |
| 172 | + * @return array of extensions |
| 173 | + */ |
| 174 | + Extension[] extensions() default {}; |
| 175 | +} |
0 commit comments