Integrate aai-schema-ingest library into aai-core
[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-2018 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 package org.onap.aai.util.swagger;
21
22 import java.util.List;
23 import java.util.Map;
24
25 public class Api {
26
27     private String path;
28
29     private List<HttpVerb> httpMethods;
30
31     private String tag;
32
33     public List<HttpVerb> getHttpMethods() {
34         return httpMethods;
35     }
36
37     public void setHttpMethods(List<HttpVerb> httpMethods) {
38         this.httpMethods = httpMethods;
39     }
40
41     public String getTag(){
42
43         if(this.tag != null){
44             return this.tag;
45         }
46
47         if(this.httpMethods != null){
48             if(this.httpMethods.size() != 0){
49                 if(this.httpMethods.get(0).getTags() != null){
50                     if(this.httpMethods.get(0).getTags().size() != 0){
51                         this.tag = this.httpMethods.get(0).getTags().get(0);
52                     }
53                 }
54             }
55         }
56
57         if(this.tag == null){
58             this.tag = "";
59         }
60
61         return this.tag;
62     }
63
64     @Override
65     public String toString() {
66         return "Api{" +
67                 "path='" + path + '\'' +
68                 ", httpMethods=" + httpMethods +
69                 '}';
70     }
71
72     public void setPath(String path) {
73         this.path = path;
74     }
75
76     public String getPath() {
77         return this.path;
78     }
79
80     public String getOperation(){
81
82         if(this.path != null){
83             return this.path.replaceAll("[^a-zA-Z0-9\\-]", "-") + "-";
84         }
85
86         return "";
87     }
88
89     public static class HttpVerb {
90
91         private List<String> tags;
92
93         private String type;
94
95         private String summary;
96
97         private String operationId;
98
99         private List<String> consumes;
100
101         private boolean consumerEnabled;
102
103         private List<String> produces;
104
105         private List<Response> responses;
106
107         private List<Map<String, Object>> parameters;
108
109         private Map<String, Object> bodyParameters;
110
111         private boolean bodyParametersEnabled;
112
113         private boolean parametersEnabled;
114
115         private String schemaLink;
116
117         private String schemaType;
118
119         private boolean hasReturnSchema;
120
121         private String returnSchemaLink;
122
123         private String returnSchemaObject;
124
125         public void setConsumerEnabled(boolean consumerEnabled){
126             this.consumerEnabled = consumerEnabled;
127         }
128
129         public boolean isConsumerEnabled() {
130             return consumerEnabled;
131         }
132
133
134         public List<String> getTags() {
135             return tags;
136         }
137
138         public void setTags(List<String> tags) {
139             this.tags = tags;
140         }
141
142         public String getType() {
143             return type;
144         }
145
146         public void setType(String type) {
147             this.type = type;
148         }
149
150         public String getSummary() {
151             return summary;
152         }
153
154         public void setSummary(String summary) {
155             this.summary = summary;
156         }
157
158         public String getOperationId() {
159             return operationId;
160         }
161
162         public void setOperationId(String operationId) {
163             this.operationId = operationId;
164         }
165
166         public List<String> getConsumes() {
167             return consumes;
168         }
169
170         public void setConsumes(List<String> consumes) {
171             this.consumes = consumes;
172         }
173
174         public List<String> getProduces() {
175             return produces;
176         }
177
178         public void setProduces(List<String> produces) {
179             this.produces = produces;
180         }
181
182         public List<Response> getResponses() {
183             return responses;
184         }
185
186         public void setResponses(List<Response> responses) {
187             this.responses = responses;
188         }
189
190         public List<Map<String, Object>> getParameters() {
191             return parameters;
192         }
193
194         public void setParameters(List<Map<String, Object>> parameters) {
195             this.parameters = parameters;
196         }
197
198         @Override
199         public String toString() {
200             return "HttpVerb{" +
201                     "tags=" + tags +
202                     ", type='" + type + '\'' +
203                     ", summary='" + summary + '\'' +
204                     ", operationId='" + operationId + '\'' +
205                     ", consumes=" + consumes +
206                     ", produces=" + produces +
207                     ", responses=" + responses +
208                     ", parameters=" + parameters +
209                     '}';
210         }
211
212         public void setParametersEnabled(boolean b) {
213             this.parametersEnabled = b;
214         }
215
216         public boolean isParametersEnabled() {
217             return parametersEnabled;
218         }
219
220         public boolean isBodyParametersEnabled() {
221             return bodyParametersEnabled;
222         }
223         public boolean isOpNotPatch() {
224                 return type.equalsIgnoreCase("patch") ? false : true;
225         }
226
227         public void setBodyParametersEnabled(boolean bodyParametersEnabled) {
228             this.bodyParametersEnabled = bodyParametersEnabled;
229         }
230
231         public Map<String, Object> getBodyParameters() {
232             return bodyParameters;
233         }
234
235         public void setBodyParameters(Map<String, Object> bodyParameters) {
236             this.bodyParameters = bodyParameters;
237         }
238
239         public String getSchemaLink() {
240             return schemaLink;
241         }
242
243         public void setSchemaLink(String schemaLink) {
244             this.schemaLink = schemaLink;
245         }
246
247         public String getSchemaType() {
248             return schemaType;
249         }
250
251         public void setSchemaType(String schemaType) {
252             this.schemaType = schemaType;
253         }
254
255         public boolean isHasReturnSchema() {
256             return hasReturnSchema;
257         }
258
259         public void setHasReturnSchema(boolean hasReturnSchema) {
260             this.hasReturnSchema = hasReturnSchema;
261         }
262
263         public String getReturnSchemaLink() {
264             return returnSchemaLink;
265         }
266
267         public void setReturnSchemaLink(String returnSchemaLink) {
268             this.returnSchemaLink = returnSchemaLink;
269         }
270
271         public String getReturnSchemaObject() {
272             return returnSchemaObject;
273         }
274
275         public void setReturnSchemaObject(String returnSchemaObject) {
276             this.returnSchemaObject = returnSchemaObject;
277         }
278
279         public static class Response {
280
281             private String responseCode;
282
283             private String description;
284
285                         private String version;
286
287             public String getResponseCode() {
288                 return responseCode;
289             }
290
291             public void setResponseCode(String responseCode) {
292                 this.responseCode = responseCode;
293             }
294
295             public String getDescription() {
296                 return description;
297             }
298
299             public void setDescription(String description) {
300                 this.description = description;
301             }
302
303             @Override
304             public String toString() {
305                 return "Response{" +
306                         "responseCode='" + responseCode + '\'' +
307                         ", description='" + description + '\'' +
308                         '}';
309             }
310
311                         public void setVersion(String version) {
312                                 this.version = version;                         
313                         }
314         }
315
316     }
317
318 }