Merge remote-tracking branch 'origin/master' into 2.3.0

This commit is contained in:
wing328 2017-03-26 23:05:46 +08:00
commit 20cc80d170
20 changed files with 138 additions and 32 deletions

View File

@ -26,6 +26,6 @@ fi
# if you've executed sbt assembly previously it will use that instead. # if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
args="$@ generate -t modules/swagger-codegen/src/main/resources/bash -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l bash -o samples/client/petstore/bash -c modules/swagger-codegen/src/test/resources/2_0/bash-config.json" args="$@ generate -t modules/swagger-codegen/src/main/resources/bash -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l bash -o samples/client/petstore/bash -c modules/swagger-codegen/src/test/resources/2_0/bash-config.json --additional-properties hideGenerationTimestamp=true"
java $JAVA_OPTS -jar $executable $args java $JAVA_OPTS -jar $executable $args

View File

@ -8,8 +8,8 @@
# ! swagger-codegen (https://github.com/swagger-api/swagger-codegen) # ! swagger-codegen (https://github.com/swagger-api/swagger-codegen)
# ! FROM SWAGGER SPECIFICATION IN JSON. # ! FROM SWAGGER SPECIFICATION IN JSON.
# ! # !
# ! Generated on: {{generatedDate}} {{^hideGenerationTimestamp}}# ! Generated on: {{generatedDate}}
# ! {{/hideGenerationTimestamp}}# !
# ! # !
# ! System wide installation: # ! System wide installation:
# ! # !

View File

@ -8,8 +8,8 @@
# ! swagger-codegen (https://github.com/swagger-api/swagger-codegen) # ! swagger-codegen (https://github.com/swagger-api/swagger-codegen)
# ! FROM SWAGGER SPECIFICATION IN JSON. # ! FROM SWAGGER SPECIFICATION IN JSON.
# ! # !
# ! Generated on: {{generatedDate}} {{^hideGenerationTimestamp}}# ! Generated on: {{generatedDate}}
# ! {{/hideGenerationTimestamp}}# !
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# #

View File

@ -10,8 +10,8 @@
# ! # !
# ! Based on: https://github.com/Valodim/zsh-curl-completion/blob/master/_curl # ! Based on: https://github.com/Valodim/zsh-curl-completion/blob/master/_curl
# ! # !
# ! Generated on: {{generatedDate}} {{^hideGenerationTimestamp}}# ! Generated on: {{generatedDate}}
# ! {{/hideGenerationTimestamp}}# !
# ! # !
# ! Installation: # ! Installation:
# ! # !

View File

@ -10,7 +10,6 @@
# ! # !
# ! Based on: https://github.com/Valodim/zsh-curl-completion/blob/master/_curl # ! Based on: https://github.com/Valodim/zsh-curl-completion/blob/master/_curl
# ! # !
# ! Generated on: 2017-03-15T16:43:11.743+01:00
# ! # !
# ! # !
# ! Installation: # ! Installation:

View File

@ -8,7 +8,6 @@
# ! swagger-codegen (https://github.com/swagger-api/swagger-codegen) # ! swagger-codegen (https://github.com/swagger-api/swagger-codegen)
# ! FROM SWAGGER SPECIFICATION IN JSON. # ! FROM SWAGGER SPECIFICATION IN JSON.
# ! # !
# ! Generated on: 2017-03-15T16:43:11.743+01:00
# ! # !
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

View File

@ -8,7 +8,6 @@
# ! swagger-codegen (https://github.com/swagger-api/swagger-codegen) # ! swagger-codegen (https://github.com/swagger-api/swagger-codegen)
# ! FROM SWAGGER SPECIFICATION IN JSON. # ! FROM SWAGGER SPECIFICATION IN JSON.
# ! # !
# ! Generated on: 2017-03-15T16:43:11.743+01:00
# ! # !
# ! # !
# ! System wide installation: # ! System wide installation:

View File

