Sahil Lele

ONOS-2485 Autogenerate swagger JSON files from WebResource classes

Change-Id: If3efcd22ce04b4579bf0d3359684b252d981913e
......@@ -51,6 +51,8 @@
<module>features</module>
<module>tools/package/archetypes</module>
<module>tools/package/branding</module>
<!-- FIXME remove before release -->
<module>tools/package/maven-plugin</module>
<module>ovsdb</module>
</modules>
......@@ -94,6 +96,14 @@
</repository>
</repositories>
<!--- FIXME Needed for onos-maven-plugin. Remove before official release -->
<pluginRepositories>
<pluginRepository>
<id>snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</pluginRepository>
</pluginRepositories>
<dependencyManagement>
<dependencies>
<dependency>
......@@ -584,7 +594,7 @@
<plugin>
<groupId>org.onosproject</groupId>
<artifactId>onos-maven-plugin</artifactId>
<version>1.4</version>
<version>1.5-SNAPSHOT</version>
<executions>
<execution>
<id>cfg</id>
......@@ -594,6 +604,13 @@
</goals>
</execution>
<execution>
<id>swagger</id>
<phase>generate-resources</phase>
<goals>
<goal>swagger</goal>
</goals>
</execution>
<execution>
<id>app</id>
<phase>package</phase>
<goals>
......
......@@ -75,6 +75,16 @@
<version>3.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.4.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.4.2</version>
</dependency>
</dependencies>
<build>
......
......@@ -59,4 +59,13 @@
<web.context>/onos/v1</web.context>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.onosproject</groupId>
<artifactId>onos-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
......
......@@ -240,9 +240,8 @@ public class NetworkConfigWebResource extends AbstractWebResource {
*/
@DELETE
@Path("{subjectKey}/{subject}")
@Consumes(MediaType.APPLICATION_JSON)
@SuppressWarnings("unchecked")
public Response upload(@PathParam("subjectKey") String subjectKey,
public Response delete(@PathParam("subjectKey") String subjectKey,
@PathParam("subject") String subject) {
NetworkConfigService service = get(NetworkConfigService.class);
Object s = service.getSubjectFactory(subjectKey).createSubject(subject);
......@@ -261,9 +260,8 @@ public class NetworkConfigWebResource extends AbstractWebResource {
*/
@DELETE
@Path("{subjectKey}/{subject}/{configKey}")
@Consumes(MediaType.APPLICATION_JSON)
@SuppressWarnings("unchecked")
public Response upload(@PathParam("subjectKey") String subjectKey,
public Response delete(@PathParam("subjectKey") String subjectKey,
@PathParam("subject") String subject,
@PathParam("configKey") String configKey) {
NetworkConfigService service = get(NetworkConfigService.class);
......@@ -279,9 +277,8 @@ public class NetworkConfigWebResource extends AbstractWebResource {
* @return empty response
*/
@DELETE
@Consumes(MediaType.APPLICATION_JSON)
@SuppressWarnings("unchecked")
public Response upload() {
public Response delete() {
NetworkConfigService service = get(NetworkConfigService.class);
service.getSubjectClasses().forEach(subjectClass -> {
service.getSubjects(subjectClass).forEach(subject -> {
......@@ -303,9 +300,8 @@ public class NetworkConfigWebResource extends AbstractWebResource {
*/
@DELETE
@Path("{subjectKey}/")
@Consumes(MediaType.APPLICATION_JSON)
@SuppressWarnings("unchecked")
public Response upload(@PathParam("subjectKey") String subjectKey) {
public Response delete(@PathParam("subjectKey") String subjectKey) {
NetworkConfigService service = get(NetworkConfigService.class);
service.getSubjects(service.getSubjectFactory(subjectKey).getClass()).forEach(subject -> {
service.getConfigs(subject).forEach(config -> {
......