1 package io.swagger.v3.oas.models.security;
2
3 import io.swagger.v3.oas.models.annotations.OpenAPI31;
4
5 /**
6  * SecurityScheme
7  *
8  * @see "https://github.com/OAI/OpenAPI-Specification/blob/3.0.1/versions/3.0.1.md#securitySchemeObject"
9  * @see "https://github.com/OAI/OpenAPI-Specification/blob/3.1.0/versions/3.1.0.md#securitySchemeObject"
10  */

11
12 public class SecurityScheme {
13     /**
14      * Gets or Sets type
15      */

16     public enum Type {
17         APIKEY("apiKey"),
18         HTTP("http"),
19         OAUTH2("oauth2"),
20         OPENIDCONNECT("openIdConnect"),
21         MUTUALTLS("mutualTLS");
22
23         private String value;
24
25         Type(String value) {
26             this.value = value;
27         }
28
29         @Override
30         public String toString() {
31             return String.valueOf(value);
32         }
33     }
34
35     private Type type = null;
36     private String description = null;
37     private String name = null;
38     private String $ref = null;
39
40     /**
41      * Gets or Sets in
42      */

43     public enum In {
44         COOKIE("cookie"),
45
46         HEADER("header"),
47
48         QUERY("query");
49
50         private String value;
51
52         In(String value) {
53             this.value = value;
54         }
55
56         @Override
57         public String toString() {
58             return String.valueOf(value);
59         }
60     }
61
62     private In in = null;
63     private String scheme = null;
64     private String bearerFormat = null;
65     private OAuthFlows flows = null;
66     private String openIdConnectUrl = null;
67     private java.util.Map<String, Object> extensions = null;
68
69     /**
70      * returns the type property from a SecurityScheme instance.
71      *
72      * @return Type type
73      **/

74
75     public Type getType() {
76         return type;
77     }
78
79     public void setType(Type type) {
80         this.type = type;
81     }
82
83     public SecurityScheme type(Type type) {
84         this.type = type;
85         return this;
86     }
87
88     /**
89      * returns the description property from a SecurityScheme instance.
90      *
91      * @return String description
92      **/

93
94     public String getDescription() {
95         return description;
96     }
97
98     public void setDescription(String description) {
99         this.description = description;
100     }
101
102     public SecurityScheme description(String description) {
103         this.description = description;
104         return this;
105     }
106
107     /**
108      * returns the name property from a SecurityScheme instance.
109      *
110      * @return String name
111      **/

112
113     public String getName() {
114         return name;
115     }
116
117     public void setName(String name) {
118         this.name = name;
119     }
120
121     public SecurityScheme name(String name) {
122         this.name = name;
123         return this;
124     }
125
126     /**
127      * returns the in property from a SecurityScheme instance.
128      *
129      * @return In in
130      **/

131
132     public In getIn() {
133         return in;
134     }
135
136     public void setIn(In in) {
137         this.in = in;
138     }
139
140     public SecurityScheme in(In in) {
141         this.in = in;
142         return this;
143     }
144
145     /**
146      * returns the scheme property from a SecurityScheme instance.
147      *
148      * @return String scheme
149      **/

150
151     public String getScheme() {
152         return scheme;
153     }
154
155     public void setScheme(String scheme) {
156         this.scheme = scheme;
157     }
158
159     public SecurityScheme scheme(String scheme) {
160         this.scheme = scheme;
161         return this;
162     }
163
164     /**
165      * returns the bearerFormat property from a SecurityScheme instance.
166      *
167      * @return String bearerFormat
168      **/

169
170     public String getBearerFormat() {
171         return bearerFormat;
172     }
173
174     public void setBearerFormat(String bearerFormat) {
175         this.bearerFormat = bearerFormat;
176     }
177
178     public SecurityScheme bearerFormat(String bearerFormat) {
179         this.bearerFormat = bearerFormat;
180         return this;
181     }
182
183     /**
184      * returns the flows property from a SecurityScheme instance.
185      *
186      * @return OAuthFlows flows
187      **/

188
189     public OAuthFlows getFlows() {
190         return flows;
191     }
192
193     public void setFlows(OAuthFlows flows) {
194         this.flows = flows;
195     }
196
197     public SecurityScheme flows(OAuthFlows flows) {
198         this.flows = flows;
199         return this;
200     }
201
202     /**
203      * returns the openIdConnectUrl property from a SecurityScheme instance.
204      *
205      * @return String openIdConnectUrl
206      **/

207
208     public String getOpenIdConnectUrl() {
209         return openIdConnectUrl;
210     }
211
212     public void setOpenIdConnectUrl(String openIdConnectUrl) {
213         this.openIdConnectUrl = openIdConnectUrl;
214     }
215
216     public SecurityScheme openIdConnectUrl(String openIdConnectUrl) {
217         this.openIdConnectUrl = openIdConnectUrl;
218         return this;
219     }
220
221     public java.util.Map<String, Object> getExtensions() {
222         return extensions;
223     }
224
225     @OpenAPI31
226     public void addExtension31(String name, Object value) {
227         if (name != null && (name.startsWith("x-oas-") || name.startsWith("x-oai-"))) {
228             return;
229         }
230         addExtension(name, value);
231     }
232
233     public void addExtension(String name, Object value) {
234         if (name == null || name.isEmpty() || !name.startsWith("x-")) {
235             return;
236         }
237         if (this.extensions == null) {
238             this.extensions = new java.util.LinkedHashMap<>();
239         }
240         this.extensions.put(name, value);
241     }
242
243     public void setExtensions(java.util.Map<String, Object> extensions) {
244         this.extensions = extensions;
245     }
246
247     public SecurityScheme extensions(java.util.Map<String, Object> extensions) {
248         this.extensions = extensions;
249         return this;
250     }
251
252     /**
253      * returns the $ref property from an SecurityScheme instance.
254      *
255      * @return String $ref
256      **/

257     public String get$ref() {
258         return $ref;
259     }
260
261     public void set$ref(String $ref) {
262         if ($ref != null && ($ref.indexOf('.') == -1 && $ref.indexOf('/') == -1)) {
263             $ref = "#/components/securitySchemes/" + $ref;
264         }
265         this.$ref = $ref;
266     }
267
268     public SecurityScheme $ref(String $ref) {
269         set$ref($ref);
270         return this;
271     }
272
273     @Override
274     public boolean equals(Object o) {
275         if (this == o) {
276             return true;
277         }
278         if (!(o instanceof SecurityScheme)) {
279             return false;
280         }
281
282         SecurityScheme that = (SecurityScheme) o;
283
284         if (type != that.type) {
285             return false;
286         }
287         if (description != null ? !description.equals(that.description) : that.description != null) {
288             return false;
289         }
290         if (name != null ? !name.equals(that.name) : that.name != null) {
291             return false;
292         }
293         if ($ref != null ? !$ref.equals(that.$ref) : that.$ref != null) {
294             return false;
295         }
296         if (in != that.in) {
297             return false;
298         }
299         if (scheme != null ? !scheme.equals(that.scheme) : that.scheme != null) {
300             return false;
301         }
302         if (bearerFormat != null ? !bearerFormat.equals(that.bearerFormat) : that.bearerFormat != null) {
303             return false;
304         }
305         if (flows != null ? !flows.equals(that.flows) : that.flows != null) {
306             return false;
307         }
308         if (openIdConnectUrl != null ? !openIdConnectUrl.equals(that.openIdConnectUrl) : that.openIdConnectUrl != null) {
309             return false;
310         }
311         return extensions != null ? extensions.equals(that.extensions) : that.extensions == null;
312     }
313
314     @Override
315     public int hashCode() {
316         int result = type != null ? type.hashCode() : 0;
317         result = 31 * result + (description != null ? description.hashCode() : 0);
318         result = 31 * result + (name != null ? name.hashCode() : 0);
319         result = 31 * result + ($ref != null ? $ref.hashCode() : 0);
320         result = 31 * result + (in != null ? in.hashCode() : 0);
321         result = 31 * result + (scheme != null ? scheme.hashCode() : 0);
322         result = 31 * result + (bearerFormat != null ? bearerFormat.hashCode() : 0);
323         result = 31 * result + (flows != null ? flows.hashCode() : 0);
324         result = 31 * result + (openIdConnectUrl != null ? openIdConnectUrl.hashCode() : 0);
325         result = 31 * result + (extensions != null ? extensions.hashCode() : 0);
326         return result;
327     }
328
329     @Override
330     public String toString() {
331         StringBuilder sb = new StringBuilder();
332         sb.append("class SecurityScheme {\n");
333
334         sb.append("    type: ").append(toIndentedString(type)).append("\n");
335         sb.append("    description: ").append(toIndentedString(description)).append("\n");
336         sb.append("    name: ").append(toIndentedString(name)).append("\n");
337         sb.append("    in: ").append(toIndentedString(in)).append("\n");
338         sb.append("    scheme: ").append(toIndentedString(scheme)).append("\n");
339         sb.append("    bearerFormat: ").append(toIndentedString(bearerFormat)).append("\n");
340         sb.append("    flows: ").append(toIndentedString(flows)).append("\n");
341         sb.append("    openIdConnectUrl: ").append(toIndentedString(openIdConnectUrl)).append("\n");
342         sb.append("    $ref: ").append(toIndentedString($ref)).append("\n");
343         sb.append("}");
344         return sb.toString();
345     }
346
347     /**
348      * Convert the given object to string with each line indented by 4 spaces
349      * (except the first line).
350      */

351     private String toIndentedString(java.lang.Object o) {
352         if (o == null) {
353             return "null";
354         }
355         return o.toString().replace("\n""\n    ");
356     }
357
358 }
359
360