@ -19,6 +19,7 @@ import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponse;
import io.swagger.jaxrs.PATCH; import io.swagger.jaxrs.PATCH;
import javax.validation.constraints.*; import javax.validation.constraints.*;
import javax.validation.Valid;
@Path("/") @Path("/")
@Api(value = "/", description = "") @Api(value = "/", description = "")
@ -31,7 +32,7 @@ public interface PetApi {
@ApiOperation(value = "Add a new pet to the store", tags={ "pet", }) @ApiOperation(value = "Add a new pet to the store", tags={ "pet", })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 405, message = "Invalid input") }) @ApiResponse(code = 405, message = "Invalid input") })
public void addPet(Pet body); public void addPet(@Valid Pet body);
@DELETE @DELETE
@Path("/pet/{petId}") @Path("/pet/{petId}")
@ -78,7 +79,7 @@ public interface PetApi {
@ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 400, message = "Invalid ID supplied"),
@ApiResponse(code = 404, message = "Pet not found"), @ApiResponse(code = 404, message = "Pet not found"),
@ApiResponse(code = 405, message = "Validation exception") }) @ApiResponse(code = 405, message = "Validation exception") })
public void updatePet(Pet body); public void updatePet(@Valid Pet body);
@POST @POST
@Path("/pet/{petId}") @Path("/pet/{petId}")

View File

@ -18,6 +18,7 @@ import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponse;
import io.swagger.jaxrs.PATCH; import io.swagger.jaxrs.PATCH;
import javax.validation.constraints.*; import javax.validation.constraints.*;
import javax.validation.Valid;
@Path("/") @Path("/")
@Api(value = "/", description = "") @Api(value = "/", description = "")
@ -57,6 +58,6 @@ public interface StoreApi {
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = Order.class), @ApiResponse(code = 200, message = "successful operation", response = Order.class),
@ApiResponse(code = 400, message = "Invalid Order") }) @ApiResponse(code = 400, message = "Invalid Order") })
public Order placeOrder(Order body); public Order placeOrder(@Valid Order body);
} }

View File

@ -18,6 +18,7 @@ import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponse;
import io.swagger.jaxrs.PATCH; import io.swagger.jaxrs.PATCH;
import javax.validation.constraints.*; import javax.validation.constraints.*;
import javax.validation.Valid;
@Path("/") @Path("/")
@Api(value = "/", description = "") @Api(value = "/", description = "")
@ -29,7 +30,7 @@ public interface UserApi {
@ApiOperation(value = "Create user", tags={ "user", }) @ApiOperation(value = "Create user", tags={ "user", })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation") }) @ApiResponse(code = 200, message = "successful operation") })
public void createUser(User body); public void createUser(@Valid User body);
@POST @POST
@Path("/user/createWithArray") @Path("/user/createWithArray")
@ -37,7 +38,7 @@ public interface UserApi {
@ApiOperation(value = "Creates list of users with given input array", tags={ "user", }) @ApiOperation(value = "Creates list of users with given input array", tags={ "user", })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation") }) @ApiResponse(code = 200, message = "successful operation") })
public void createUsersWithArrayInput(List<User> body); public void createUsersWithArrayInput(@Valid List<User> body);
@POST @POST
@Path("/user/createWithList") @Path("/user/createWithList")
@ -45,7 +46,7 @@ public interface UserApi {
@ApiOperation(value = "Creates list of users with given input array", tags={ "user", }) @ApiOperation(value = "Creates list of users with given input array", tags={ "user", })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation") }) @ApiResponse(code = 200, message = "successful operation") })
public void createUsersWithListInput(List<User> body); public void createUsersWithListInput(@Valid List<User> body);
@DELETE @DELETE
@Path("/user/{username}") @Path("/user/{username}")
@ -90,6 +91,6 @@ public interface UserApi {
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 400, message = "Invalid user supplied"), @ApiResponse(code = 400, message = "Invalid user supplied"),
@ApiResponse(code = 404, message = "User not found") }) @ApiResponse(code = 404, message = "User not found") })
public void updateUser(@PathParam("username") String username, User body); public void updateUser(@PathParam("username") String username, @Valid User body);
} }

View File

@ -0,0 +1,72 @@
.travis.yaml
.swagger-codegen-ignore
README.md
tox.ini
git_push.sh
test-requirements.txt
setup.py
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/
venv/
.python-version
# Translations
*.mo
*.pot
# Django stuff:
*.log
# Sphinx documentation
docs/_build/
# PyBuilder
target/
#Ipython Notebook
.ipynb_checkpoints

View File

@ -0,0 +1,16 @@
FROM python:2-alpine
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY requirements.txt /usr/src/app/
RUN pip install --no-cache-dir -r requirements.txt
COPY . /usr/src/app
EXPOSE 8080
ENTRYPOINT ["python"]
CMD ["-m", "swagger_server"]

View File

