1 package io.swagger.v3.oas.models;
2
3 import io.swagger.v3.oas.models.annotations.OpenAPI31;
4 import io.swagger.v3.oas.models.callbacks.Callback;
5 import io.swagger.v3.oas.models.examples.Example;
6 import io.swagger.v3.oas.models.headers.Header;
7 import io.swagger.v3.oas.models.links.Link;
8 import io.swagger.v3.oas.models.media.Schema;
9 import io.swagger.v3.oas.models.parameters.Parameter;
10 import io.swagger.v3.oas.models.parameters.RequestBody;
11 import io.swagger.v3.oas.models.responses.ApiResponse;
12 import io.swagger.v3.oas.models.security.SecurityScheme;
13
14 import java.util.LinkedHashMap;
15 import java.util.Map;
16 import java.util.Objects;
17
18
24
25 public class Components {
26
27
30 public static final String COMPONENTS_SCHEMAS_REF = "#/components/schemas/";
31 private Map<String, Schema> schemas = null;
32 private Map<String, ApiResponse> responses = null;
33 private Map<String, Parameter> parameters = null;
34 private Map<String, Example> examples = null;
35 private Map<String, RequestBody> requestBodies = null;
36 private Map<String, Header> headers = null;
37 private Map<String, SecurityScheme> securitySchemes = null;
38 private Map<String, Link> links = null;
39 private Map<String, Callback> callbacks = null;
40 private java.util.Map<String, Object> extensions = null;
41
42
45 @OpenAPI31
46 private Map<String, PathItem> pathItems;
47
48
53
54 public Map<String, Schema> getSchemas() {
55 return schemas;
56 }
57
58 public void setSchemas(Map<String, Schema> schemas) {
59 this.schemas = schemas;
60 }
61
62 public Components schemas(Map<String, Schema> schemas) {
63 this.schemas = schemas;
64 return this;
65 }
66
67 public Components addSchemas(String key, Schema schemasItem) {
68 if (this.schemas == null) {
69 this.schemas = new LinkedHashMap<>();
70 }
71 this.schemas.put(key, schemasItem);
72 return this;
73 }
74
75
80
81 public Map<String, ApiResponse> getResponses() {
82 return responses;
83 }
84
85 public void setResponses(Map<String, ApiResponse> responses) {
86 this.responses = responses;
87 }
88
89 public Components responses(Map<String, ApiResponse> responses) {
90 this.responses = responses;
91 return this;
92 }
93
94 public Components addResponses(String key, ApiResponse responsesItem) {
95 if (this.responses == null) {
96 this.responses = new LinkedHashMap<>();
97 }
98 this.responses.put(key, responsesItem);
99 return this;
100 }
101
102
107
108 public Map<String, Parameter> getParameters() {
109 return parameters;
110 }
111
112 public void setParameters(Map<String, Parameter> parameters) {
113 this.parameters = parameters;
114 }
115
116 public Components parameters(Map<String, Parameter> parameters) {
117 this.parameters = parameters;
118 return this;
119 }
120
121 public Components addParameters(String key, Parameter parametersItem) {
122 if (this.parameters == null) {
123 this.parameters = new LinkedHashMap<>();
124 }
125 this.parameters.put(key, parametersItem);
126 return this;
127 }
128
129
134
135 public Map<String, Example> getExamples() {
136 return examples;
137 }
138
139 public void setExamples(Map<String, Example> examples) {
140 this.examples = examples;
141 }
142
143 public Components examples(Map<String, Example> examples) {
144 this.examples = examples;
145 return this;
146 }
147
148 public Components addExamples(String key, Example examplesItem) {
149 if (this.examples == null) {
150 this.examples = new LinkedHashMap<>();
151 }
152 this.examples.put(key, examplesItem);
153 return this;
154 }
155
156
161
162 public Map<String, RequestBody> getRequestBodies() {
163 return requestBodies;
164 }
165
166 public void setRequestBodies(Map<String, RequestBody> requestBodies) {
167 this.requestBodies = requestBodies;
168 }
169
170 public Components requestBodies(Map<String, RequestBody> requestBodies) {
171 this.requestBodies = requestBodies;
172 return this;
173 }
174
175 public Components addRequestBodies(String key, RequestBody requestBodiesItem) {
176 if (this.requestBodies == null) {
177 this.requestBodies = new LinkedHashMap<>();
178 }
179 this.requestBodies.put(key, requestBodiesItem);
180 return this;
181 }
182
183
188
189 public Map<String, Header> getHeaders() {
190 return headers;
191 }
192
193 public void setHeaders(Map<String, Header> headers) {
194 this.headers = headers;
195 }
196
197 public Components headers(Map<String, Header> headers) {
198 this.headers = headers;
199 return this;
200 }
201
202 public Components addHeaders(String key, Header headersItem) {
203 if (this.headers == null) {
204 this.headers = new LinkedHashMap<>();
205 }
206 this.headers.put(key, headersItem);
207 return this;
208 }
209
210
215
216 public Map<String, SecurityScheme> getSecuritySchemes() {
217 return securitySchemes;
218 }
219
220 public void setSecuritySchemes(Map<String, SecurityScheme> securitySchemes) {
221 this.securitySchemes = securitySchemes;
222 }
223
224 public Components securitySchemes(Map<String, SecurityScheme> securitySchemes) {
225 this.securitySchemes = securitySchemes;
226 return this;
227 }
228
229 public Components addSecuritySchemes(String key, SecurityScheme securitySchemesItem) {
230 if (this.securitySchemes == null) {
231 this.securitySchemes = new LinkedHashMap<>();
232 }
233 this.securitySchemes.put(key, securitySchemesItem);
234 return this;
235 }
236
237
242
243 public Map<String, Link> getLinks() {
244 return links;
245 }
246
247 public void setLinks(Map<String, Link> links) {
248 this.links = links;
249 }
250
251 public Components links(Map<String, Link> links) {
252 this.links = links;
253 return this;
254 }
255
256 public Components addLinks(String key, Link linksItem) {
257 if (this.links == null) {
258 this.links = new LinkedHashMap<>();
259 }
260 this.links.put(key, linksItem);
261 return this;
262 }
263
264
269
270 public Map<String, Callback> getCallbacks() {
271 return callbacks;
272 }
273
274 public void setCallbacks(Map<String, Callback> callbacks) {
275 this.callbacks = callbacks;
276 }
277
278 public Components callbacks(Map<String, Callback> callbacks) {
279 this.callbacks = callbacks;
280 return this;
281 }
282
283 public Components addCallbacks(String key, Callback callbacksItem) {
284 if (this.callbacks == null) {
285 this.callbacks = new LinkedHashMap<>();
286 }
287 this.callbacks.put(key, callbacksItem);
288 return this;
289 }
290
291
297 @OpenAPI31
298 public Map<String, PathItem> getPathItems() {
299 return pathItems;
300 }
301
302 @OpenAPI31
303 public void setPathItems(Map<String, PathItem> pathItems) {
304 this.pathItems = pathItems;
305 }
306
307 @OpenAPI31
308 public Components pathItems(Map<String, PathItem> pathItems) {
309 this.pathItems = pathItems;
310 return this;
311 }
312
313 @OpenAPI31
314 public Components addPathItem(String key, PathItem pathItem) {
315 if (this.pathItems == null) {
316 this.pathItems = new LinkedHashMap<>();
317 }
318 this.pathItems.put(key, pathItem);
319 return this;
320 }
321
322 @Override
323 public boolean equals(java.lang.Object o) {
324 if (this == o) {
325 return true;
326 }
327 if (o == null || getClass() != o.getClass()) {
328 return false;
329 }
330 Components components = (Components) o;
331 return Objects.equals(this.schemas, components.schemas) &&
332 Objects.equals(this.responses, components.responses) &&
333 Objects.equals(this.parameters, components.parameters) &&
334 Objects.equals(this.examples, components.examples) &&
335 Objects.equals(this.requestBodies, components.requestBodies) &&
336 Objects.equals(this.headers, components.headers) &&
337 Objects.equals(this.securitySchemes, components.securitySchemes) &&
338 Objects.equals(this.links, components.links) &&
339 Objects.equals(this.callbacks, components.callbacks) &&
340 Objects.equals(this.extensions, components.extensions) &&
341 Objects.equals(this.pathItems, components.pathItems);
342 }
343
344 @Override
345 public int hashCode() {
346 return Objects.hash(schemas, responses, parameters, examples, requestBodies, headers, securitySchemes, links, callbacks, extensions, pathItems);
347 }
348
349 public java.util.Map<String, Object> getExtensions() {
350 return extensions;
351 }
352
353 public void addExtension(String name, Object value) {
354 if (name == null || name.isEmpty() || !name.startsWith("x-")) {
355 return;
356 }
357 if (this.extensions == null) {
358 this.extensions = new java.util.LinkedHashMap<>();
359 }
360 this.extensions.put(name, value);
361 }
362
363 @OpenAPI31
364 public void addExtension31(String name, Object value) {
365 if (name != null && (name.startsWith("x-oas-") || name.startsWith("x-oai-"))) {
366 return;
367 }
368 addExtension(name, value);
369 }
370
371 public void setExtensions(java.util.Map<String, Object> extensions) {
372 this.extensions = extensions;
373 }
374
375 public Components extensions(java.util.Map<String, Object> extensions) {
376 this.extensions = extensions;
377 return this;
378 }
379
380 @Override
381 public String toString() {
382 StringBuilder sb = new StringBuilder();
383 sb.append("class Components {\n");
384
385 sb.append(" schemas: ").append(toIndentedString(schemas)).append("\n");
386 sb.append(" responses: ").append(toIndentedString(responses)).append("\n");
387 sb.append(" parameters: ").append(toIndentedString(parameters)).append("\n");
388 sb.append(" examples: ").append(toIndentedString(examples)).append("\n");
389 sb.append(" requestBodies: ").append(toIndentedString(requestBodies)).append("\n");
390 sb.append(" headers: ").append(toIndentedString(headers)).append("\n");
391 sb.append(" securitySchemes: ").append(toIndentedString(securitySchemes)).append("\n");
392 sb.append(" links: ").append(toIndentedString(links)).append("\n");
393 sb.append(" callbacks: ").append(toIndentedString(callbacks)).append("\n");
394 sb.append(" pathItems: ").append(toIndentedString(pathItems)).append("\n");
395 sb.append("}");
396 return sb.toString();
397 }
398
399
403 private String toIndentedString(java.lang.Object o) {
404 if (o == null) {
405 return "null";
406 }
407 return o.toString().replace("\n", "\n ");
408 }
409
410 }
411
412