Skip to content

Commit

Permalink
Updating the example to be compatible with swagger-maven-plugin 3.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
who committed Aug 21, 2015
1 parent 47c3e03 commit 3d6bfa0
Show file tree
Hide file tree
Showing 10 changed files with 132 additions and 29 deletions.
77 changes: 75 additions & 2 deletions generated/document.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,79 @@



# Security Definitions


### api_key



<table>
<tr>
<th>type</th>
<th colspan="2">apiKey</th>
</tr>


<tr>
<th>name</th>
<th colspan="2">api_key</th>
</tr>


<tr>
<th>in</th>
<th colspan="2">HEADER</th>
</tr>

</table>




### petstore_auth


<table>
<tr>
<th>type</th>
<th colspan="2">oauth2</th>
</tr>


<tr>
<th>authorizationUrl</th>
<th colspan="2">http://swagger.io/api/oauth/dialog</th>
</tr>


<tr>
<th>flow</th>
<th colspan="2">implicit</th>
</tr>



<tr>
<td rowspan="3">scopes</td>

<td>write:pets</td>
<td>modify pets in your account</td>
</tr>
<tr>

<td>read:pets</td>
<td>read your pets</td>
</tr>
<tr>

</tr>

</table>






# APIs
Expand Down Expand Up @@ -245,7 +318,7 @@
<td> - </td>


<td>Array[string] (multi)</td>
<td>Array[string] (csv)</td>


</tr>
Expand Down Expand Up @@ -332,7 +405,7 @@
<td> - </td>


<td>Array[string] (multi)</td>
<td>Array[string] (csv)</td>


</tr>
Expand Down
45 changes: 35 additions & 10 deletions generated/swagger-ui/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
"basePath" : "/api",
"tags" : [ {
"name" : "pet"
}, {
"name" : "user"
}, {
"name" : "store"
}, {
"name" : "user"
} ],
"schemes" : [ "http", "https" ],
"paths" : {
Expand Down Expand Up @@ -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" : {
Expand Down Expand Up @@ -139,7 +139,7 @@
"items" : {
"type" : "string"
},
"collectionFormat" : "multi"
"collectionFormat" : "csv"
} ],
"responses" : {
"200" : {
Expand Down Expand Up @@ -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" : {
Expand Down Expand Up @@ -239,7 +241,6 @@
"parameters" : [ {
"name" : "api_key",
"in" : "header",
"description" : "",
"required" : false,
"type" : "string",
"default" : ""
Expand Down Expand Up @@ -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" : {
Expand Down Expand Up @@ -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" : {
Expand Down Expand Up @@ -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",
Expand All @@ -563,6 +584,7 @@
}
},
"Order" : {
"type" : "object",
"properties" : {
"id" : {
"type" : "integer",
Expand Down Expand Up @@ -595,6 +617,7 @@
}
},
"Pet" : {
"type" : "object",
"required" : [ "name", "photoUrls" ],
"properties" : {
"id" : {
Expand Down Expand Up @@ -639,6 +662,7 @@
}
},
"Tag" : {
"type" : "object",
"properties" : {
"id" : {
"type" : "integer",
Expand All @@ -653,6 +677,7 @@
}
},
"User" : {
"type" : "object",
"properties" : {
"id" : {
"type" : "integer",
Expand Down
11 changes: 8 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<plugin>
<groupId>com.github.kongchen</groupId>
<artifactId>swagger-maven-plugin</artifactId>
<version>3.0.1-SNAPSHOT</version>
<version>3.1.0</version>
<configuration>
<apiSources>
<apiSource>
Expand Down Expand Up @@ -46,6 +46,11 @@
<templatePath>${basedir}/templates/strapdown.html.hbs</templatePath>
<outputPath>${basedir}/generated/document.html</outputPath>
<swaggerDirectory>generated/swagger-ui</swaggerDirectory>
<securityDefinitions>
<securityDefinition>
<json>/securityDefinition.json</json>
</securityDefinition>
</securityDefinitions>
</apiSource>
</apiSources>
</configuration>
Expand Down Expand Up @@ -76,10 +81,10 @@
</build>
<dependencies>
<dependency>
<groupId>com.wordnik</groupId>
<groupId>io.swagger</groupId>
<artifactId>swagger-core</artifactId>
<scope>compile</scope>
<version>1.5.1-M2</version>
<version>1.5.3</version>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@
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;
import javax.ws.rs.*;

@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")
Expand All @@ -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") })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>
com.wordnik.swagger.jaxrs.json,
io.swagger.jaxrs.json,
com.github.kongchen.swagger.sample.wordnik.resource
</param-value>
</init-param>
<init-param>
<param-name>jersey.config.server.provider.classnames</param-name>
<param-value>
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
</param-value>
</init-param>
<init-param>
Expand All @@ -35,7 +35,7 @@

<servlet>
<servlet-name>Jersey2Config</servlet-name>
<servlet-class>com.wordnik.swagger.jersey.config.JerseyJaxrsConfig</servlet-class>
<servlet-class>io.swagger.jersey.config.JerseyJaxrsConfig</servlet-class>
<init-param>
<param-name>api.version</param-name>
<param-value>1.0.0</param-value>
Expand Down

0 comments on commit 3d6bfa0

Please sign in to comment.