@ -35,3 +35,15 @@ To launch the integration tests, use tox:
sudo pip install tox sudo pip install tox
tox tox
``` ```
## Running with Docker
To run the server on a Docker container, please execute the following from the root directory:
```bash
# building the image
docker build -t swagger_server .
# starting up a container
docker run -p 8080:8080 swagger_server
```

View File

@ -108,11 +108,11 @@ paths:
type: "array" type: "array"
items: items:
type: "string" type: "string"
default: "available"
enum: enum:
- "available" - "available"
- "pending" - "pending"
- "sold" - "sold"
default: "available"
collectionFormat: "csv" collectionFormat: "csv"
responses: responses:
200: 200:

View File

@ -19,6 +19,7 @@ import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponse;
import io.swagger.jaxrs.PATCH; import io.swagger.jaxrs.PATCH;
import javax.validation.constraints.*; import javax.validation.constraints.*;
import javax.validation.Valid;
@Path("/v2") @Path("/v2")
@Api(value = "/", description = "") @Api(value = "/", description = "")
@ -31,7 +32,7 @@ public interface PetApi {
@ApiOperation(value = "Add a new pet to the store", tags={ "pet", }) @ApiOperation(value = "Add a new pet to the store", tags={ "pet", })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 405, message = "Invalid input") }) @ApiResponse(code = 405, message = "Invalid input") })
public void addPet(Pet body); public void addPet(@Valid Pet body);
@DELETE @DELETE
@Path("/pet/{petId}") @Path("/pet/{petId}")
@ -78,7 +79,7 @@ public interface PetApi {
@ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 400, message = "Invalid ID supplied"),
@ApiResponse(code = 404, message = "Pet not found"), @ApiResponse(code = 404, message = "Pet not found"),
@ApiResponse(code = 405, message = "Validation exception") }) @ApiResponse(code = 405, message = "Validation exception") })
public void updatePet(Pet body); public void updatePet(@Valid Pet body);
@POST @POST
@Path("/pet/{petId}") @Path("/pet/{petId}")

View File

@ -18,6 +18,7 @@ import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponse;
import io.swagger.jaxrs.PATCH; import io.swagger.jaxrs.PATCH;
import javax.validation.constraints.*; import javax.validation.constraints.*;
import javax.validation.Valid;
@Path("/v2") @Path("/v2")
@Api(value = "/", description = "") @Api(value = "/", description = "")
@ -57,6 +58,6 @@ public interface StoreApi {
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = Order.class), @ApiResponse(code = 200, message = "successful operation", response = Order.class),
@ApiResponse(code = 400, message = "Invalid Order") }) @ApiResponse(code = 400, message = "Invalid Order") })
public Order placeOrder(Order body); public Order placeOrder(@Valid Order body);
} }

View File

@ -18,6 +18,7 @@ import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponse;
import io.swagger.jaxrs.PATCH; import io.swagger.jaxrs.PATCH;
import javax.validation.constraints.*; import javax.validation.constraints.*;
import javax.validation.Valid;
@Path("/v2") @Path("/v2")
@Api(value = "/", description = "") @Api(value = "/", description = "")
@ -29,7 +30,7 @@ public interface UserApi {
@ApiOperation(value = "Create user", tags={ "user", }) @ApiOperation(value = "Create user", tags={ "user", })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation") }) @ApiResponse(code = 200, message = "successful operation") })
public void createUser(User body); public void createUser(@Valid User body);
@POST @POST
@Path("/user/createWithArray") @Path("/user/createWithArray")
@ -37,7 +38,7 @@ public interface UserApi {
@ApiOperation(value = "Creates list of users with given input array", tags={ "user", }) @ApiOperation(value = "Creates list of users with given input array", tags={ "user", })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation") }) @ApiResponse(code = 200, message = "successful operation") })
public void createUsersWithArrayInput(List<User> body); public void createUsersWithArrayInput(@Valid List<User> body);
@POST @POST
@Path("/user/createWithList") @Path("/user/createWithList")
@ -45,7 +46,7 @@ public interface UserApi {
@ApiOperation(value = "Creates list of users with given input array", tags={ "user", }) @ApiOperation(value = "Creates list of users with given input array", tags={ "user", })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation") }) @ApiResponse(code = 200, message = "successful operation") })
public void createUsersWithListInput(List<User> body); public void createUsersWithListInput(@Valid List<User> body);
@DELETE @DELETE
@Path("/user/{username}") @Path("/user/{username}")
@ -90,6 +91,6 @@ public interface UserApi {
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 400, message = "Invalid user supplied"), @ApiResponse(code = 400, message = "Invalid user supplied"),
@ApiResponse(code = 404, message = "User not found") }) @ApiResponse(code = 404, message = "User not found") })
public void updateUser(@PathParam("username") String username, User body); public void updateUser(@PathParam("username") String username, @Valid User body);
} }

