From 3d6bfa06d638d0855edc04816d4e35bff4a5e771 Mon Sep 17 00:00:00 2001 From: Andrew B Date: Thu, 20 Aug 2015 22:06:58 -0700 Subject: [PATCH] Updating the example to be compatible with swagger-maven-plugin 3.1.0 --- generated/document.html | 77 ++++++++++++++++++- generated/swagger-ui/swagger.json | 45 ++++++++--- pom.xml | 11 ++- .../swagger/sample/wordnik/model/Order.java | 2 +- .../swagger/sample/wordnik/model/Pet.java | 2 +- .../swagger/sample/wordnik/model/User.java | 2 +- .../sample/wordnik/resource/PetResource.java | 8 +- .../wordnik/resource/PetStoreResource.java | 2 +- .../sample/wordnik/resource/UserResource.java | 2 +- src/main/webapp/WEB-INF/web.xml | 10 +-- 10 files changed, 132 insertions(+), 29 deletions(-) diff --git a/generated/document.html b/generated/document.html index 4034fc7..a2bcb9a 100644 --- a/generated/document.html +++ b/generated/document.html @@ -28,6 +28,79 @@ +# Security Definitions + + +### api_key + + + + + + + + + + + + + + + + + + + + + +
typeapiKey
nameapi_key
inHEADER
+ + + + +### petstore_auth + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
typeoauth2
authorizationUrlhttp://swagger.io/api/oauth/dialog
flowimplicit
scopeswrite:petsmodify pets in your account
read:petsread your pets
+ + + + # APIs @@ -245,7 +318,7 @@ - - Array[string] (multi) + Array[string] (csv) @@ -332,7 +405,7 @@ - - Array[string] (multi) + Array[string] (csv) diff --git a/generated/swagger-ui/swagger.json b/generated/swagger-ui/swagger.json index a1bd314..9629206 100644 --- a/generated/swagger-ui/swagger.json +++ b/generated/swagger-ui/swagger.json @@ -19,10 +19,10 @@ "basePath" : "/api", "tags" : [ { "name" : "pet" - }, { - "name" : "user" }, { "name" : "store" + }, { + "name" : "user" } ], "schemes" : [ "http", "https" ], "paths" : { @@ -98,11 +98,11 @@ "required" : true, "type" : "array", "items" : { - "type" : "string" + "type" : "string", + "default" : "available", + "enum" : [ "available", "pending", "sold" ] }, - "collectionFormat" : "multi", - "default" : "available", - "enum" : [ "available", "pending", "sold" ] + "collectionFormat" : "csv" } ], "responses" : { "200" : { @@ -139,7 +139,7 @@ "items" : { "type" : "string" }, - "collectionFormat" : "multi" + "collectionFormat" : "csv" } ], "responses" : { "200" : { @@ -173,6 +173,8 @@ "description" : "ID of pet that needs to be fetched", "required" : true, "type" : "integer", + "maximum" : 5.0, + "minimum" : 1.0, "format" : "int64" } ], "responses" : { @@ -239,7 +241,6 @@ "parameters" : [ { "name" : "api_key", "in" : "header", - "description" : "", "required" : false, "type" : "string", "default" : "" @@ -302,7 +303,9 @@ "in" : "path", "description" : "ID of pet that needs to be fetched", "required" : true, - "type" : "string" + "type" : "string", + "maximum" : 5.0, + "minimum" : 1.0 } ], "responses" : { "200" : { @@ -330,7 +333,8 @@ "in" : "path", "description" : "ID of the order that needs to be deleted", "required" : true, - "type" : "string" + "type" : "string", + "minimum" : 1.0 } ], "responses" : { "400" : { @@ -547,8 +551,25 @@ } } }, + "securityDefinitions" : { + "api_key" : { + "type" : "apiKey", + "name" : "api_key", + "in" : "header" + }, + "petstore_auth" : { + "type" : "oauth2", + "authorizationUrl" : "http://swagger.io/api/oauth/dialog", + "flow" : "implicit", + "scopes" : { + "write:pets" : "modify pets in your account", + "read:pets" : "read your pets" + } + } + }, "definitions" : { "Category" : { + "type" : "object", "properties" : { "id" : { "type" : "integer", @@ -563,6 +584,7 @@ } }, "Order" : { + "type" : "object", "properties" : { "id" : { "type" : "integer", @@ -595,6 +617,7 @@ } }, "Pet" : { + "type" : "object", "required" : [ "name", "photoUrls" ], "properties" : { "id" : { @@ -639,6 +662,7 @@ } }, "Tag" : { + "type" : "object", "properties" : { "id" : { "type" : "integer", @@ -653,6 +677,7 @@ } }, "User" : { + "type" : "object", "properties" : { "id" : { "type" : "integer", diff --git a/pom.xml b/pom.xml index 0e47c9c..a7fe6e3 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ com.github.kongchen swagger-maven-plugin - 3.0.1-SNAPSHOT + 3.1.0 @@ -46,6 +46,11 @@ ${basedir}/templates/strapdown.html.hbs ${basedir}/generated/document.html generated/swagger-ui + + + /securityDefinition.json + + @@ -76,10 +81,10 @@ - com.wordnik + io.swagger swagger-core compile - 1.5.1-M2 + 1.5.3 javax.ws.rs diff --git a/src/main/java/com/github/kongchen/swagger/sample/wordnik/model/Order.java b/src/main/java/com/github/kongchen/swagger/sample/wordnik/model/Order.java index 7cde9da..93909ec 100644 --- a/src/main/java/com/github/kongchen/swagger/sample/wordnik/model/Order.java +++ b/src/main/java/com/github/kongchen/swagger/sample/wordnik/model/Order.java @@ -16,7 +16,7 @@ package com.github.kongchen.swagger.sample.wordnik.model; -import com.wordnik.swagger.annotations.*; +import io.swagger.annotations.*; import java.util.Date; diff --git a/src/main/java/com/github/kongchen/swagger/sample/wordnik/model/Pet.java b/src/main/java/com/github/kongchen/swagger/sample/wordnik/model/Pet.java index 09a2f88..da809d6 100644 --- a/src/main/java/com/github/kongchen/swagger/sample/wordnik/model/Pet.java +++ b/src/main/java/com/github/kongchen/swagger/sample/wordnik/model/Pet.java @@ -16,7 +16,7 @@ package com.github.kongchen.swagger.sample.wordnik.model; -import com.wordnik.swagger.annotations.*; +import io.swagger.annotations.*; import java.util.List; import java.util.ArrayList; diff --git a/src/main/java/com/github/kongchen/swagger/sample/wordnik/model/User.java b/src/main/java/com/github/kongchen/swagger/sample/wordnik/model/User.java index 4d8c68b..aef0d24 100644 --- a/src/main/java/com/github/kongchen/swagger/sample/wordnik/model/User.java +++ b/src/main/java/com/github/kongchen/swagger/sample/wordnik/model/User.java @@ -16,7 +16,7 @@ package com.github.kongchen.swagger.sample.wordnik.model; -import com.wordnik.swagger.annotations.*; +import io.swagger.annotations.*; import javax.xml.bind.annotation.*; diff --git a/src/main/java/com/github/kongchen/swagger/sample/wordnik/resource/PetResource.java b/src/main/java/com/github/kongchen/swagger/sample/wordnik/resource/PetResource.java index e71753d..c3f19f9 100644 --- a/src/main/java/com/github/kongchen/swagger/sample/wordnik/resource/PetResource.java +++ b/src/main/java/com/github/kongchen/swagger/sample/wordnik/resource/PetResource.java @@ -17,9 +17,9 @@ package com.github.kongchen.swagger.sample.wordnik.resource; import com.github.kongchen.swagger.sample.wordnik.data.PetData; -import com.wordnik.swagger.annotations.*; +import io.swagger.annotations.*; import com.github.kongchen.swagger.sample.wordnik.model.Pet; -import com.wordnik.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponse; import javax.ws.rs.core.Response; import javax.ws.rs.core.MediaType; @@ -27,7 +27,7 @@ @Path("/pet") @Api(value = "/pet", description = "Operations about pets", authorizations = { - @Authorization(value = "petstore_auth", type = "oauth2", + @Authorization(value = "petstore_auth", scopes = { @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), @AuthorizationScope(scope = "read:pets", description = "read your pets") @@ -43,7 +43,7 @@ public class PetResource { @ApiOperation(value = "Find pet by ID", notes = "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions", response = Pet.class, - authorizations = @Authorization(value = "api_key", type = "api_key") + authorizations = @Authorization(value = "api_key") ) @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Pet not found") }) diff --git a/src/main/java/com/github/kongchen/swagger/sample/wordnik/resource/PetStoreResource.java b/src/main/java/com/github/kongchen/swagger/sample/wordnik/resource/PetStoreResource.java index 075be05..47b20aa 100644 --- a/src/main/java/com/github/kongchen/swagger/sample/wordnik/resource/PetStoreResource.java +++ b/src/main/java/com/github/kongchen/swagger/sample/wordnik/resource/PetStoreResource.java @@ -16,7 +16,7 @@ package com.github.kongchen.swagger.sample.wordnik.resource; -import com.wordnik.swagger.annotations.*; +import io.swagger.annotations.*; import com.github.kongchen.swagger.sample.wordnik.data.StoreData; import com.github.kongchen.swagger.sample.wordnik.model.Order; import com.github.kongchen.swagger.sample.wordnik.exception.NotFoundException; diff --git a/src/main/java/com/github/kongchen/swagger/sample/wordnik/resource/UserResource.java b/src/main/java/com/github/kongchen/swagger/sample/wordnik/resource/UserResource.java index 896fa06..4c4f1a9 100644 --- a/src/main/java/com/github/kongchen/swagger/sample/wordnik/resource/UserResource.java +++ b/src/main/java/com/github/kongchen/swagger/sample/wordnik/resource/UserResource.java @@ -16,7 +16,7 @@ package com.github.kongchen.swagger.sample.wordnik.resource; -import com.wordnik.swagger.annotations.*; +import io.swagger.annotations.*; import com.github.kongchen.swagger.sample.wordnik.data.UserData; import com.github.kongchen.swagger.sample.wordnik.model.User; import com.github.kongchen.swagger.sample.wordnik.exception.ApiException; diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml index 735bd25..bda3583 100644 --- a/src/main/webapp/WEB-INF/web.xml +++ b/src/main/webapp/WEB-INF/web.xml @@ -9,16 +9,16 @@ jersey.config.server.provider.packages - com.wordnik.swagger.jaxrs.json, + io.swagger.jaxrs.json, com.github.kongchen.swagger.sample.wordnik.resource jersey.config.server.provider.classnames - com.wordnik.swagger.jersey.listing.ApiListingResourceJSON, - com.wordnik.swagger.jersey.listing.JerseyApiDeclarationProvider, - com.wordnik.swagger.jersey.listing.JerseyResourceListingProvider + io.swagger.jersey.listing.ApiListingResourceJSON, + io.swagger.jersey.listing.JerseyApiDeclarationProvider, + io.swagger.jersey.listing.JerseyResourceListingProvider @@ -35,7 +35,7 @@ Jersey2Config - com.wordnik.swagger.jersey.config.JerseyJaxrsConfig + io.swagger.jersey.config.JerseyJaxrsConfig api.version 1.0.0