e1e16c254f28d47708e7ab03016f1faed42e77a9
[aai/aai-common.git] / aai-core / src / main / java / org / onap / aai / util / swagger / Api.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *    http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  *
20  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
21  */
22 package org.onap.aai.util.swagger;
23
24 import java.util.List;
25 import java.util.Map;
26
27 public class Api {
28
29     private String path;
30
31     private List<HttpVerb> httpMethods;
32
33     private String tag;
34
35     public List<HttpVerb> getHttpMethods() {
36         return httpMethods;
37     }
38
39     public void setHttpMethods(List<HttpVerb> httpMethods) {
40         this.httpMethods = httpMethods;
41     }
42
43     public String getTag(){
44
45         if(this.tag != null){
46             return this.tag;
47         }
48
49         if(this.httpMethods != null){
50             if(this.httpMethods.size() != 0){
51                 if(this.httpMethods.get(0).getTags() != null){
52                     if(this.httpMethods.get(0).getTags().size() != 0){
53                         this.tag = this.httpMethods.get(0).getTags().get(0);
54                     }
55                 }
56             }
57         }
58
59         if(this.tag == null){
60             this.tag = "";
61         }
62
63         return this.tag;
64     }
65
66     @Override
67     public String toString() {
68         return "Api{" +
69                 "path='" + path + '\'' +
70                 ", httpMethods=" + httpMethods +
71                 '}';
72     }
73
74     public void setPath(String path) {
75         this.path = path;
76     }
77
78     public String getPath() {
79         return this.path;
80     }
81
82     public String getOperation(){
83
84         if(this.path != null){
85             return this.path.replaceAll("[^a-zA-Z0-9\\-]", "-") + "-";
86         }
87
88         return "";
89     }
90
91     public static class HttpVerb {
92
93         private List<String> tags;
94
95         private String type;
96
97         private String summary;
98
99         private String operationId;
100
101         private List<String> consumes;
102
103         private boolean consumerEnabled;
104
105         private List<String> produces;
106
107         private List<Response> responses;
108
109         private List<Map<String, Object>> parameters;
110
111         private Map<String, Object> bodyParameters;
112
113         private boolean bodyParametersEnabled;
114
115         private boolean parametersEnabled;
116
117         private String schemaLink;
118
119         private String schemaType;
120
121         private boolean hasReturnSchema;
122
123         private String returnSchemaLink;
124
125         private String returnSchemaObject;
126
127         public void setConsumerEnabled(boolean consumerEnabled){
128             this.consumerEnabled = consumerEnabled;
129         }
130
131         public boolean isConsumerEnabled() {
132             return consumerEnabled;
133         }
134
135
136         public List<String> getTags() {
137             return tags;
138         }
139
140         public void setTags(List<String> tags) {
141             this.tags = tags;
142         }
143
144         public String getType() {
145             return type;
146         }
147
148         public void setType(String type) {
149             this.type = type;
150         }
151
152         public String getSummary() {
153             return summary;
154         }
155
156         public void setSummary(String summary) {
157             this.summary = summary;
158         }
159
160         public String getOperationId() {
161             return operationId;
162         }
163
164         public void setOperationId(String operationId) {
165             this.operationId = operationId;
166         }
167
168         public List<String> getConsumes() {
169             return consumes;
170         }
171
172         public void setConsumes(List<String> consumes) {
173             this.consumes = consumes;
174         }
175
176         public List<String> getProduces() {
177             return produces;
178         }
179
180         public void setProduces(List<String> produces) {
181             this.produces = produces;
182         }
183
184         public List<Response> getResponses() {
185             return responses;
186         }
187
188         public void setResponses(List<Response> responses) {
189             this.responses = responses;
190         }
191
192         public List<Map<String, Object>> getParameters() {
193             return parameters;
194         }
195
196         public void setParameters(List<Map<String, Object>> parameters) {
197             this.parameters = parameters;
198         }
199
200         @Override
201         public String toString() {
202             return "HttpVerb{" +
203                     "tags=" + tags +
204                     ", type='" + type + '\'' +
205                     ", summary='" + summary + '\'' +
206                     ", operationId='" + operationId + '\'' +
207                     ", consumes=" + consumes +
208                     ", produces=" + produces +
209                     ", responses=" + responses +
210                     ", parameters=" + parameters +
211                     '}';
212         }
213
214         public void setParametersEnabled(boolean b) {
215             this.parametersEnabled = b;
216         }
217
218         public boolean isParametersEnabled() {
219             return parametersEnabled;
220         }
221
222         public boolean isBodyParametersEnabled() {
223             return bodyParametersEnabled;
224         }
225
226         public void setBodyParametersEnabled(boolean bodyParametersEnabled) {
227             this.bodyParametersEnabled = bodyParametersEnabled;
228         }
229
230         public Map<String, Object> getBodyParameters() {
231             return bodyParameters;
232         }
233
234         public void setBodyParameters(Map<String, Object> bodyParameters) {
235             this.bodyParameters = bodyParameters;
236         }
237
238         public String getSchemaLink() {
239             return schemaLink;
240         }
241
242         public void setSchemaLink(String schemaLink) {
243             this.schemaLink = schemaLink;
244         }
245
246         public String getSchemaType() {
247             return schemaType;
248         }
249
250         public void setSchemaType(String schemaType) {
251             this.schemaType = schemaType;
252         }
253
254         public boolean isHasReturnSchema() {
255             return hasReturnSchema;
256         }
257
258         public void setHasReturnSchema(boolean hasReturnSchema) {
259             this.hasReturnSchema = hasReturnSchema;
260         }
261
262         public String getReturnSchemaLink() {
263             return returnSchemaLink;
264         }
265
266         public void setReturnSchemaLink(String returnSchemaLink) {
267             this.returnSchemaLink = returnSchemaLink;
268         }
269
270         public String getReturnSchemaObject() {
271             return returnSchemaObject;
272         }
273
274         public void setReturnSchemaObject(String returnSchemaObject) {
275             this.returnSchemaObject = returnSchemaObject;
276         }
277
278         public static class Response {
279
280             private String responseCode;
281
282             private String description;
283
284             public String getResponseCode() {
285                 return responseCode;
286             }
287
288             public void setResponseCode(String responseCode) {
289                 this.responseCode = responseCode;
290             }
291
292             public String getDescription() {
293                 return description;
294             }
295
296             public void setDescription(String description) {
297                 this.description = description;
298             }
299
300             @Override
301             public String toString() {
302                 return "Response{" +
303                         "responseCode='" + responseCode + '\'' +
304                         ", description='" + description + '\'' +
305                         '}';
306             }
307         }
308
309     }
310
311 }