View File

@ -19,6 +19,7 @@ import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponse;
import io.swagger.jaxrs.PATCH; import io.swagger.jaxrs.PATCH;
import javax.validation.constraints.*; import javax.validation.constraints.*;
import javax.validation.Valid;
@Path("/") @Path("/")
@Api(value = "/", description = "") @Api(value = "/", description = "")
@ -31,7 +32,7 @@ public interface PetApi {
@ApiOperation(value = "Add a new pet to the store", tags={ "pet", }) @ApiOperation(value = "Add a new pet to the store", tags={ "pet", })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 405, message = "Invalid input") }) @ApiResponse(code = 405, message = "Invalid input") })
public void addPet(Pet body); public void addPet(@Valid Pet body);
@DELETE @DELETE
@Path("/pet/{petId}") @Path("/pet/{petId}")
@ -78,7 +79,7 @@ public interface PetApi {
@ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 400, message = "Invalid ID supplied"),
@ApiResponse(code = 404, message = "Pet not found"), @ApiResponse(code = 404, message = "Pet not found"),
@ApiResponse(code = 405, message = "Validation exception") }) @ApiResponse(code = 405, message = "Validation exception") })
public void updatePet(Pet body); public void updatePet(@Valid Pet body);
@POST @POST
@Path("/pet/{petId}") @Path("/pet/{petId}")

View File

@ -18,6 +18,7 @@ import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponse;
import io.swagger.jaxrs.PATCH; import io.swagger.jaxrs.PATCH;
import javax.validation.constraints.*; import javax.validation.constraints.*;
import javax.validation.Valid;
@Path("/") @Path("/")
@Api(value = "/", description = "") @Api(value = "/", description = "")
@ -57,6 +58,6 @@ public interface StoreApi {
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = Order.class), @ApiResponse(code = 200, message = "successful operation", response = Order.class),
@ApiResponse(code = 400, message = "Invalid Order") }) @ApiResponse(code = 400, message = "Invalid Order") })
public Order placeOrder(Order body); public Order placeOrder(@Valid Order body);
} }

View File

@ -18,6 +18,7 @@ import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponse;
import io.swagger.jaxrs.PATCH; import io.swagger.jaxrs.PATCH;
import javax.validation.constraints.*; import javax.validation.constraints.*;
import javax.validation.Valid;
@Path("/") @Path("/")
@Api(value = "/", description = "") @Api(value = "/", description = "")
@ -29,7 +30,7 @@ public interface UserApi {
@ApiOperation(value = "Create user", tags={ "user", }) @ApiOperation(value = "Create user", tags={ "user", })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation") }) @ApiResponse(code = 200, message = "successful operation") })
public void createUser(User body); public void createUser(@Valid User body);
@POST @POST
@Path("/user/createWithArray") @Path("/user/createWithArray")
@ -37,7 +38,7 @@ public interface UserApi {
@ApiOperation(value = "Creates list of users with given input array", tags={ "user", }) @ApiOperation(value = "Creates list of users with given input array", tags={ "user", })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation") }) @ApiResponse(code = 200, message = "successful operation") })
public void createUsersWithArrayInput(List<User> body); public void createUsersWithArrayInput(@Valid List<User> body);
@POST @POST
@Path("/user/createWithList") @Path("/user/createWithList")
@ -45,7 +46,7 @@ public interface UserApi {
@ApiOperation(value = "Creates list of users with given input array", tags={ "user", }) @ApiOperation(value = "Creates list of users with given input array", tags={ "user", })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation") }) @ApiResponse(code = 200, message = "successful operation") })
public void createUsersWithListInput(List<User> body); public void createUsersWithListInput(@Valid List<User> body);
@DELETE @DELETE
@Path("/user/{username}") @Path("/user/{username}")
@ -90,6 +91,6 @@ public interface UserApi {
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 400, message = "Invalid user supplied"), @ApiResponse(code = 400, message = "Invalid user supplied"),
@ApiResponse(code = 404, message = "User not found") }) @ApiResponse(code = 404, message = "User not found") })
public void updateUser(@PathParam("username") String username, User body); public void updateUser(@PathParam("username") String username, @Valid User body);
} }