Committed by
Gerrit Code Review
ONOS-3607 Add Criteria model for Flows REST Api with field description.
Change Model parsing in Swagger mojo for whitspaces stripping. Also, readding onos-maven-plugin to root pom build temporarily. Change-Id: I8995c74d762a3e59acebe15cc600a0f1bfa41411
Showing
5 changed files
with
411 additions
and
16 deletions
... | @@ -54,6 +54,7 @@ | ... | @@ -54,6 +54,7 @@ |
54 | 54 | ||
55 | <module>tools/package/archetypes</module> | 55 | <module>tools/package/archetypes</module> |
56 | <module>tools/package/branding</module> | 56 | <module>tools/package/branding</module> |
57 | + <module>tools/package/maven-plugin</module> | ||
57 | </modules> | 58 | </modules> |
58 | 59 | ||
59 | <url>http://onosproject.org/</url> | 60 | <url>http://onosproject.org/</url> |
... | @@ -78,7 +79,7 @@ | ... | @@ -78,7 +79,7 @@ |
78 | <netty4.version>4.0.23.Final</netty4.version> | 79 | <netty4.version>4.0.23.Final</netty4.version> |
79 | <copycat.version>0.5.1.onos</copycat.version> | 80 | <copycat.version>0.5.1.onos</copycat.version> |
80 | <openflowj.version>0.9.1.onos</openflowj.version> | 81 | <openflowj.version>0.9.1.onos</openflowj.version> |
81 | - <onos-maven-plugin.version>1.7</onos-maven-plugin.version> | 82 | + <onos-maven-plugin.version>1.8-SNAPSHOT</onos-maven-plugin.version> |
82 | <karaf.version>3.0.3</karaf.version> | 83 | <karaf.version>3.0.3</karaf.version> |
83 | <jersey.version>1.19</jersey.version> | 84 | <jersey.version>1.19</jersey.version> |
84 | <!-- TODO argLine was originally added maven-surfire-plugin configuration | 85 | <!-- TODO argLine was originally added maven-surfire-plugin configuration | ... | ... |
... | @@ -91,6 +91,11 @@ | ... | @@ -91,6 +91,11 @@ |
91 | <artifactId>commons-io</artifactId> | 91 | <artifactId>commons-io</artifactId> |
92 | <version>2.4</version> | 92 | <version>2.4</version> |
93 | </dependency> | 93 | </dependency> |
94 | + <dependency> | ||
95 | + <groupId>com.google.code.gson</groupId> | ||
96 | + <artifactId>gson</artifactId> | ||
97 | + <version>2.5</version> | ||
98 | + </dependency> | ||
94 | </dependencies> | 99 | </dependencies> |
95 | 100 | ||
96 | <build> | 101 | <build> | ... | ... |
... | @@ -18,9 +18,9 @@ package org.onosproject.maven; | ... | @@ -18,9 +18,9 @@ package org.onosproject.maven; |
18 | import com.fasterxml.jackson.databind.ObjectMapper; | 18 | import com.fasterxml.jackson.databind.ObjectMapper; |
19 | import com.fasterxml.jackson.databind.node.ArrayNode; | 19 | import com.fasterxml.jackson.databind.node.ArrayNode; |
20 | import com.fasterxml.jackson.databind.node.ObjectNode; | 20 | import com.fasterxml.jackson.databind.node.ObjectNode; |
21 | -import com.google.common.base.Charsets; | ||
22 | import com.google.common.io.ByteStreams; | 21 | import com.google.common.io.ByteStreams; |
23 | import com.google.common.io.Files; | 22 | import com.google.common.io.Files; |
23 | +import com.google.gson.JsonParser; | ||
24 | import com.thoughtworks.qdox.JavaProjectBuilder; | 24 | import com.thoughtworks.qdox.JavaProjectBuilder; |
25 | import com.thoughtworks.qdox.model.DocletTag; | 25 | import com.thoughtworks.qdox.model.DocletTag; |
26 | import com.thoughtworks.qdox.model.JavaAnnotation; | 26 | import com.thoughtworks.qdox.model.JavaAnnotation; |
... | @@ -36,6 +36,7 @@ import org.apache.maven.plugins.annotations.Parameter; | ... | @@ -36,6 +36,7 @@ import org.apache.maven.plugins.annotations.Parameter; |
36 | import org.apache.maven.project.MavenProject; | 36 | import org.apache.maven.project.MavenProject; |
37 | 37 | ||
38 | import java.io.File; | 38 | import java.io.File; |
39 | +import java.io.FileReader; | ||
39 | import java.io.FileWriter; | 40 | import java.io.FileWriter; |
40 | import java.io.IOException; | 41 | import java.io.IOException; |
41 | import java.io.PrintWriter; | 42 | import java.io.PrintWriter; |
... | @@ -51,6 +52,7 @@ import static com.google.common.base.Strings.isNullOrEmpty; | ... | @@ -51,6 +52,7 @@ import static com.google.common.base.Strings.isNullOrEmpty; |
51 | @Mojo(name = "swagger", defaultPhase = LifecyclePhase.GENERATE_SOURCES) | 52 | @Mojo(name = "swagger", defaultPhase = LifecyclePhase.GENERATE_SOURCES) |
52 | public class OnosSwaggerMojo extends AbstractMojo { | 53 | public class OnosSwaggerMojo extends AbstractMojo { |
53 | private final ObjectMapper mapper = new ObjectMapper(); | 54 | private final ObjectMapper mapper = new ObjectMapper(); |
55 | + private final JsonParser jsonParser = new JsonParser(); | ||
54 | 56 | ||
55 | private static final String JSON_FILE = "swagger.json"; | 57 | private static final String JSON_FILE = "swagger.json"; |
56 | private static final String GEN_SRC = "generated-sources"; | 58 | private static final String GEN_SRC = "generated-sources"; |
... | @@ -291,10 +293,7 @@ public class OnosSwaggerMojo extends AbstractMojo { | ... | @@ -291,10 +293,7 @@ public class OnosSwaggerMojo extends AbstractMojo { |
291 | try { | 293 | try { |
292 | File config = new File(definitionsDirectory.getAbsolutePath() + "/" | 294 | File config = new File(definitionsDirectory.getAbsolutePath() + "/" |
293 | + param + ".json"); | 295 | + param + ".json"); |
294 | - String lines = Files.readLines(config, Charsets.UTF_8).stream().reduce((t, u) -> t + u). | 296 | + definitions.putPOJO(param, jsonParser.parse(new FileReader(config))); |
295 | - get(); | ||
296 | - lines = lines.replaceAll("\\s+", ""); | ||
297 | - definitions.putPOJO(param, lines); | ||
298 | } catch (IOException e) { | 297 | } catch (IOException e) { |
299 | e.printStackTrace(); | 298 | e.printStackTrace(); |
300 | } | 299 | } | ... | ... |
... | @@ -155,19 +155,214 @@ | ... | @@ -155,19 +155,214 @@ |
155 | "items": { | 155 | "items": { |
156 | "type": "object", | 156 | "type": "object", |
157 | "title": "criteria", | 157 | "title": "criteria", |
158 | - "required": [ | ||
159 | - "type", | ||
160 | - "ethType" | ||
161 | - ], | ||
162 | "properties": { | 158 | "properties": { |
163 | "type": { | 159 | "type": { |
164 | "type": "string", | 160 | "type": "string", |
161 | + "description":"Ethernet field name", | ||
165 | "example": "ETH_TYPE" | 162 | "example": "ETH_TYPE" |
166 | }, | 163 | }, |
167 | "ethType": { | 164 | "ethType": { |
165 | + "type": "int64", | ||
166 | + "format": "int64", | ||
167 | + "example": "0x88cc", | ||
168 | + "description":"Ethernet frame type" | ||
169 | + }, | ||
170 | + "mac": { | ||
171 | + "type": "string", | ||
172 | + "example": "00:00:11:00:00:01" | ||
173 | + }, | ||
174 | + "port": { | ||
175 | + "type": "int64", | ||
176 | + "format": "int64", | ||
177 | + "example": 1, | ||
178 | + "description":"Match port" | ||
179 | + }, | ||
180 | + "metadata": { | ||
181 | + "type": "Hex16", | ||
182 | + "format": "Hex16", | ||
183 | + "example": "0xabcdL", | ||
184 | + "description":"Metadata passed between tables" | ||
185 | + }, | ||
186 | + "vlanId": { | ||
187 | + "type": "uint16", | ||
188 | + "format": "uint16", | ||
189 | + "example": "0x1000" | ||
190 | + }, | ||
191 | + "priority": { | ||
192 | + "type": "int64", | ||
193 | + "format": "int64", | ||
194 | + "example": 1, | ||
195 | + "description":"VLAN priority." | ||
196 | + }, | ||
197 | + "ipDscp": { | ||
198 | + "type": "byte", | ||
199 | + "format": "byte", | ||
200 | + "description":"IP DSCP (6 bits in ToS field)" | ||
201 | + }, | ||
202 | + "ipEcn": { | ||
203 | + "type": "byte", | ||
204 | + "format": "byte", | ||
205 | + "description":"IP ECN (2 bits in ToS field)." | ||
206 | + }, | ||
207 | + "protocol": { | ||
208 | + "type": "uint16", | ||
209 | + "format": "uint16", | ||
210 | + "example": 1, | ||
211 | + "description":"IP protocol" | ||
212 | + }, | ||
213 | + "ip": { | ||
214 | + "type": "string", | ||
215 | + "example": "10.1.1.0/24", | ||
216 | + "description":"IP source address" | ||
217 | + }, | ||
218 | + "tcpPort": { | ||
219 | + "type": "integer", | ||
220 | + "format": "uint16", | ||
221 | + "example": 1, | ||
222 | + "description":"TCP source address" | ||
223 | + }, | ||
224 | + "udpPort": { | ||
225 | + "type": "uint16", | ||
226 | + "format": "uint16", | ||
227 | + "example": 1, | ||
228 | + "description":"UDP source address" | ||
229 | + }, | ||
230 | + "sctpPort": { | ||
231 | + "type": "uint16", | ||
232 | + "format": "uint16", | ||
233 | + "example": 1, | ||
234 | + "description":"SCTP source address" | ||
235 | + }, | ||
236 | + "icmpType": { | ||
237 | + "type": "uint16", | ||
238 | + "format": "uint16", | ||
239 | + "example": 1, | ||
240 | + "description":"Internet Control Message Protocol for IPV4 code (RFC0792)" | ||
241 | + }, | ||
242 | + "icmpCode": { | ||
243 | + "type": "uint16", | ||
244 | + "format": "uint16", | ||
245 | + "example": 1, | ||
246 | + "description":"Internet Control Message Protocol for IPV4 code (RFC0792)" | ||
247 | + }, | ||
248 | + "flowLabel": { | ||
249 | + "type": "Hex16", | ||
250 | + "format": "Hex16", | ||
251 | + "example": "0xffffe", | ||
252 | + "description":"IPv6 Flow Label (RFC 6437)" | ||
253 | + }, | ||
254 | + "icmpv6Type": { | ||
255 | + "type": "uint16", | ||
256 | + "format": "uint16", | ||
257 | + "example": 1, | ||
258 | + "description":"Internet Control Message Protocol for IPV6 type (RFC2463)" | ||
259 | + }, | ||
260 | + "icmpv6Code": { | ||
261 | + "type": "uint16", | ||
262 | + "format": "uint16", | ||
263 | + "example": 1, | ||
264 | + "description":"Internet Control Message Protocol for IPV6 code (RFC2463)" | ||
265 | + }, | ||
266 | + "targetAddress": { | ||
267 | + "type": "String", | ||
268 | + "example": "10.1.1.0/24", | ||
269 | + "description":"IPv6 Neighbor discovery target address" | ||
270 | + }, | ||
271 | + "label": { | ||
272 | + "type": "int32", | ||
273 | + "format": "int32", | ||
274 | + "example": 1, | ||
275 | + "description":"MPLS label" | ||
276 | + }, | ||
277 | + "exthdrFlags": { | ||
278 | + "type": "int64", | ||
279 | + "format": "int64", | ||
280 | + "example": 1, | ||
281 | + "description":"IPv6 extension header pseudo-field" | ||
282 | + }, | ||
283 | + "lambda": { | ||
284 | + "type": "int64", | ||
285 | + "format": "int64", | ||
286 | + "example": 1, | ||
287 | + "description":"wavelength abstraction" | ||
288 | + }, | ||
289 | + "gridType": { | ||
290 | + "type": "String", | ||
291 | + "example": "DWDM", | ||
292 | + "description":"Type of wavelength grid" | ||
293 | + }, | ||
294 | + "channelSpacing": { | ||
295 | + "type": "int64", | ||
296 | + "format": "int64", | ||
297 | + "example": 100, | ||
298 | + "description":"Optical channel spacing" | ||
299 | + }, | ||
300 | + "spacingMultiplier": { | ||
301 | + "type": "integer", | ||
302 | + "format": "int64", | ||
303 | + "example": 4, | ||
304 | + "description":"Optical channel spacing multiplier" | ||
305 | + }, | ||
306 | + "slotGranularity": { | ||
307 | + "type": "int64", | ||
308 | + "format": "int64", | ||
309 | + "example": 8 | ||
310 | + }, | ||
311 | + "ochSignalId": { | ||
168 | "type": "integer", | 312 | "type": "integer", |
169 | "format": "int64", | 313 | "format": "int64", |
170 | - "example": "0x88cc" | 314 | + "example": 1, |
315 | + "description":"Optical channel signal ID" | ||
316 | + }, | ||
317 | + "tunnelId": { | ||
318 | + "type": "int64", | ||
319 | + "format": "int64", | ||
320 | + "example": 5, | ||
321 | + "description":"Tunnel ID" | ||
322 | + }, | ||
323 | + "ochSignalType": { | ||
324 | + "type": "int64", | ||
325 | + "format": "int64", | ||
326 | + "example": 1, | ||
327 | + "description":"Optical channel signal type" | ||
328 | + }, | ||
329 | + "oduSignalId": { | ||
330 | + "type": "int64", | ||
331 | + "format": "int64", | ||
332 | + "example": 1, | ||
333 | + "description":"ODU (Optical channel Data Unit) signal ID." | ||
334 | + }, | ||
335 | + "tributaryPortNumber": { | ||
336 | + "type": "int64", | ||
337 | + "format": "int64", | ||
338 | + "example": 11, | ||
339 | + "description":"OPU (Optical channel Payload Unit) port number." | ||
340 | + }, | ||
341 | + "tributarySlotLen": { | ||
342 | + "type": "int64", | ||
343 | + "format": "int64", | ||
344 | + "example": 80, | ||
345 | + "description":"OPU (Optical channel Payload Unit) slot length." | ||
346 | + }, | ||
347 | + "tributarySlotBitmap": { | ||
348 | + "type": "array", | ||
349 | + "title": "tributarySlotBitmap", | ||
350 | + "description":"OPU (Optical channel Payload Unit) slot bitmap.", | ||
351 | + "required": [ | ||
352 | + "byte", | ||
353 | + "port" | ||
354 | + ], | ||
355 | + "items": { | ||
356 | + "type": "byte", | ||
357 | + "title": "byte", | ||
358 | + "example": 1 | ||
359 | + } | ||
360 | + }, | ||
361 | + "oduSignalType": { | ||
362 | + "type": "int64", | ||
363 | + "format": "int64", | ||
364 | + "example": 4, | ||
365 | + "description":"ODU (Optical channel Data Unit) signal type." | ||
171 | } | 366 | } |
172 | } | 367 | } |
173 | } | 368 | } | ... | ... |
... | @@ -78,19 +78,214 @@ | ... | @@ -78,19 +78,214 @@ |
78 | "items": { | 78 | "items": { |
79 | "type": "object", | 79 | "type": "object", |
80 | "title": "criteria", | 80 | "title": "criteria", |
81 | - "required": [ | ||
82 | - "type", | ||
83 | - "ethType" | ||
84 | - ], | ||
85 | "properties": { | 81 | "properties": { |
86 | "type": { | 82 | "type": { |
87 | "type": "string", | 83 | "type": "string", |
84 | + "description":"Ethernet field name", | ||
88 | "example": "ETH_TYPE" | 85 | "example": "ETH_TYPE" |
89 | }, | 86 | }, |
90 | "ethType": { | 87 | "ethType": { |
88 | + "type": "int64", | ||
89 | + "format": "int64", | ||
90 | + "example": "0x88cc", | ||
91 | + "description":"Ethernet frame type" | ||
92 | + }, | ||
93 | + "mac": { | ||
94 | + "type": "string", | ||
95 | + "example": "00:00:11:00:00:01" | ||
96 | + }, | ||
97 | + "port": { | ||
98 | + "type": "int64", | ||
99 | + "format": "int64", | ||
100 | + "example": 1, | ||
101 | + "description":"Match port" | ||
102 | + }, | ||
103 | + "metadata": { | ||
104 | + "type": "Hex16", | ||
105 | + "format": "Hex16", | ||
106 | + "example": "0xabcdL", | ||
107 | + "description":"Metadata passed between tables" | ||
108 | + }, | ||
109 | + "vlanId": { | ||
110 | + "type": "uint16", | ||
111 | + "format": "uint16", | ||
112 | + "example": "0x1000" | ||
113 | + }, | ||
114 | + "priority": { | ||
115 | + "type": "int64", | ||
116 | + "format": "int64", | ||
117 | + "example": 1, | ||
118 | + "description":"VLAN priority." | ||
119 | + }, | ||
120 | + "ipDscp": { | ||
121 | + "type": "byte", | ||
122 | + "format": "byte", | ||
123 | + "description":"IP DSCP (6 bits in ToS field)" | ||
124 | + }, | ||
125 | + "ipEcn": { | ||
126 | + "type": "byte", | ||
127 | + "format": "byte", | ||
128 | + "description":"IP ECN (2 bits in ToS field)." | ||
129 | + }, | ||
130 | + "protocol": { | ||
131 | + "type": "uint16", | ||
132 | + "format": "uint16", | ||
133 | + "example": 1, | ||
134 | + "description":"IP protocol" | ||
135 | + }, | ||
136 | + "ip": { | ||
137 | + "type": "string", | ||
138 | + "example": "10.1.1.0/24", | ||
139 | + "description":"IP source address" | ||
140 | + }, | ||
141 | + "tcpPort": { | ||
142 | + "type": "integer", | ||
143 | + "format": "uint16", | ||
144 | + "example": 1, | ||
145 | + "description":"TCP source address" | ||
146 | + }, | ||
147 | + "udpPort": { | ||
148 | + "type": "uint16", | ||
149 | + "format": "uint16", | ||
150 | + "example": 1, | ||
151 | + "description":"UDP source address" | ||
152 | + }, | ||
153 | + "sctpPort": { | ||
154 | + "type": "uint16", | ||
155 | + "format": "uint16", | ||
156 | + "example": 1, | ||
157 | + "description":"SCTP source address" | ||
158 | + }, | ||
159 | + "icmpType": { | ||
160 | + "type": "uint16", | ||
161 | + "format": "uint16", | ||
162 | + "example": 1, | ||
163 | + "description":"Internet Control Message Protocol for IPV4 code (RFC0792)" | ||
164 | + }, | ||
165 | + "icmpCode": { | ||
166 | + "type": "uint16", | ||
167 | + "format": "uint16", | ||
168 | + "example": 1, | ||
169 | + "description":"Internet Control Message Protocol for IPV4 code (RFC0792)" | ||
170 | + }, | ||
171 | + "flowLabel": { | ||
172 | + "type": "Hex16", | ||
173 | + "format": "Hex16", | ||
174 | + "example": "0xffffe", | ||
175 | + "description":"IPv6 Flow Label (RFC 6437)" | ||
176 | + }, | ||
177 | + "icmpv6Type": { | ||
178 | + "type": "uint16", | ||
179 | + "format": "uint16", | ||
180 | + "example": 1, | ||
181 | + "description":"Internet Control Message Protocol for IPV6 type (RFC2463)" | ||
182 | + }, | ||
183 | + "icmpv6Code": { | ||
184 | + "type": "uint16", | ||
185 | + "format": "uint16", | ||
186 | + "example": 1, | ||
187 | + "description":"Internet Control Message Protocol for IPV6 code (RFC2463)" | ||
188 | + }, | ||
189 | + "targetAddress": { | ||
190 | + "type": "String", | ||
191 | + "example": "10.1.1.0/24", | ||
192 | + "description":"IPv6 Neighbor discovery target address" | ||
193 | + }, | ||
194 | + "label": { | ||
195 | + "type": "int32", | ||
196 | + "format": "int32", | ||
197 | + "example": 1, | ||
198 | + "description":"MPLS label" | ||
199 | + }, | ||
200 | + "exthdrFlags": { | ||
201 | + "type": "int64", | ||
202 | + "format": "int64", | ||
203 | + "example": 1, | ||
204 | + "description":"IPv6 extension header pseudo-field" | ||
205 | + }, | ||
206 | + "lambda": { | ||
207 | + "type": "int64", | ||
208 | + "format": "int64", | ||
209 | + "example": 1, | ||
210 | + "description":"wavelength abstraction" | ||
211 | + }, | ||
212 | + "gridType": { | ||
213 | + "type": "String", | ||
214 | + "example": "DWDM", | ||
215 | + "description":"Type of wavelength grid" | ||
216 | + }, | ||
217 | + "channelSpacing": { | ||
218 | + "type": "int64", | ||
219 | + "format": "int64", | ||
220 | + "example": 100, | ||
221 | + "description":"Optical channel spacing" | ||
222 | + }, | ||
223 | + "spacingMultiplier": { | ||
224 | + "type": "integer", | ||
225 | + "format": "int64", | ||
226 | + "example": 4, | ||
227 | + "description":"Optical channel spacing multiplier" | ||
228 | + }, | ||
229 | + "slotGranularity": { | ||
230 | + "type": "int64", | ||
231 | + "format": "int64", | ||
232 | + "example": 8 | ||
233 | + }, | ||
234 | + "ochSignalId": { | ||
91 | "type": "integer", | 235 | "type": "integer", |
92 | "format": "int64", | 236 | "format": "int64", |
93 | - "example": "0x88cc" | 237 | + "example": 1, |
238 | + "description":"Optical channel signal ID" | ||
239 | + }, | ||
240 | + "tunnelId": { | ||
241 | + "type": "int64", | ||
242 | + "format": "int64", | ||
243 | + "example": 5, | ||
244 | + "description":"Tunnel ID" | ||
245 | + }, | ||
246 | + "ochSignalType": { | ||
247 | + "type": "int64", | ||
248 | + "format": "int64", | ||
249 | + "example": 1, | ||
250 | + "description":"Optical channel signal type" | ||
251 | + }, | ||
252 | + "oduSignalId": { | ||
253 | + "type": "int64", | ||
254 | + "format": "int64", | ||
255 | + "example": 1, | ||
256 | + "description":"ODU (Optical channel Data Unit) signal ID." | ||
257 | + }, | ||
258 | + "tributaryPortNumber": { | ||
259 | + "type": "int64", | ||
260 | + "format": "int64", | ||
261 | + "example": 11, | ||
262 | + "description":"OPU (Optical channel Payload Unit) port number." | ||
263 | + }, | ||
264 | + "tributarySlotLen": { | ||
265 | + "type": "int64", | ||
266 | + "format": "int64", | ||
267 | + "example": 80, | ||
268 | + "description":"OPU (Optical channel Payload Unit) slot length." | ||
269 | + }, | ||
270 | + "tributarySlotBitmap": { | ||
271 | + "type": "array", | ||
272 | + "title": "tributarySlotBitmap", | ||
273 | + "description":"OPU (Optical channel Payload Unit) slot bitmap.", | ||
274 | + "required": [ | ||
275 | + "byte", | ||
276 | + "port" | ||
277 | + ], | ||
278 | + "items": { | ||
279 | + "type": "byte", | ||
280 | + "title": "byte", | ||
281 | + "example": 1 | ||
282 | + } | ||
283 | + }, | ||
284 | + "oduSignalType": { | ||
285 | + "type": "int64", | ||
286 | + "format": "int64", | ||
287 | + "example": 4, | ||
288 | + "description":"ODU (Optical channel Data Unit) signal type." | ||
94 | } | 289 | } |
95 | } | 290 | } |
96 | } | 291 | } | ... | ... |
-
Please register or login to post a comment