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