ONOS-2485 Autogenerate swagger JSON files from WebResource classes
Change-Id: If3efcd22ce04b4579bf0d3359684b252d981913e
Showing
5 changed files
with
41 additions
and
9 deletions
| ... | @@ -51,6 +51,8 @@ | ... | @@ -51,6 +51,8 @@ |
| 51 | <module>features</module> | 51 | <module>features</module> |
| 52 | <module>tools/package/archetypes</module> | 52 | <module>tools/package/archetypes</module> |
| 53 | <module>tools/package/branding</module> | 53 | <module>tools/package/branding</module> |
| 54 | + <!-- FIXME remove before release --> | ||
| 55 | + <module>tools/package/maven-plugin</module> | ||
| 54 | <module>ovsdb</module> | 56 | <module>ovsdb</module> |
| 55 | </modules> | 57 | </modules> |
| 56 | 58 | ||
| ... | @@ -94,6 +96,14 @@ | ... | @@ -94,6 +96,14 @@ |
| 94 | </repository> | 96 | </repository> |
| 95 | </repositories> | 97 | </repositories> |
| 96 | 98 | ||
| 99 | + <!--- FIXME Needed for onos-maven-plugin. Remove before official release --> | ||
| 100 | + <pluginRepositories> | ||
| 101 | + <pluginRepository> | ||
| 102 | + <id>snapshots</id> | ||
| 103 | + <url>https://oss.sonatype.org/content/repositories/snapshots</url> | ||
| 104 | + </pluginRepository> | ||
| 105 | + </pluginRepositories> | ||
| 106 | + | ||
| 97 | <dependencyManagement> | 107 | <dependencyManagement> |
| 98 | <dependencies> | 108 | <dependencies> |
| 99 | <dependency> | 109 | <dependency> |
| ... | @@ -584,7 +594,7 @@ | ... | @@ -584,7 +594,7 @@ |
| 584 | <plugin> | 594 | <plugin> |
| 585 | <groupId>org.onosproject</groupId> | 595 | <groupId>org.onosproject</groupId> |
| 586 | <artifactId>onos-maven-plugin</artifactId> | 596 | <artifactId>onos-maven-plugin</artifactId> |
| 587 | - <version>1.4</version> | 597 | + <version>1.5-SNAPSHOT</version> |
| 588 | <executions> | 598 | <executions> |
| 589 | <execution> | 599 | <execution> |
| 590 | <id>cfg</id> | 600 | <id>cfg</id> |
| ... | @@ -594,6 +604,13 @@ | ... | @@ -594,6 +604,13 @@ |
| 594 | </goals> | 604 | </goals> |
| 595 | </execution> | 605 | </execution> |
| 596 | <execution> | 606 | <execution> |
| 607 | + <id>swagger</id> | ||
| 608 | + <phase>generate-resources</phase> | ||
| 609 | + <goals> | ||
| 610 | + <goal>swagger</goal> | ||
| 611 | + </goals> | ||
| 612 | + </execution> | ||
| 613 | + <execution> | ||
| 597 | <id>app</id> | 614 | <id>app</id> |
| 598 | <phase>package</phase> | 615 | <phase>package</phase> |
| 599 | <goals> | 616 | <goals> | ... | ... |
| ... | @@ -75,6 +75,16 @@ | ... | @@ -75,6 +75,16 @@ |
| 75 | <version>3.4</version> | 75 | <version>3.4</version> |
| 76 | <scope>provided</scope> | 76 | <scope>provided</scope> |
| 77 | </dependency> | 77 | </dependency> |
| 78 | + <dependency> | ||
| 79 | + <groupId>com.fasterxml.jackson.core</groupId> | ||
| 80 | + <artifactId>jackson-databind</artifactId> | ||
| 81 | + <version>2.4.2</version> | ||
| 82 | + </dependency> | ||
| 83 | + <dependency> | ||
| 84 | + <groupId>com.fasterxml.jackson.core</groupId> | ||
| 85 | + <artifactId>jackson-annotations</artifactId> | ||
| 86 | + <version>2.4.2</version> | ||
| 87 | + </dependency> | ||
| 78 | </dependencies> | 88 | </dependencies> |
| 79 | 89 | ||
| 80 | <build> | 90 | <build> | ... | ... |
This diff is collapsed. Click to expand it.
| ... | @@ -59,4 +59,13 @@ | ... | @@ -59,4 +59,13 @@ |
| 59 | <web.context>/onos/v1</web.context> | 59 | <web.context>/onos/v1</web.context> |
| 60 | </properties> | 60 | </properties> |
| 61 | 61 | ||
| 62 | + <build> | ||
| 63 | + <plugins> | ||
| 64 | + <plugin> | ||
| 65 | + <groupId>org.onosproject</groupId> | ||
| 66 | + <artifactId>onos-maven-plugin</artifactId> | ||
| 67 | + </plugin> | ||
| 68 | + </plugins> | ||
| 69 | + </build> | ||
| 70 | + | ||
| 62 | </project> | 71 | </project> | ... | ... |
| ... | @@ -240,9 +240,8 @@ public class NetworkConfigWebResource extends AbstractWebResource { | ... | @@ -240,9 +240,8 @@ public class NetworkConfigWebResource extends AbstractWebResource { |
| 240 | */ | 240 | */ |
| 241 | @DELETE | 241 | @DELETE |
| 242 | @Path("{subjectKey}/{subject}") | 242 | @Path("{subjectKey}/{subject}") |
| 243 | - @Consumes(MediaType.APPLICATION_JSON) | ||
| 244 | @SuppressWarnings("unchecked") | 243 | @SuppressWarnings("unchecked") |
| 245 | - public Response upload(@PathParam("subjectKey") String subjectKey, | 244 | + public Response delete(@PathParam("subjectKey") String subjectKey, |
| 246 | @PathParam("subject") String subject) { | 245 | @PathParam("subject") String subject) { |
| 247 | NetworkConfigService service = get(NetworkConfigService.class); | 246 | NetworkConfigService service = get(NetworkConfigService.class); |
| 248 | Object s = service.getSubjectFactory(subjectKey).createSubject(subject); | 247 | Object s = service.getSubjectFactory(subjectKey).createSubject(subject); |
| ... | @@ -261,9 +260,8 @@ public class NetworkConfigWebResource extends AbstractWebResource { | ... | @@ -261,9 +260,8 @@ public class NetworkConfigWebResource extends AbstractWebResource { |
| 261 | */ | 260 | */ |
| 262 | @DELETE | 261 | @DELETE |
| 263 | @Path("{subjectKey}/{subject}/{configKey}") | 262 | @Path("{subjectKey}/{subject}/{configKey}") |
| 264 | - @Consumes(MediaType.APPLICATION_JSON) | ||
| 265 | @SuppressWarnings("unchecked") | 263 | @SuppressWarnings("unchecked") |
| 266 | - public Response upload(@PathParam("subjectKey") String subjectKey, | 264 | + public Response delete(@PathParam("subjectKey") String subjectKey, |
| 267 | @PathParam("subject") String subject, | 265 | @PathParam("subject") String subject, |
| 268 | @PathParam("configKey") String configKey) { | 266 | @PathParam("configKey") String configKey) { |
| 269 | NetworkConfigService service = get(NetworkConfigService.class); | 267 | NetworkConfigService service = get(NetworkConfigService.class); |
| ... | @@ -279,9 +277,8 @@ public class NetworkConfigWebResource extends AbstractWebResource { | ... | @@ -279,9 +277,8 @@ public class NetworkConfigWebResource extends AbstractWebResource { |
| 279 | * @return empty response | 277 | * @return empty response |
| 280 | */ | 278 | */ |
| 281 | @DELETE | 279 | @DELETE |
| 282 | - @Consumes(MediaType.APPLICATION_JSON) | ||
| 283 | @SuppressWarnings("unchecked") | 280 | @SuppressWarnings("unchecked") |
| 284 | - public Response upload() { | 281 | + public Response delete() { |
| 285 | NetworkConfigService service = get(NetworkConfigService.class); | 282 | NetworkConfigService service = get(NetworkConfigService.class); |
| 286 | service.getSubjectClasses().forEach(subjectClass -> { | 283 | service.getSubjectClasses().forEach(subjectClass -> { |
| 287 | service.getSubjects(subjectClass).forEach(subject -> { | 284 | service.getSubjects(subjectClass).forEach(subject -> { |
| ... | @@ -303,9 +300,8 @@ public class NetworkConfigWebResource extends AbstractWebResource { | ... | @@ -303,9 +300,8 @@ public class NetworkConfigWebResource extends AbstractWebResource { |
| 303 | */ | 300 | */ |
| 304 | @DELETE | 301 | @DELETE |
| 305 | @Path("{subjectKey}/") | 302 | @Path("{subjectKey}/") |
| 306 | - @Consumes(MediaType.APPLICATION_JSON) | ||
| 307 | @SuppressWarnings("unchecked") | 303 | @SuppressWarnings("unchecked") |
| 308 | - public Response upload(@PathParam("subjectKey") String subjectKey) { | 304 | + public Response delete(@PathParam("subjectKey") String subjectKey) { |
| 309 | NetworkConfigService service = get(NetworkConfigService.class); | 305 | NetworkConfigService service = get(NetworkConfigService.class); |
| 310 | service.getSubjects(service.getSubjectFactory(subjectKey).getClass()).forEach(subject -> { | 306 | service.getSubjects(service.getSubjectFactory(subjectKey).getClass()).forEach(subject -> { |
| 311 | service.getConfigs(subject).forEach(config -> { | 307 | service.getConfigs(subject).forEach(config -> { | ... | ... |
-
Please register or login to post a comment