mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-06 18:45:23 +00:00
* Fix issue #6867 : The apiPackage option is ignored in the template for Java Play Framework. * use openjdk7 in travis to ensure it works with jdk7
This commit is contained in:
parent
16e3226c8a
commit
ebf4efe3ea
@ -8,3 +8,4 @@
|
||||
./bin/java-play-framework-petstore-server-no-swagger-ui.sh
|
||||
./bin/java-play-framework-petstore-server-no-wrap-calls.sh
|
||||
./bin/java-play-framework-petstore-server-fake-endpoints.sh
|
||||
./bin/java-play-framework-petstore-server-api-package-override.sh
|
@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn clean package
|
||||
fi
|
||||
|
||||
# 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"
|
||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaPlayFramework -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l java-play-framework -o samples/server/petstore/java-play-framework-api-package-override -DhideGenerationTimestamp=true,apiPackage=com.puppies.store.apis"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
@ -168,7 +168,7 @@ public class JavaPlayFrameworkCodegen extends AbstractJavaCodegen implements Bea
|
||||
if(this.useSwaggerUI) {
|
||||
//App/Controllers
|
||||
supportingFiles.add(new SupportingFile("swagger.mustache", "public", "swagger.json"));
|
||||
supportingFiles.add(new SupportingFile("apiDocController.mustache", "app/controllers", "ApiDocController.java"));
|
||||
supportingFiles.add(new SupportingFile("apiDocController.mustache", String.format("app/%s", apiPackage.replace(".", File.separator)), "ApiDocController.java"));
|
||||
}
|
||||
|
||||
//We remove the default api.mustache that is used
|
||||
|
@ -1,4 +1,4 @@
|
||||
package controllers;
|
||||
package {{apiPackage}};
|
||||
|
||||
import javax.inject.*;
|
||||
import play.mvc.*;
|
||||
|
@ -1,6 +1,6 @@
|
||||
import com.google.inject.AbstractModule;
|
||||
|
||||
import controllers.*;
|
||||
import {{apiPackage}}.*;
|
||||
|
||||
public class Module extends AbstractModule {
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
# ~~~~
|
||||
|
||||
{{#useSwaggerUI}}
|
||||
GET /api controllers.ApiDocController.api
|
||||
GET /api {{apiPackage}}.ApiDocController.api
|
||||
{{/useSwaggerUI}}
|
||||
|
||||
{{#apiInfo}}
|
||||
@ -12,7 +12,7 @@ GET /api controllers.ApiDocController.api
|
||||
#Functions for {{{baseName}}} API
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
{{httpMethod}} {{{contextPath}}}{{{path}}} controllers.{{classname}}Controller.{{operationId}}({{#pathParams}}{{paramName}}: {{#isUuid}}java.util.UUID{{/isUuid}}{{^isUuid}}{{{dataType}}}{{/isUuid}}{{#hasMore}}, {{/hasMore}}{{/pathParams}})
|
||||
{{httpMethod}} {{{contextPath}}}{{{path}}} {{apiPackage}}.{{classname}}Controller.{{operationId}}({{#pathParams}}{{paramName}}: {{#isUuid}}java.util.UUID{{/isUuid}}{{^isUuid}}{{{dataType}}}{{/isUuid}}{{#hasMore}}, {{/hasMore}}{{/pathParams}})
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
{{/apis}}
|
||||
|
@ -0,0 +1,23 @@
|
||||
# Swagger Codegen Ignore
|
||||
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
|
||||
|
||||
# Use this file to prevent files from being overwritten by the generator.
|
||||
# The patterns follow closely to .gitignore or .dockerignore.
|
||||
|
||||
# As an example, the C# client generator defines ApiClient.cs.
|
||||
# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line:
|
||||
#ApiClient.cs
|
||||
|
||||
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
||||
#foo/*/qux
|
||||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
||||
|
||||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
||||
#foo/**/qux
|
||||
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
||||
|
||||
# You can also negate patterns with an exclamation (!).
|
||||
# For example, you can ignore all files in a docs folder with the file extension .md:
|
||||
#docs/*.md
|
||||
# Then explicitly reverse the ignore rule for a single file:
|
||||
#!docs/README.md
|
@ -0,0 +1 @@
|
||||
2.3.0
|
@ -0,0 +1,8 @@
|
||||
This software is licensed under the Apache 2 license, quoted below.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this project except in compliance with
|
||||
the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
|
||||
language governing permissions and limitations under the License.
|
@ -0,0 +1,4 @@
|
||||
This is your new Play application
|
||||
=================================
|
||||
|
||||
This file will be packaged with your application when using `activator dist`.
|
@ -0,0 +1,13 @@
|
||||
import com.google.inject.AbstractModule;
|
||||
|
||||
import com.puppies.store.apis.*;
|
||||
|
||||
public class Module extends AbstractModule {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(PetApiControllerImpInterface.class).to(PetApiControllerImp.class);
|
||||
bind(StoreApiControllerImpInterface.class).to(StoreApiControllerImp.class);
|
||||
bind(UserApiControllerImpInterface.class).to(UserApiControllerImp.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
package apimodels;
|
||||
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import java.util.Set;
|
||||
import javax.validation.*;
|
||||
import java.util.Objects;
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* A category for a pet
|
||||
*/
|
||||
|
||||
@SuppressWarnings({"UnusedReturnValue", "WeakerAccess"})
|
||||
public class Category {
|
||||
@JsonProperty("id")
|
||||
private Long id = null;
|
||||
|
||||
@JsonProperty("name")
|
||||
private String name = null;
|
||||
|
||||
public Category id(Long id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get id
|
||||
* @return id
|
||||
**/
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Category name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name
|
||||
* @return name
|
||||
**/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(java.lang.Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Category category = (Category) o;
|
||||
return Objects.equals(id, category.id) &&
|
||||
Objects.equals(name, category.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, name);
|
||||
}
|
||||
|
||||
@SuppressWarnings("StringBufferReplaceableByString")
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class Category {\n");
|
||||
|
||||
sb.append(" id: ").append(toIndentedString(id)).append("\n");
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private String toIndentedString(java.lang.Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,118 @@
|
||||
package apimodels;
|
||||
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import java.util.Set;
|
||||
import javax.validation.*;
|
||||
import java.util.Objects;
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* Describes the result of uploading an image resource
|
||||
*/
|
||||
|
||||
@SuppressWarnings({"UnusedReturnValue", "WeakerAccess"})
|
||||
public class ModelApiResponse {
|
||||
@JsonProperty("code")
|
||||
private Integer code = null;
|
||||
|
||||
@JsonProperty("type")
|
||||
private String type = null;
|
||||
|
||||
@JsonProperty("message")
|
||||
private String message = null;
|
||||
|
||||
public ModelApiResponse code(Integer code) {
|
||||
this.code = code;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get code
|
||||
* @return code
|
||||
**/
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public ModelApiResponse type(String type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get type
|
||||
* @return type
|
||||
**/
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public ModelApiResponse message(String message) {
|
||||
this.message = message;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get message
|
||||
* @return message
|
||||
**/
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(java.lang.Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
ModelApiResponse _apiResponse = (ModelApiResponse) o;
|
||||
return Objects.equals(code, _apiResponse.code) &&
|
||||
Objects.equals(type, _apiResponse.type) &&
|
||||
Objects.equals(message, _apiResponse.message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(code, type, message);
|
||||
}
|
||||
|
||||
@SuppressWarnings("StringBufferReplaceableByString")
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class ModelApiResponse {\n");
|
||||
|
||||
sb.append(" code: ").append(toIndentedString(code)).append("\n");
|
||||
sb.append(" type: ").append(toIndentedString(type)).append("\n");
|
||||
sb.append(" message: ").append(toIndentedString(message)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private String toIndentedString(java.lang.Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,219 @@
|
||||
package apimodels;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import java.util.Set;
|
||||
import javax.validation.*;
|
||||
import java.util.Objects;
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* An order for a pets from the pet store
|
||||
*/
|
||||
|
||||
@SuppressWarnings({"UnusedReturnValue", "WeakerAccess"})
|
||||
public class Order {
|
||||
@JsonProperty("id")
|
||||
private Long id = null;
|
||||
|
||||
@JsonProperty("petId")
|
||||
private Long petId = null;
|
||||
|
||||
@JsonProperty("quantity")
|
||||
private Integer quantity = null;
|
||||
|
||||
@JsonProperty("shipDate")
|
||||
private OffsetDateTime shipDate = null;
|
||||
|
||||
/**
|
||||
* Order Status
|
||||
*/
|
||||
public enum StatusEnum {
|
||||
PLACED("placed"),
|
||||
|
||||
APPROVED("approved"),
|
||||
|
||||
DELIVERED("delivered");
|
||||
|
||||
private final String value;
|
||||
|
||||
StatusEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonValue
|
||||
public String toString() {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static StatusEnum fromValue(String text) {
|
||||
for (StatusEnum b : StatusEnum.values()) {
|
||||
if (String.valueOf(b.value).equals(text)) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@JsonProperty("status")
|
||||
private StatusEnum status = null;
|
||||
|
||||
@JsonProperty("complete")
|
||||
private Boolean complete = false;
|
||||
|
||||
public Order id(Long id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get id
|
||||
* @return id
|
||||
**/
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Order petId(Long petId) {
|
||||
this.petId = petId;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get petId
|
||||
* @return petId
|
||||
**/
|
||||
public Long getPetId() {
|
||||
return petId;
|
||||
}
|
||||
|
||||
public void setPetId(Long petId) {
|
||||
this.petId = petId;
|
||||
}
|
||||
|
||||
public Order quantity(Integer quantity) {
|
||||
this.quantity = quantity;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get quantity
|
||||
* @return quantity
|
||||
**/
|
||||
public Integer getQuantity() {
|
||||
return quantity;
|
||||
}
|
||||
|
||||
public void setQuantity(Integer quantity) {
|
||||
this.quantity = quantity;
|
||||
}
|
||||
|
||||
public Order shipDate(OffsetDateTime shipDate) {
|
||||
this.shipDate = shipDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get shipDate
|
||||
* @return shipDate
|
||||
**/
|
||||
@Valid
|
||||
public OffsetDateTime getShipDate() {
|
||||
return shipDate;
|
||||
}
|
||||
|
||||
public void setShipDate(OffsetDateTime shipDate) {
|
||||
this.shipDate = shipDate;
|
||||
}
|
||||
|
||||
public Order status(StatusEnum status) {
|
||||
this.status = status;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Order Status
|
||||
* @return status
|
||||
**/
|
||||
public StatusEnum getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(StatusEnum status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Order complete(Boolean complete) {
|
||||
this.complete = complete;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get complete
|
||||
* @return complete
|
||||
**/
|
||||
public Boolean isComplete() {
|
||||
return complete;
|
||||
}
|
||||
|
||||
public void setComplete(Boolean complete) {
|
||||
this.complete = complete;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(java.lang.Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Order order = (Order) o;
|
||||
return Objects.equals(id, order.id) &&
|
||||
Objects.equals(petId, order.petId) &&
|
||||
Objects.equals(quantity, order.quantity) &&
|
||||
Objects.equals(shipDate, order.shipDate) &&
|
||||
Objects.equals(status, order.status) &&
|
||||
Objects.equals(complete, order.complete);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, petId, quantity, shipDate, status, complete);
|
||||
}
|
||||
|
||||
@SuppressWarnings("StringBufferReplaceableByString")
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class Order {\n");
|
||||
|
||||
sb.append(" id: ").append(toIndentedString(id)).append("\n");
|
||||
sb.append(" petId: ").append(toIndentedString(petId)).append("\n");
|
||||
sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n");
|
||||
sb.append(" shipDate: ").append(toIndentedString(shipDate)).append("\n");
|
||||
sb.append(" status: ").append(toIndentedString(status)).append("\n");
|
||||
sb.append(" complete: ").append(toIndentedString(complete)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private String toIndentedString(java.lang.Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,238 @@
|
||||
package apimodels;
|
||||
|
||||
import apimodels.Category;
|
||||
import apimodels.Tag;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import java.util.Set;
|
||||
import javax.validation.*;
|
||||
import java.util.Objects;
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* A pet for sale in the pet store
|
||||
*/
|
||||
|
||||
@SuppressWarnings({"UnusedReturnValue", "WeakerAccess"})
|
||||
public class Pet {
|
||||
@JsonProperty("id")
|
||||
private Long id = null;
|
||||
|
||||
@JsonProperty("category")
|
||||
private Category category = null;
|
||||
|
||||
@JsonProperty("name")
|
||||
private String name = null;
|
||||
|
||||
@JsonProperty("photoUrls")
|
||||
private List<String> photoUrls = new ArrayList<>();
|
||||
|
||||
@JsonProperty("tags")
|
||||
private List<Tag> tags = null;
|
||||
|
||||
/**
|
||||
* pet status in the store
|
||||
*/
|
||||
public enum StatusEnum {
|
||||
AVAILABLE("available"),
|
||||
|
||||
PENDING("pending"),
|
||||
|
||||
SOLD("sold");
|
||||
|
||||
private final String value;
|
||||
|
||||
StatusEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonValue
|
||||
public String toString() {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static StatusEnum fromValue(String text) {
|
||||
for (StatusEnum b : StatusEnum.values()) {
|
||||
if (String.valueOf(b.value).equals(text)) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@JsonProperty("status")
|
||||
private StatusEnum status = null;
|
||||
|
||||
public Pet id(Long id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get id
|
||||
* @return id
|
||||
**/
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Pet category(Category category) {
|
||||
this.category = category;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get category
|
||||
* @return category
|
||||
**/
|
||||
@Valid
|
||||
public Category getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
public void setCategory(Category category) {
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
public Pet name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name
|
||||
* @return name
|
||||
**/
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Pet photoUrls(List<String> photoUrls) {
|
||||
this.photoUrls = photoUrls;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Pet addPhotoUrlsItem(String photoUrlsItem) {
|
||||
photoUrls.add(photoUrlsItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get photoUrls
|
||||
* @return photoUrls
|
||||
**/
|
||||
@NotNull
|
||||
public List<String> getPhotoUrls() {
|
||||
return photoUrls;
|
||||
}
|
||||
|
||||
public void setPhotoUrls(List<String> photoUrls) {
|
||||
this.photoUrls = photoUrls;
|
||||
}
|
||||
|
||||
public Pet tags(List<Tag> tags) {
|
||||
this.tags = tags;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Pet addTagsItem(Tag tagsItem) {
|
||||
if (tags == null) {
|
||||
tags = new ArrayList<>();
|
||||
}
|
||||
tags.add(tagsItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tags
|
||||
* @return tags
|
||||
**/
|
||||
@Valid
|
||||
public List<Tag> getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
public void setTags(List<Tag> tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
public Pet status(StatusEnum status) {
|
||||
this.status = status;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* pet status in the store
|
||||
* @return status
|
||||
**/
|
||||
public StatusEnum getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(StatusEnum status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(java.lang.Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Pet pet = (Pet) o;
|
||||
return Objects.equals(id, pet.id) &&
|
||||
Objects.equals(category, pet.category) &&
|
||||
Objects.equals(name, pet.name) &&
|
||||
Objects.equals(photoUrls, pet.photoUrls) &&
|
||||
Objects.equals(tags, pet.tags) &&
|
||||
Objects.equals(status, pet.status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, category, name, photoUrls, tags, status);
|
||||
}
|
||||
|
||||
@SuppressWarnings("StringBufferReplaceableByString")
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class Pet {\n");
|
||||
|
||||
sb.append(" id: ").append(toIndentedString(id)).append("\n");
|
||||
sb.append(" category: ").append(toIndentedString(category)).append("\n");
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n");
|
||||
sb.append(" tags: ").append(toIndentedString(tags)).append("\n");
|
||||
sb.append(" status: ").append(toIndentedString(status)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private String toIndentedString(java.lang.Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,96 @@
|
||||
package apimodels;
|
||||
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import java.util.Set;
|
||||
import javax.validation.*;
|
||||
import java.util.Objects;
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* A tag for a pet
|
||||
*/
|
||||
|
||||
@SuppressWarnings({"UnusedReturnValue", "WeakerAccess"})
|
||||
public class Tag {
|
||||
@JsonProperty("id")
|
||||
private Long id = null;
|
||||
|
||||
@JsonProperty("name")
|
||||
private String name = null;
|
||||
|
||||
public Tag id(Long id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get id
|
||||
* @return id
|
||||
**/
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Tag name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name
|
||||
* @return name
|
||||
**/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(java.lang.Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Tag tag = (Tag) o;
|
||||
return Objects.equals(id, tag.id) &&
|
||||
Objects.equals(name, tag.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, name);
|
||||
}
|
||||
|
||||
@SuppressWarnings("StringBufferReplaceableByString")
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class Tag {\n");
|
||||
|
||||
sb.append(" id: ").append(toIndentedString(id)).append("\n");
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private String toIndentedString(java.lang.Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,228 @@
|
||||
package apimodels;
|
||||
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import java.util.Set;
|
||||
import javax.validation.*;
|
||||
import java.util.Objects;
|
||||
import javax.validation.constraints.*;
|
||||
/**
|
||||
* A User who is purchasing from the pet store
|
||||
*/
|
||||
|
||||
@SuppressWarnings({"UnusedReturnValue", "WeakerAccess"})
|
||||
public class User {
|
||||
@JsonProperty("id")
|
||||
private Long id = null;
|
||||
|
||||
@JsonProperty("username")
|
||||
private String username = null;
|
||||
|
||||
@JsonProperty("firstName")
|
||||
private String firstName = null;
|
||||
|
||||
@JsonProperty("lastName")
|
||||
private String lastName = null;
|
||||
|
||||
@JsonProperty("email")
|
||||
private String email = null;
|
||||
|
||||
@JsonProperty("password")
|
||||
private String password = null;
|
||||
|
||||
@JsonProperty("phone")
|
||||
private String phone = null;
|
||||
|
||||
@JsonProperty("userStatus")
|
||||
private Integer userStatus = null;
|
||||
|
||||
public User id(Long id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get id
|
||||
* @return id
|
||||
**/
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public User username(String username) {
|
||||
this.username = username;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get username
|
||||
* @return username
|
||||
**/
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public User firstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get firstName
|
||||
* @return firstName
|
||||
**/
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public void setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
public User lastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get lastName
|
||||
* @return lastName
|
||||
**/
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public void setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
public User email(String email) {
|
||||
this.email = email;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get email
|
||||
* @return email
|
||||
**/
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public User password(String password) {
|
||||
this.password = password;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get password
|
||||
* @return password
|
||||
**/
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public User phone(String phone) {
|
||||
this.phone = phone;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get phone
|
||||
* @return phone
|
||||
**/
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public User userStatus(Integer userStatus) {
|
||||
this.userStatus = userStatus;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* User Status
|
||||
* @return userStatus
|
||||
**/
|
||||
public Integer getUserStatus() {
|
||||
return userStatus;
|
||||
}
|
||||
|
||||
public void setUserStatus(Integer userStatus) {
|
||||
this.userStatus = userStatus;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(java.lang.Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
User user = (User) o;
|
||||
return Objects.equals(id, user.id) &&
|
||||
Objects.equals(username, user.username) &&
|
||||
Objects.equals(firstName, user.firstName) &&
|
||||
Objects.equals(lastName, user.lastName) &&
|
||||
Objects.equals(email, user.email) &&
|
||||
Objects.equals(password, user.password) &&
|
||||
Objects.equals(phone, user.phone) &&
|
||||
Objects.equals(userStatus, user.userStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, username, firstName, lastName, email, password, phone, userStatus);
|
||||
}
|
||||
|
||||
@SuppressWarnings("StringBufferReplaceableByString")
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class User {\n");
|
||||
|
||||
sb.append(" id: ").append(toIndentedString(id)).append("\n");
|
||||
sb.append(" username: ").append(toIndentedString(username)).append("\n");
|
||||
sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n");
|
||||
sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n");
|
||||
sb.append(" email: ").append(toIndentedString(email)).append("\n");
|
||||
sb.append(" password: ").append(toIndentedString(password)).append("\n");
|
||||
sb.append(" phone: ").append(toIndentedString(phone)).append("\n");
|
||||
sb.append(" userStatus: ").append(toIndentedString(userStatus)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private String toIndentedString(java.lang.Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,15 @@
|
||||
package com.puppies.store.apis;
|
||||
|
||||
import javax.inject.*;
|
||||
import play.mvc.*;
|
||||
|
||||
public class ApiDocController extends Controller {
|
||||
|
||||
@Inject
|
||||
private ApiDocController() {
|
||||
}
|
||||
|
||||
public Result api() {
|
||||
return redirect("/assets/lib/swagger-ui/index.html?/url=/assets/swagger.json");
|
||||
}
|
||||
}
|
@ -0,0 +1,176 @@
|
||||
package com.puppies.store.apis;
|
||||
|
||||
import java.io.InputStream;
|
||||
import apimodels.ModelApiResponse;
|
||||
import apimodels.Pet;
|
||||
|
||||
import play.mvc.Controller;
|
||||
import play.mvc.Result;
|
||||
import play.mvc.Http;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ArrayList;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.google.inject.Inject;
|
||||
import java.io.File;
|
||||
import swagger.SwaggerUtils;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import play.Configuration;
|
||||
|
||||
import swagger.SwaggerUtils.ApiAction;
|
||||
|
||||
|
||||
public class PetApiController extends Controller {
|
||||
|
||||
private final PetApiControllerImpInterface imp;
|
||||
private final ObjectMapper mapper;
|
||||
private final Configuration configuration;
|
||||
|
||||
@Inject
|
||||
private PetApiController(Configuration configuration, PetApiControllerImpInterface imp) {
|
||||
this.imp = imp;
|
||||
mapper = new ObjectMapper();
|
||||
this.configuration = configuration;
|
||||
}
|
||||
|
||||
|
||||
@ApiAction
|
||||
public Result addPet() throws Exception {
|
||||
JsonNode nodebody = request().body().asJson();
|
||||
Pet body;
|
||||
if (nodebody != null) {
|
||||
body = mapper.readValue(nodebody.toString(), Pet.class);
|
||||
if (configuration.getBoolean("useInputBeanValidation")) {
|
||||
SwaggerUtils.validate(body);
|
||||
}
|
||||
} else {
|
||||
throw new IllegalArgumentException("'body' parameter is required");
|
||||
}
|
||||
imp.addPet(body);
|
||||
return ok();
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
public Result deletePet(Long petId) throws Exception {
|
||||
String valueapiKey = request().getHeader("api_key");
|
||||
String apiKey;
|
||||
if (valueapiKey != null) {
|
||||
apiKey = valueapiKey;
|
||||
} else {
|
||||
apiKey = null;
|
||||
}
|
||||
imp.deletePet(petId, apiKey);
|
||||
return ok();
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
public Result findPetsByStatus() throws Exception {
|
||||
String[] statusArray = request().queryString().get("status");
|
||||
if (statusArray == null) {
|
||||
throw new IllegalArgumentException("'status' parameter is required");
|
||||
}
|
||||
List<String> statusList = SwaggerUtils.parametersToList("csv", statusArray);
|
||||
List<String> status = new ArrayList<String>();
|
||||
for (String curParam : statusList) {
|
||||
//noinspection UseBulkOperation
|
||||
status.add(curParam);
|
||||
}
|
||||
List<Pet> obj = imp.findPetsByStatus(status);
|
||||
if (configuration.getBoolean("useOutputBeanValidation")) {
|
||||
for (Pet curItem : obj) {
|
||||
SwaggerUtils.validate(curItem);
|
||||
}
|
||||
}
|
||||
JsonNode result = mapper.valueToTree(obj);
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
public Result findPetsByTags() throws Exception {
|
||||
String[] tagsArray = request().queryString().get("tags");
|
||||
if (tagsArray == null) {
|
||||
throw new IllegalArgumentException("'tags' parameter is required");
|
||||
}
|
||||
List<String> tagsList = SwaggerUtils.parametersToList("csv", tagsArray);
|
||||
List<String> tags = new ArrayList<String>();
|
||||
for (String curParam : tagsList) {
|
||||
//noinspection UseBulkOperation
|
||||
tags.add(curParam);
|
||||
}
|
||||
List<Pet> obj = imp.findPetsByTags(tags);
|
||||
if (configuration.getBoolean("useOutputBeanValidation")) {
|
||||
for (Pet curItem : obj) {
|
||||
SwaggerUtils.validate(curItem);
|
||||
}
|
||||
}
|
||||
JsonNode result = mapper.valueToTree(obj);
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
public Result getPetById(Long petId) throws Exception {
|
||||
Pet obj = imp.getPetById(petId);
|
||||
if (configuration.getBoolean("useOutputBeanValidation")) {
|
||||
SwaggerUtils.validate(obj);
|
||||
}
|
||||
JsonNode result = mapper.valueToTree(obj);
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
public Result updatePet() throws Exception {
|
||||
JsonNode nodebody = request().body().asJson();
|
||||
Pet body;
|
||||
if (nodebody != null) {
|
||||
body = mapper.readValue(nodebody.toString(), Pet.class);
|
||||
if (configuration.getBoolean("useInputBeanValidation")) {
|
||||
SwaggerUtils.validate(body);
|
||||
}
|
||||
} else {
|
||||
throw new IllegalArgumentException("'body' parameter is required");
|
||||
}
|
||||
imp.updatePet(body);
|
||||
return ok();
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
public Result updatePetWithForm(Long petId) throws Exception {
|
||||
String valuename = (request().body().asMultipartFormData().asFormUrlEncoded().get("name"))[0];
|
||||
String name;
|
||||
if (valuename != null) {
|
||||
name = valuename;
|
||||
} else {
|
||||
name = null;
|
||||
}
|
||||
String valuestatus = (request().body().asMultipartFormData().asFormUrlEncoded().get("status"))[0];
|
||||
String status;
|
||||
if (valuestatus != null) {
|
||||
status = valuestatus;
|
||||
} else {
|
||||
status = null;
|
||||
}
|
||||
imp.updatePetWithForm(petId, name, status);
|
||||
return ok();
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
public Result uploadFile(Long petId) throws Exception {
|
||||
String valueadditionalMetadata = (request().body().asMultipartFormData().asFormUrlEncoded().get("additionalMetadata"))[0];
|
||||
String additionalMetadata;
|
||||
if (valueadditionalMetadata != null) {
|
||||
additionalMetadata = valueadditionalMetadata;
|
||||
} else {
|
||||
additionalMetadata = null;
|
||||
}
|
||||
Http.MultipartFormData.FilePart file = request().body().asMultipartFormData().getFile("file");
|
||||
ModelApiResponse obj = imp.uploadFile(petId, additionalMetadata, file);
|
||||
if (configuration.getBoolean("useOutputBeanValidation")) {
|
||||
SwaggerUtils.validate(obj);
|
||||
}
|
||||
JsonNode result = mapper.valueToTree(obj);
|
||||
return ok(result);
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
package com.puppies.store.apis;
|
||||
|
||||
import java.io.InputStream;
|
||||
import apimodels.ModelApiResponse;
|
||||
import apimodels.Pet;
|
||||
|
||||
import play.mvc.Http;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.io.FileInputStream;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
public class PetApiControllerImp implements PetApiControllerImpInterface {
|
||||
@Override
|
||||
public void addPet(Pet body) throws Exception {
|
||||
//Do your magic!!!
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deletePet(Long petId, String apiKey) throws Exception {
|
||||
//Do your magic!!!
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Pet> findPetsByStatus( @NotNull List<String> status) throws Exception {
|
||||
//Do your magic!!!
|
||||
return new ArrayList<Pet>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Pet> findPetsByTags( @NotNull List<String> tags) throws Exception {
|
||||
//Do your magic!!!
|
||||
return new ArrayList<Pet>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pet getPetById(Long petId) throws Exception {
|
||||
//Do your magic!!!
|
||||
return new Pet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePet(Pet body) throws Exception {
|
||||
//Do your magic!!!
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePetWithForm(Long petId, String name, String status) throws Exception {
|
||||
//Do your magic!!!
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelApiResponse uploadFile(Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception {
|
||||
//Do your magic!!!
|
||||
return new ModelApiResponse();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package com.puppies.store.apis;
|
||||
|
||||
import java.io.InputStream;
|
||||
import apimodels.ModelApiResponse;
|
||||
import apimodels.Pet;
|
||||
|
||||
import play.mvc.Http;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@SuppressWarnings("RedundantThrows")
|
||||
public interface PetApiControllerImpInterface {
|
||||
void addPet(Pet body) throws Exception;
|
||||
|
||||
void deletePet(Long petId, String apiKey) throws Exception;
|
||||
|
||||
List<Pet> findPetsByStatus( @NotNull List<String> status) throws Exception;
|
||||
|
||||
List<Pet> findPetsByTags( @NotNull List<String> tags) throws Exception;
|
||||
|
||||
Pet getPetById(Long petId) throws Exception;
|
||||
|
||||
void updatePet(Pet body) throws Exception;
|
||||
|
||||
void updatePetWithForm(Long petId, String name, String status) throws Exception;
|
||||
|
||||
ModelApiResponse uploadFile(Long petId, String additionalMetadata, Http.MultipartFormData.FilePart file) throws Exception;
|
||||
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
package com.puppies.store.apis;
|
||||
|
||||
import java.util.Map;
|
||||
import apimodels.Order;
|
||||
|
||||
import play.mvc.Controller;
|
||||
import play.mvc.Result;
|
||||
import play.mvc.Http;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ArrayList;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.google.inject.Inject;
|
||||
import java.io.File;
|
||||
import swagger.SwaggerUtils;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import play.Configuration;
|
||||
|
||||
import swagger.SwaggerUtils.ApiAction;
|
||||
|
||||
|
||||
public class StoreApiController extends Controller {
|
||||
|
||||
private final StoreApiControllerImpInterface imp;
|
||||
private final ObjectMapper mapper;
|
||||
private final Configuration configuration;
|
||||
|
||||
@Inject
|
||||
private StoreApiController(Configuration configuration, StoreApiControllerImpInterface imp) {
|
||||
this.imp = imp;
|
||||
mapper = new ObjectMapper();
|
||||
this.configuration = configuration;
|
||||
}
|
||||
|
||||
|
||||
@ApiAction
|
||||
public Result deleteOrder(String orderId) throws Exception {
|
||||
imp.deleteOrder(orderId);
|
||||
return ok();
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
public Result getInventory() throws Exception {
|
||||
Map<String, Integer> obj = imp.getInventory();
|
||||
JsonNode result = mapper.valueToTree(obj);
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
public Result getOrderById( @Min(1) @Max(5)Long orderId) throws Exception {
|
||||
Order obj = imp.getOrderById(orderId);
|
||||
if (configuration.getBoolean("useOutputBeanValidation")) {
|
||||
SwaggerUtils.validate(obj);
|
||||
}
|
||||
JsonNode result = mapper.valueToTree(obj);
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
public Result placeOrder() throws Exception {
|
||||
JsonNode nodebody = request().body().asJson();
|
||||
Order body;
|
||||
if (nodebody != null) {
|
||||
body = mapper.readValue(nodebody.toString(), Order.class);
|
||||
if (configuration.getBoolean("useInputBeanValidation")) {
|
||||
SwaggerUtils.validate(body);
|
||||
}
|
||||
} else {
|
||||
throw new IllegalArgumentException("'body' parameter is required");
|
||||
}
|
||||
Order obj = imp.placeOrder(body);
|
||||
if (configuration.getBoolean("useOutputBeanValidation")) {
|
||||
SwaggerUtils.validate(obj);
|
||||
}
|
||||
JsonNode result = mapper.valueToTree(obj);
|
||||
return ok(result);
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package com.puppies.store.apis;
|
||||
|
||||
import java.util.Map;
|
||||
import apimodels.Order;
|
||||
|
||||
import play.mvc.Http;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.io.FileInputStream;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
public class StoreApiControllerImp implements StoreApiControllerImpInterface {
|
||||
@Override
|
||||
public void deleteOrder(String orderId) throws Exception {
|
||||
//Do your magic!!!
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Integer> getInventory() throws Exception {
|
||||
//Do your magic!!!
|
||||
return new HashMap<String, Integer>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Order getOrderById( @Min(1) @Max(5)Long orderId) throws Exception {
|
||||
//Do your magic!!!
|
||||
return new Order();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Order placeOrder(Order body) throws Exception {
|
||||
//Do your magic!!!
|
||||
return new Order();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.puppies.store.apis;
|
||||
|
||||
import java.util.Map;
|
||||
import apimodels.Order;
|
||||
|
||||
import play.mvc.Http;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@SuppressWarnings("RedundantThrows")
|
||||
public interface StoreApiControllerImpInterface {
|
||||
void deleteOrder(String orderId) throws Exception;
|
||||
|
||||
Map<String, Integer> getInventory() throws Exception;
|
||||
|
||||
Order getOrderById( @Min(1) @Max(5)Long orderId) throws Exception;
|
||||
|
||||
Order placeOrder(Order body) throws Exception;
|
||||
|
||||
}
|
@ -0,0 +1,149 @@
|
||||
package com.puppies.store.apis;
|
||||
|
||||
import java.util.List;
|
||||
import apimodels.User;
|
||||
|
||||
import play.mvc.Controller;
|
||||
import play.mvc.Result;
|
||||
import play.mvc.Http;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ArrayList;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.google.inject.Inject;
|
||||
import java.io.File;
|
||||
import swagger.SwaggerUtils;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import play.Configuration;
|
||||
|
||||
import swagger.SwaggerUtils.ApiAction;
|
||||
|
||||
|
||||
public class UserApiController extends Controller {
|
||||
|
||||
private final UserApiControllerImpInterface imp;
|
||||
private final ObjectMapper mapper;
|
||||
private final Configuration configuration;
|
||||
|
||||
@Inject
|
||||
private UserApiController(Configuration configuration, UserApiControllerImpInterface imp) {
|
||||
this.imp = imp;
|
||||
mapper = new ObjectMapper();
|
||||
this.configuration = configuration;
|
||||
}
|
||||
|
||||
|
||||
@ApiAction
|
||||
public Result createUser() throws Exception {
|
||||
JsonNode nodebody = request().body().asJson();
|
||||
User body;
|
||||
if (nodebody != null) {
|
||||
body = mapper.readValue(nodebody.toString(), User.class);
|
||||
if (configuration.getBoolean("useInputBeanValidation")) {
|
||||
SwaggerUtils.validate(body);
|
||||
}
|
||||
} else {
|
||||
throw new IllegalArgumentException("'body' parameter is required");
|
||||
}
|
||||
imp.createUser(body);
|
||||
return ok();
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
public Result createUsersWithArrayInput() throws Exception {
|
||||
JsonNode nodebody = request().body().asJson();
|
||||
List<User> body;
|
||||
if (nodebody != null) {
|
||||
body = mapper.readValue(nodebody.toString(), new TypeReference<List<User>>(){});
|
||||
if (configuration.getBoolean("useInputBeanValidation")) {
|
||||
for (User curItem : body) {
|
||||
SwaggerUtils.validate(curItem);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new IllegalArgumentException("'body' parameter is required");
|
||||
}
|
||||
imp.createUsersWithArrayInput(body);
|
||||
return ok();
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
public Result createUsersWithListInput() throws Exception {
|
||||
JsonNode nodebody = request().body().asJson();
|
||||
List<User> body;
|
||||
if (nodebody != null) {
|
||||
body = mapper.readValue(nodebody.toString(), new TypeReference<List<User>>(){});
|
||||
if (configuration.getBoolean("useInputBeanValidation")) {
|
||||
for (User curItem : body) {
|
||||
SwaggerUtils.validate(curItem);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new IllegalArgumentException("'body' parameter is required");
|
||||
}
|
||||
imp.createUsersWithListInput(body);
|
||||
return ok();
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
public Result deleteUser(String username) throws Exception {
|
||||
imp.deleteUser(username);
|
||||
return ok();
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
public Result getUserByName(String username) throws Exception {
|
||||
User obj = imp.getUserByName(username);
|
||||
if (configuration.getBoolean("useOutputBeanValidation")) {
|
||||
SwaggerUtils.validate(obj);
|
||||
}
|
||||
JsonNode result = mapper.valueToTree(obj);
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
public Result loginUser() throws Exception {
|
||||
String valueusername = request().getQueryString("username");
|
||||
String username;
|
||||
if (valueusername != null) {
|
||||
username = valueusername;
|
||||
} else {
|
||||
throw new IllegalArgumentException("'username' parameter is required");
|
||||
}
|
||||
String valuepassword = request().getQueryString("password");
|
||||
String password;
|
||||
if (valuepassword != null) {
|
||||
password = valuepassword;
|
||||
} else {
|
||||
throw new IllegalArgumentException("'password' parameter is required");
|
||||
}
|
||||
String obj = imp.loginUser(username, password);
|
||||
JsonNode result = mapper.valueToTree(obj);
|
||||
return ok(result);
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
public Result logoutUser() throws Exception {
|
||||
imp.logoutUser();
|
||||
return ok();
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
public Result updateUser(String username) throws Exception {
|
||||
JsonNode nodebody = request().body().asJson();
|
||||
User body;
|
||||
if (nodebody != null) {
|
||||
body = mapper.readValue(nodebody.toString(), User.class);
|
||||
if (configuration.getBoolean("useInputBeanValidation")) {
|
||||
SwaggerUtils.validate(body);
|
||||
}
|
||||
} else {
|
||||
throw new IllegalArgumentException("'body' parameter is required");
|
||||
}
|
||||
imp.updateUser(username, body);
|
||||
return ok();
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package com.puppies.store.apis;
|
||||
|
||||
import java.util.List;
|
||||
import apimodels.User;
|
||||
|
||||
import play.mvc.Http;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.io.FileInputStream;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
public class UserApiControllerImp implements UserApiControllerImpInterface {
|
||||
@Override
|
||||
public void createUser(User body) throws Exception {
|
||||
//Do your magic!!!
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createUsersWithArrayInput(List<User> body) throws Exception {
|
||||
//Do your magic!!!
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createUsersWithListInput(List<User> body) throws Exception {
|
||||
//Do your magic!!!
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteUser(String username) throws Exception {
|
||||
//Do your magic!!!
|
||||
}
|
||||
|
||||
@Override
|
||||
public User getUserByName(String username) throws Exception {
|
||||
//Do your magic!!!
|
||||
return new User();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String loginUser( @NotNull String username, @NotNull String password) throws Exception {
|
||||
//Do your magic!!!
|
||||
return new String();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logoutUser() throws Exception {
|
||||
//Do your magic!!!
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUser(String username, User body) throws Exception {
|
||||
//Do your magic!!!
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package com.puppies.store.apis;
|
||||
|
||||
import java.util.List;
|
||||
import apimodels.User;
|
||||
|
||||
import play.mvc.Http;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@SuppressWarnings("RedundantThrows")
|
||||
public interface UserApiControllerImpInterface {
|
||||
void createUser(User body) throws Exception;
|
||||
|
||||
void createUsersWithArrayInput(List<User> body) throws Exception;
|
||||
|
||||
void createUsersWithListInput(List<User> body) throws Exception;
|
||||
|
||||
void deleteUser(String username) throws Exception;
|
||||
|
||||
User getUserByName(String username) throws Exception;
|
||||
|
||||
String loginUser( @NotNull String username, @NotNull String password) throws Exception;
|
||||
|
||||
void logoutUser() throws Exception;
|
||||
|
||||
void updateUser(String username, User body) throws Exception;
|
||||
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package swagger;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import play.mvc.Action;
|
||||
import play.mvc.Http;
|
||||
import play.mvc.Result;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.CompletionStage;
|
||||
|
||||
public class ApiCall extends Action<SwaggerUtils.ApiAction> {
|
||||
|
||||
@Inject
|
||||
private ApiCall() {}
|
||||
|
||||
public CompletionStage<Result> call(Http.Context ctx) {
|
||||
try {
|
||||
//TODO: Do stuff you want to handle with each API call (metrics, logging, etc..)
|
||||
return delegate.call(ctx);
|
||||
} catch (Throwable t) {
|
||||
//TODO: log the error in your metric
|
||||
|
||||
//We rethrow this error so it will be caught in the ErrorHandler
|
||||
throw t;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package swagger;
|
||||
|
||||
|
||||
import play.*;
|
||||
import play.api.OptionalSourceMapper;
|
||||
import play.api.UsefulException;
|
||||
import play.api.routing.Router;
|
||||
import play.http.DefaultHttpErrorHandler;
|
||||
import play.mvc.Http.*;
|
||||
import play.mvc.*;
|
||||
|
||||
import javax.inject.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.CompletionStage;
|
||||
import static play.mvc.Results.*;
|
||||
|
||||
@Singleton
|
||||
public class ErrorHandler extends DefaultHttpErrorHandler {
|
||||
|
||||
@Inject
|
||||
public ErrorHandler(Configuration configuration, Environment environment, OptionalSourceMapper sourceMapper, Provider<Router> routes) {
|
||||
super(configuration, environment, sourceMapper, routes);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CompletionStage<Result> onDevServerError(RequestHeader request, UsefulException exception) {
|
||||
return CompletableFuture.completedFuture(
|
||||
handleExceptions(exception)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CompletionStage<Result> onProdServerError(RequestHeader request, UsefulException exception) {
|
||||
return CompletableFuture.completedFuture(
|
||||
handleExceptions(exception)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void logServerError(RequestHeader request, UsefulException usefulException) {
|
||||
//Since the error is already handled, we don't want to print anything on the console
|
||||
//But if you want to have the error printed in the console, just delete this override
|
||||
}
|
||||
|
||||
private Result handleExceptions(Throwable t) {
|
||||
//TODO: Handle exception that need special response (return a special apimodel, notFound(), etc..)
|
||||
return ok();
|
||||
}
|
||||
}
|
@ -0,0 +1,103 @@
|
||||
package swagger;
|
||||
|
||||
import play.mvc.With;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
import javax.validation.ConstraintViolation;
|
||||
import javax.validation.Validation;
|
||||
import javax.validation.Validator;
|
||||
import javax.validation.ValidatorFactory;
|
||||
|
||||
public class SwaggerUtils {
|
||||
|
||||
@With(ApiCall.class)
|
||||
@Target({ ElementType.TYPE, ElementType.METHOD })
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface ApiAction {
|
||||
}
|
||||
|
||||
public static <T> void validate(T obj) {
|
||||
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
|
||||
Validator validator = factory.getValidator();
|
||||
Set<ConstraintViolation<T>> constraintViolations = validator.validate(obj);
|
||||
if (constraintViolations.size() > 0) {
|
||||
StringBuilder errors = new StringBuilder();
|
||||
for (ConstraintViolation<T> contraintes : constraintViolations) {
|
||||
errors.append(String.format("%s.%s %s\n",
|
||||
contraintes.getRootBeanClass().getSimpleName(),
|
||||
contraintes.getPropertyPath(),
|
||||
contraintes.getMessage()));
|
||||
}
|
||||
throw new RuntimeException("Bean validation : " + errors);
|
||||
}
|
||||
}
|
||||
|
||||
public static List<String> parametersToList(String collectionFormat, String[] values){
|
||||
List<String> params = new ArrayList<>();
|
||||
|
||||
if (values == null) {
|
||||
return params;
|
||||
}
|
||||
|
||||
if (values.length >= 1 && collectionFormat.equals("multi")) {
|
||||
params.addAll(Arrays.asList(values));
|
||||
} else {
|
||||
collectionFormat = (collectionFormat == null || collectionFormat.isEmpty() ? "csv" : collectionFormat); // default: csv
|
||||
|
||||
String delimiter = ",";
|
||||
|
||||
switch(collectionFormat) {
|
||||
case "csv": {
|
||||
delimiter = ",";
|
||||
break;
|
||||
}
|
||||
case "ssv": {
|
||||
delimiter = " ";
|
||||
break;
|
||||
}
|
||||
case "tsv": {
|
||||
delimiter = "\t";
|
||||
break;
|
||||
}
|
||||
case "pipes": {
|
||||
delimiter = "|";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
params = Arrays.asList(values[0].split(delimiter));
|
||||
}
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
public static String parameterToString(Object param) {
|
||||
if (param == null) {
|
||||
return "";
|
||||
} else if (param instanceof Date) {
|
||||
return formatDatetime((Date) param);
|
||||
} else if (param instanceof Collection) {
|
||||
StringBuilder b = new StringBuilder();
|
||||
for (Object o : (Collection)param) {
|
||||
if (b.length() > 0) {
|
||||
b.append(",");
|
||||
}
|
||||
b.append(String.valueOf(o));
|
||||
}
|
||||
|
||||
return b.toString();
|
||||
} else {
|
||||
return String.valueOf(param);
|
||||
}
|
||||
}
|
||||
|
||||
public static String formatDatetime(Date date) {
|
||||
return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX").format(date);
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
name := """swagger-java-playframework"""
|
||||
|
||||
version := "1.0-SNAPSHOT"
|
||||
|
||||
lazy val root = (project in file(".")).enablePlugins(PlayJava)
|
||||
|
||||
scalaVersion := "2.12.2"
|
||||
|
||||
libraryDependencies += "org.webjars" % "swagger-ui" % "3.1.5"
|
||||
libraryDependencies += "javax.validation" % "validation-api" % "1.1.0.Final"
|
||||
libraryDependencies += guice
|
@ -0,0 +1,374 @@
|
||||
# This is the main configuration file for the application.
|
||||
# https://www.playframework.com/documentation/latest/ConfigFile
|
||||
# ~~~~~
|
||||
# Play uses HOCON as its configuration file format. HOCON has a number
|
||||
# of advantages over other config formats, but there are two things that
|
||||
# can be used when modifying settings.
|
||||
#
|
||||
# You can include other configuration files in this main application.conf file:
|
||||
#include "extra-config.conf"
|
||||
#
|
||||
# You can declare variables and substitute for them:
|
||||
#mykey = ${some.value}
|
||||
#
|
||||
# And if an environment variable exists when there is no other subsitution, then
|
||||
# HOCON will fall back to substituting environment variable:
|
||||
#mykey = ${JAVA_HOME}
|
||||
|
||||
play.filters.headers.contentSecurityPolicy=null
|
||||
|
||||
# When using bean validation with the swagger api, the validator will check that every constraint is respected
|
||||
# This is very useful when testing but could add a lot of overhead if you return a lot of data. Benchmark have
|
||||
# shown that the time it takes to validate is exponential.
|
||||
# If this is a concern in your application, or if you don't want to validate the output coming from your API for
|
||||
# respecting its contract, set the "output" property below to "false". Since there is not a lot of data as input for
|
||||
# an endpoint, I highly suggest you let the "input" property set to true.
|
||||
useInputBeanValidation=true
|
||||
useOutputBeanValidation=true
|
||||
|
||||
play.http.errorHandler="swagger.ErrorHandler"
|
||||
|
||||
## Akka
|
||||
# https://www.playframework.com/documentation/latest/ScalaAkka#Configuration
|
||||
# https://www.playframework.com/documentation/latest/JavaAkka#Configuration
|
||||
# ~~~~~
|
||||
# Play uses Akka internally and exposes Akka Streams and actors in Websockets and
|
||||
# other streaming HTTP responses.
|
||||
akka {
|
||||
# "akka.log-config-on-start" is extraordinarily useful because it log the complete
|
||||
# configuration at INFO level, including defaults and overrides, so it s worth
|
||||
# putting at the very top.
|
||||
#
|
||||
# Put the following in your conf/logback.xml file:
|
||||
#
|
||||
# <logger name="akka.actor" level="INFO" />
|
||||
#
|
||||
# And then uncomment this line to debug the configuration.
|
||||
#
|
||||
#log-config-on-start = true
|
||||
}
|
||||
|
||||
## Secret key
|
||||
# http://www.playframework.com/documentation/latest/ApplicationSecret
|
||||
# ~~~~~
|
||||
# The secret key is used to sign Play's session cookie.
|
||||
# This must be changed for production, but we don't recommend you change it in this file.
|
||||
play.http.secret.key = "changeme"
|
||||
|
||||
## Modules
|
||||
# https://www.playframework.com/documentation/latest/Modules
|
||||
# ~~~~~
|
||||
# Control which modules are loaded when Play starts. Note that modules are
|
||||
# the replacement for "GlobalSettings", which are deprecated in 2.5.x.
|
||||
# Please see https://www.playframework.com/documentation/latest/GlobalSettings
|
||||
# for more information.
|
||||
#
|
||||
# You can also extend Play functionality by using one of the publically available
|
||||
# Play modules: https://playframework.com/documentation/latest/ModuleDirectory
|
||||
play.modules {
|
||||
# By default, Play will load any class called Module that is defined
|
||||
# in the root package (the "app" directory), or you can define them
|
||||
# explicitly below.
|
||||
# If there are any built-in modules that you want to disable, you can list them here.
|
||||
}
|
||||
|
||||
play.assets {
|
||||
path = "/public"
|
||||
urlPrefix = "/assets"
|
||||
}
|
||||
|
||||
## IDE
|
||||
# https://www.playframework.com/documentation/latest/IDE
|
||||
# ~~~~~
|
||||
# Depending on your IDE, you can add a hyperlink for errors that will jump you
|
||||
# directly to the code location in the IDE in dev mode. The following line makes
|
||||
# use of the IntelliJ IDEA REST interface:
|
||||
#play.editor="http://localhost:63342/api/file/?file=%s&line=%s"
|
||||
|
||||
## Internationalisation
|
||||
# https://www.playframework.com/documentation/latest/JavaI18N
|
||||
# https://www.playframework.com/documentation/latest/ScalaI18N
|
||||
# ~~~~~
|
||||
# Play comes with its own i18n settings, which allow the user's preferred language
|
||||
# to map through to internal messages, or allow the language to be stored in a cookie.
|
||||
play.i18n {
|
||||
# The application languages
|
||||
langs = [ "en" ]
|
||||
|
||||
# Whether the language cookie should be secure or not
|
||||
#langCookieSecure = true
|
||||
|
||||
# Whether the HTTP only attribute of the cookie should be set to true
|
||||
#langCookieHttpOnly = true
|
||||
}
|
||||
|
||||
## Play HTTP settings
|
||||
# ~~~~~
|
||||
play.http {
|
||||
## Router
|
||||
# https://www.playframework.com/documentation/latest/JavaRouting
|
||||
# https://www.playframework.com/documentation/latest/ScalaRouting
|
||||
# ~~~~~
|
||||
# Define the Router object to use for this application.
|
||||
# This router will be looked up first when the application is starting up,
|
||||
# so make sure this is the entry point.
|
||||
# Furthermore, it's assumed your route file is named properly.
|
||||
# So for an application router like `my.application.Router`,
|
||||
# you may need to define a router file `conf/my.application.routes`.
|
||||
# Default to Routes in the root package (aka "apps" folder) (and conf/routes)
|
||||
#router = my.application.Router
|
||||
|
||||
## Action Creator
|
||||
# https://www.playframework.com/documentation/latest/JavaActionCreator
|
||||
# ~~~~~
|
||||
#actionCreator = null
|
||||
|
||||
## ErrorHandler
|
||||
# https://www.playframework.com/documentation/latest/JavaRouting
|
||||
# https://www.playframework.com/documentation/latest/ScalaRouting
|
||||
# ~~~~~
|
||||
# If null, will attempt to load a class called ErrorHandler in the root package,
|
||||
#errorHandler = null
|
||||
|
||||
## Filters
|
||||
# https://www.playframework.com/documentation/latest/ScalaHttpFilters
|
||||
# https://www.playframework.com/documentation/latest/JavaHttpFilters
|
||||
# ~~~~~
|
||||
# Filters run code on every request. They can be used to perform
|
||||
# common logic for all your actions, e.g. adding common headers.
|
||||
# Defaults to "Filters" in the root package (aka "apps" folder)
|
||||
# Alternatively you can explicitly register a class here.
|
||||
#filters = my.application.Filters
|
||||
|
||||
## Session & Flash
|
||||
# https://www.playframework.com/documentation/latest/JavaSessionFlash
|
||||
# https://www.playframework.com/documentation/latest/ScalaSessionFlash
|
||||
# ~~~~~
|
||||
session {
|
||||
# Sets the cookie to be sent only over HTTPS.
|
||||
#secure = true
|
||||
|
||||
# Sets the cookie to be accessed only by the server.
|
||||
#httpOnly = true
|
||||
|
||||
# Sets the max-age field of the cookie to 5 minutes.
|
||||
# NOTE: this only sets when the browser will discard the cookie. Play will consider any
|
||||
# cookie value with a valid signature to be a valid session forever. To implement a server side session timeout,
|
||||
# you need to put a timestamp in the session and check it at regular intervals to possibly expire it.
|
||||
#maxAge = 300
|
||||
|
||||
# Sets the domain on the session cookie.
|
||||
#domain = "example.com"
|
||||
}
|
||||
|
||||
flash {
|
||||
# Sets the cookie to be sent only over HTTPS.
|
||||
#secure = true
|
||||
|
||||
# Sets the cookie to be accessed only by the server.
|
||||
#httpOnly = true
|
||||
}
|
||||
}
|
||||
|
||||
## Netty Provider
|
||||
# https://www.playframework.com/documentation/latest/SettingsNetty
|
||||
# ~~~~~
|
||||
play.server.netty {
|
||||
# Whether the Netty wire should be logged
|
||||
#log.wire = true
|
||||
|
||||
# If you run Play on Linux, you can use Netty's native socket transport
|
||||
# for higher performance with less garbage.
|
||||
#transport = "native"
|
||||
}
|
||||
|
||||
## WS (HTTP Client)
|
||||
# https://www.playframework.com/documentation/latest/ScalaWS#Configuring-WS
|
||||
# ~~~~~
|
||||
# The HTTP client primarily used for REST APIs. The default client can be
|
||||
# configured directly, but you can also create different client instances
|
||||
# with customized settings. You must enable this by adding to build.sbt:
|
||||
#
|
||||
# libraryDependencies += ws // or javaWs if using java
|
||||
#
|
||||
play.ws {
|
||||
# Sets HTTP requests not to follow 302 requests
|
||||
#followRedirects = false
|
||||
|
||||
# Sets the maximum number of open HTTP connections for the client.
|
||||
#ahc.maxConnectionsTotal = 50
|
||||
|
||||
## WS SSL
|
||||
# https://www.playframework.com/documentation/latest/WsSSL
|
||||
# ~~~~~
|
||||
ssl {
|
||||
# Configuring HTTPS with Play WS does not require programming. You can
|
||||
# set up both trustManager and keyManager for mutual authentication, and
|
||||
# turn on JSSE debugging in development with a reload.
|
||||
#debug.handshake = true
|
||||
#trustManager = {
|
||||
# stores = [
|
||||
# { type = "JKS", path = "exampletrust.jks" }
|
||||
# ]
|
||||
#}
|
||||
}
|
||||
}
|
||||
|
||||
## Cache
|
||||
# https://www.playframework.com/documentation/latest/JavaCache
|
||||
# https://www.playframework.com/documentation/latest/ScalaCache
|
||||
# ~~~~~
|
||||
# Play comes with an integrated cache API that can reduce the operational
|
||||
# overhead of repeated requests. You must enable this by adding to build.sbt:
|
||||
#
|
||||
# libraryDependencies += cache
|
||||
#
|
||||
play.cache {
|
||||
# If you want to bind several caches, you can bind the individually
|
||||
#bindCaches = ["db-cache", "user-cache", "session-cache"]
|
||||
}
|
||||
|
||||
## Filters
|
||||
# https://www.playframework.com/documentation/latest/Filters
|
||||
# ~~~~~
|
||||
# There are a number of built-in filters that can be enabled and configured
|
||||
# to give Play greater security. You must enable this by adding to build.sbt:
|
||||
#
|
||||
# libraryDependencies += filters
|
||||
#
|
||||
play.filters {
|
||||
## CORS filter configuration
|
||||
# https://www.playframework.com/documentation/latest/CorsFilter
|
||||
# ~~~~~
|
||||
# CORS is a protocol that allows web applications to make requests from the browser
|
||||
# across different domains.
|
||||
# NOTE: You MUST apply the CORS configuration before the CSRF filter, as CSRF has
|
||||
# dependencies on CORS settings.
|
||||
cors {
|
||||
# Filter paths by a whitelist of path prefixes
|
||||
#pathPrefixes = ["/some/path", ...]
|
||||
|
||||
# The allowed origins. If null, all origins are allowed.
|
||||
#allowedOrigins = ["http://www.example.com"]
|
||||
|
||||
# The allowed HTTP methods. If null, all methods are allowed
|
||||
#allowedHttpMethods = ["GET", "POST"]
|
||||
}
|
||||
|
||||
## CSRF Filter
|
||||
# https://www.playframework.com/documentation/latest/ScalaCsrf#Applying-a-global-CSRF-filter
|
||||
# https://www.playframework.com/documentation/latest/JavaCsrf#Applying-a-global-CSRF-filter
|
||||
# ~~~~~
|
||||
# Play supports multiple methods for verifying that a request is not a CSRF request.
|
||||
# The primary mechanism is a CSRF token. This token gets placed either in the query string
|
||||
# or body of every form submitted, and also gets placed in the users session.
|
||||
# Play then verifies that both tokens are present and match.
|
||||
csrf {
|
||||
# Sets the cookie to be sent only over HTTPS
|
||||
#cookie.secure = true
|
||||
|
||||
# Defaults to CSRFErrorHandler in the root package.
|
||||
#errorHandler = MyCSRFErrorHandler
|
||||
}
|
||||
|
||||
## Security headers filter configuration
|
||||
# https://www.playframework.com/documentation/latest/SecurityHeaders
|
||||
# ~~~~~
|
||||
# Defines security headers that prevent XSS attacks.
|
||||
# If enabled, then all options are set to the below configuration by default:
|
||||
play.filters.headers {
|
||||
|
||||
# The X-Frame-Options header. If null, the header is not set.
|
||||
#frameOptions = "DENY"
|
||||
|
||||
# The X-XSS-Protection header. If null, the header is not set.
|
||||
#xssProtection = "1; mode=block"
|
||||
|
||||
# The X-Content-Type-Options header. If null, the header is not set.
|
||||
#contentTypeOptions = "nosniff"
|
||||
|
||||
# The X-Permitted-Cross-Domain-Policies header. If null, the header is not set.
|
||||
#permittedCrossDomainPolicies = "master-only"
|
||||
|
||||
# The Content-Security-Policy header. If null, the header is not set.
|
||||
contentSecurityPolicy = "default-src 'self'"
|
||||
|
||||
# The Referrer-Policy header. If null, the header is not set.
|
||||
#referrerPolicy = "origin-when-cross-origin, strict-origin-when-cross-origin"
|
||||
|
||||
# If true, allow an action to use .withHeaders to replace one or more of the above headers
|
||||
#allowActionSpecificHeaders = false
|
||||
}
|
||||
|
||||
## Allowed hosts filter configuration
|
||||
# https://www.playframework.com/documentation/latest/AllowedHostsFilter
|
||||
# ~~~~~
|
||||
# Play provides a filter that lets you configure which hosts can access your application.
|
||||
# This is useful to prevent cache poisoning attacks.
|
||||
hosts {
|
||||
# Allow requests to example.com, its subdomains, and localhost:9000.
|
||||
#allowed = [".example.com", "localhost:9000"]
|
||||
}
|
||||
}
|
||||
|
||||
## Evolutions
|
||||
# https://www.playframework.com/documentation/latest/Evolutions
|
||||
# ~~~~~
|
||||
# Evolutions allows database scripts to be automatically run on startup in dev mode
|
||||
# for database migrations. You must enable this by adding to build.sbt:
|
||||
#
|
||||
# libraryDependencies += evolutions
|
||||
#
|
||||
play.evolutions {
|
||||
# You can disable evolutions for a specific datasource if necessary
|
||||
#db.default.enabled = false
|
||||
}
|
||||
|
||||
## Database Connection Pool
|
||||
# https://www.playframework.com/documentation/latest/SettingsJDBC
|
||||
# ~~~~~
|
||||
# Play doesn't require a JDBC database to run, but you can easily enable one.
|
||||
#
|
||||
# libraryDependencies += jdbc
|
||||
#
|
||||
play.db {
|
||||
# The combination of these two settings results in "db.default" as the
|
||||
# default JDBC pool:
|
||||
#config = "db"
|
||||
#default = "default"
|
||||
|
||||
# Play uses HikariCP as the default connection pool. You can override
|
||||
# settings by changing the prototype:
|
||||
prototype {
|
||||
# Sets a fixed JDBC connection pool size of 50
|
||||
#hikaricp.minimumIdle = 50
|
||||
#hikaricp.maximumPoolSize = 50
|
||||
}
|
||||
}
|
||||
|
||||
## JDBC Datasource
|
||||
# https://www.playframework.com/documentation/latest/JavaDatabase
|
||||
# https://www.playframework.com/documentation/latest/ScalaDatabase
|
||||
# ~~~~~
|
||||
# Once JDBC datasource is set up, you can work with several different
|
||||
# database options:
|
||||
#
|
||||
# Slick (Scala preferred option): https://www.playframework.com/documentation/latest/PlaySlick
|
||||
# JPA (Java preferred option): https://playframework.com/documentation/latest/JavaJPA
|
||||
# EBean: https://playframework.com/documentation/latest/JavaEbean
|
||||
# Anorm: https://www.playframework.com/documentation/latest/ScalaAnorm
|
||||
#
|
||||
db {
|
||||
# You can declare as many datasources as you want.
|
||||
# By convention, the default datasource is named `default`
|
||||
|
||||
# https://www.playframework.com/documentation/latest/Developing-with-the-H2-Database
|
||||
#default.driver = org.h2.Driver
|
||||
#default.url = "jdbc:h2:mem:play"
|
||||
#default.username = sa
|
||||
#default.password = ""
|
||||
|
||||
# You can turn on SQL logging for any datasource
|
||||
# https://www.playframework.com/documentation/latest/Highlights25#Logging-SQL-statements
|
||||
#default.logSql=true
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
<!-- https://www.playframework.com/documentation/latest/SettingsLogger -->
|
||||
<configuration>
|
||||
|
||||
<conversionRule conversionWord="coloredLevel" converterClass="play.api.libs.logback.ColoredLevel" />
|
||||
|
||||
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
|
||||
<file>${application.home:-.}/logs/application.log</file>
|
||||
<encoder>
|
||||
<pattern>%date [%level] from %logger in %thread - %message%n%xException</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%coloredLevel %logger{15} - %message%n%xException{10}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<appender name="ASYNCFILE" class="ch.qos.logback.classic.AsyncAppender">
|
||||
<appender-ref ref="FILE" />
|
||||
</appender>
|
||||
|
||||
<appender name="ASYNCSTDOUT" class="ch.qos.logback.classic.AsyncAppender">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</appender>
|
||||
|
||||
<logger name="play" level="INFO" />
|
||||
<logger name="application" level="DEBUG" />
|
||||
|
||||
<!-- Off these ones as they are annoying, and anyway we manage configuration ourselves -->
|
||||
<logger name="com.avaje.ebean.config.PropertyMapLoader" level="OFF" />
|
||||
<logger name="com.avaje.ebeaninternal.server.core.XmlConfigLoader" level="OFF" />
|
||||
<logger name="com.avaje.ebeaninternal.server.lib.BackgroundThread" level="OFF" />
|
||||
<logger name="com.gargoylesoftware.htmlunit.javascript" level="OFF" />
|
||||
|
||||
<root level="WARN">
|
||||
<appender-ref ref="ASYNCFILE" />
|
||||
<appender-ref ref="ASYNCSTDOUT" />
|
||||
</root>
|
||||
|
||||
</configuration>
|
@ -0,0 +1,36 @@
|
||||
# Routes
|
||||
# This file defines all application routes (Higher priority routes first)
|
||||
# ~~~~
|
||||
|
||||
GET /api com.puppies.store.apis.ApiDocController.api
|
||||
|
||||
|
||||
#Functions for Pet API
|
||||
POST /v2/pet com.puppies.store.apis.PetApiController.addPet()
|
||||
DELETE /v2/pet/:petId com.puppies.store.apis.PetApiController.deletePet(petId: Long)
|
||||
GET /v2/pet/findByStatus com.puppies.store.apis.PetApiController.findPetsByStatus()
|
||||
GET /v2/pet/findByTags com.puppies.store.apis.PetApiController.findPetsByTags()
|
||||
GET /v2/pet/:petId com.puppies.store.apis.PetApiController.getPetById(petId: Long)
|
||||
PUT /v2/pet com.puppies.store.apis.PetApiController.updatePet()
|
||||
POST /v2/pet/:petId com.puppies.store.apis.PetApiController.updatePetWithForm(petId: Long)
|
||||
POST /v2/pet/:petId/uploadImage com.puppies.store.apis.PetApiController.uploadFile(petId: Long)
|
||||
|
||||
#Functions for Store API
|
||||
DELETE /v2/store/order/:orderId com.puppies.store.apis.StoreApiController.deleteOrder(orderId: String)
|
||||
GET /v2/store/inventory com.puppies.store.apis.StoreApiController.getInventory()
|
||||
GET /v2/store/order/:orderId com.puppies.store.apis.StoreApiController.getOrderById(orderId: Long)
|
||||
POST /v2/store/order com.puppies.store.apis.StoreApiController.placeOrder()
|
||||
|
||||
#Functions for User API
|
||||
POST /v2/user com.puppies.store.apis.UserApiController.createUser()
|
||||
POST /v2/user/createWithArray com.puppies.store.apis.UserApiController.createUsersWithArrayInput()
|
||||
POST /v2/user/createWithList com.puppies.store.apis.UserApiController.createUsersWithListInput()
|
||||
DELETE /v2/user/:username com.puppies.store.apis.UserApiController.deleteUser(username: String)
|
||||
GET /v2/user/:username com.puppies.store.apis.UserApiController.getUserByName(username: String)
|
||||
GET /v2/user/login com.puppies.store.apis.UserApiController.loginUser()
|
||||
GET /v2/user/logout com.puppies.store.apis.UserApiController.logoutUser()
|
||||
PUT /v2/user/:username com.puppies.store.apis.UserApiController.updateUser(username: String)
|
||||
|
||||
# Map static resources from the /public folder to the /assets URL path
|
||||
GET /assets/*file controllers.Assets.at(file)
|
||||
GET /versionedAssets/*file controllers.Assets.versioned(file)
|
@ -0,0 +1 @@
|
||||
sbt.version=0.13.15
|
@ -0,0 +1,2 @@
|
||||
// The Play plugin
|
||||
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.6.3")
|
@ -0,0 +1,908 @@
|
||||
{
|
||||
"swagger" : "2.0",
|
||||
"info" : {
|
||||
"description" : "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.",
|
||||
"version" : "1.0.0",
|
||||
"title" : "Swagger Petstore",
|
||||
"termsOfService" : "http://swagger.io/terms/",
|
||||
"contact" : {
|
||||
"email" : "apiteam@swagger.io"
|
||||
},
|
||||
"license" : {
|
||||
"name" : "Apache-2.0",
|
||||
"url" : "http://www.apache.org/licenses/LICENSE-2.0.html"
|
||||
}
|
||||
},
|
||||
"host" : "petstore.swagger.io",
|
||||
"basePath" : "/v2",
|
||||
"tags" : [ {
|
||||
"name" : "pet",
|
||||
"description" : "Everything about your Pets",
|
||||
"externalDocs" : {
|
||||
"description" : "Find out more",
|
||||
"url" : "http://swagger.io"
|
||||
}
|
||||
}, {
|
||||
"name" : "store",
|
||||
"description" : "Access to Petstore orders"
|
||||
}, {
|
||||
"name" : "user",
|
||||
"description" : "Operations about user",
|
||||
"externalDocs" : {
|
||||
"description" : "Find out more about our store",
|
||||
"url" : "http://swagger.io"
|
||||
}
|
||||
} ],
|
||||
"schemes" : [ "http" ],
|
||||
"paths" : {
|
||||
"/pet" : {
|
||||
"post" : {
|
||||
"tags" : [ "pet" ],
|
||||
"summary" : "Add a new pet to the store",
|
||||
"description" : "",
|
||||
"operationId" : "addPet",
|
||||
"consumes" : [ "application/json", "application/xml" ],
|
||||
"produces" : [ "application/xml", "application/json" ],
|
||||
"parameters" : [ {
|
||||
"in" : "body",
|
||||
"name" : "body",
|
||||
"description" : "Pet object that needs to be added to the store",
|
||||
"required" : true,
|
||||
"schema" : {
|
||||
"$ref" : "#/definitions/Pet"
|
||||
}
|
||||
} ],
|
||||
"responses" : {
|
||||
"405" : {
|
||||
"description" : "Invalid input"
|
||||
}
|
||||
},
|
||||
"security" : [ {
|
||||
"petstore_auth" : [ "write:pets", "read:pets" ]
|
||||
} ],
|
||||
"x-contentType" : "application/json",
|
||||
"x-accepts" : "application/json"
|
||||
},
|
||||
"put" : {
|
||||
"tags" : [ "pet" ],
|
||||
"summary" : "Update an existing pet",
|
||||
"description" : "",
|
||||
"operationId" : "updatePet",
|
||||
"consumes" : [ "application/json", "application/xml" ],
|
||||
"produces" : [ "application/xml", "application/json" ],
|
||||
"parameters" : [ {
|
||||
"in" : "body",
|
||||
"name" : "body",
|
||||
"description" : "Pet object that needs to be added to the store",
|
||||
"required" : true,
|
||||
"schema" : {
|
||||
"$ref" : "#/definitions/Pet"
|
||||
}
|
||||
} ],
|
||||
"responses" : {
|
||||
"400" : {
|
||||
"description" : "Invalid ID supplied"
|
||||
},
|
||||
"404" : {
|
||||
"description" : "Pet not found"
|
||||
},
|
||||
"405" : {
|
||||
"description" : "Validation exception"
|
||||
}
|
||||
},
|
||||
"security" : [ {
|
||||
"petstore_auth" : [ "write:pets", "read:pets" ]
|
||||
} ],
|
||||
"x-contentType" : "application/json",
|
||||
"x-accepts" : "application/json"
|
||||
}
|
||||
},
|
||||
"/pet/findByStatus" : {
|
||||
"get" : {
|
||||
"tags" : [ "pet" ],
|
||||
"summary" : "Finds Pets by status",
|
||||
"description" : "Multiple status values can be provided with comma separated strings",
|
||||
"operationId" : "findPetsByStatus",
|
||||
"produces" : [ "application/xml", "application/json" ],
|
||||
"parameters" : [ {
|
||||
"name" : "status",
|
||||
"in" : "query",
|
||||
"description" : "Status values that need to be considered for filter",
|
||||
"required" : true,
|
||||
"type" : "array",
|
||||
"items" : {
|
||||
"type" : "string",
|
||||
"default" : "available",
|
||||
"enum" : [ "available", "pending", "sold" ]
|
||||
},
|
||||
"collectionFormat" : "csv"
|
||||
} ],
|
||||
"responses" : {
|
||||
"200" : {
|
||||
"description" : "successful operation",
|
||||
"schema" : {
|
||||
"type" : "array",
|
||||
"items" : {
|
||||
"$ref" : "#/definitions/Pet"
|
||||
}
|
||||
}
|
||||
},
|
||||
"400" : {
|
||||
"description" : "Invalid status value"
|
||||
}
|
||||
},
|
||||
"security" : [ {
|
||||
"petstore_auth" : [ "write:pets", "read:pets" ]
|
||||
} ],
|
||||
"x-accepts" : "application/json"
|
||||
}
|
||||
},
|
||||
"/pet/findByTags" : {
|
||||
"get" : {
|
||||
"tags" : [ "pet" ],
|
||||
"summary" : "Finds Pets by tags",
|
||||
"description" : "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.",
|
||||
"operationId" : "findPetsByTags",
|
||||
"produces" : [ "application/xml", "application/json" ],
|
||||
"parameters" : [ {
|
||||
"name" : "tags",
|
||||
"in" : "query",
|
||||
"description" : "Tags to filter by",
|
||||
"required" : true,
|
||||
"type" : "array",
|
||||
"items" : {
|
||||
"type" : "string"
|
||||
},
|
||||
"collectionFormat" : "csv"
|
||||
} ],
|
||||
"responses" : {
|
||||
"200" : {
|
||||
"description" : "successful operation",
|
||||
"schema" : {
|
||||
"type" : "array",
|
||||
"items" : {
|
||||
"$ref" : "#/definitions/Pet"
|
||||
}
|
||||
}
|
||||
},
|
||||
"400" : {
|
||||
"description" : "Invalid tag value"
|
||||
}
|
||||
},
|
||||
"security" : [ {
|
||||
"petstore_auth" : [ "write:pets", "read:pets" ]
|
||||
} ],
|
||||
"deprecated" : true,
|
||||
"x-accepts" : "application/json"
|
||||
}
|
||||
},
|
||||
"/pet/{petId}" : {
|
||||
"get" : {
|
||||
"tags" : [ "pet" ],
|
||||
"summary" : "Find pet by ID",
|
||||
"description" : "Returns a single pet",
|
||||
"operationId" : "getPetById",
|
||||
"produces" : [ "application/xml", "application/json" ],
|
||||
"parameters" : [ {
|
||||
"name" : "petId",
|
||||
"in" : "path",
|
||||
"description" : "ID of pet to return",
|
||||
"required" : true,
|
||||
"type" : "integer",
|
||||
"format" : "int64"
|
||||
} ],
|
||||
"responses" : {
|
||||
"200" : {
|
||||
"description" : "successful operation",
|
||||
"schema" : {
|
||||
"$ref" : "#/definitions/Pet"
|
||||
}
|
||||
},
|
||||
"400" : {
|
||||
"description" : "Invalid ID supplied"
|
||||
},
|
||||
"404" : {
|
||||
"description" : "Pet not found"
|
||||
}
|
||||
},
|
||||
"security" : [ {
|
||||
"api_key" : [ ]
|
||||
} ],
|
||||
"x-accepts" : "application/json"
|
||||
},
|
||||
"post" : {
|
||||
"tags" : [ "pet" ],
|
||||
"summary" : "Updates a pet in the store with form data",
|
||||
"description" : "",
|
||||
"operationId" : "updatePetWithForm",
|
||||
"consumes" : [ "application/x-www-form-urlencoded" ],
|
||||
"produces" : [ "application/xml", "application/json" ],
|
||||
"parameters" : [ {
|
||||
"name" : "petId",
|
||||
"in" : "path",
|
||||
"description" : "ID of pet that needs to be updated",
|
||||
"required" : true,
|
||||
"type" : "integer",
|
||||
"format" : "int64"
|
||||
}, {
|
||||
"name" : "name",
|
||||
"in" : "formData",
|
||||
"description" : "Updated name of the pet",
|
||||
"required" : false,
|
||||
"type" : "string"
|
||||
}, {
|
||||
"name" : "status",
|
||||
"in" : "formData",
|
||||
"description" : "Updated status of the pet",
|
||||
"required" : false,
|
||||
"type" : "string"
|
||||
} ],
|
||||
"responses" : {
|
||||
"405" : {
|
||||
"description" : "Invalid input"
|
||||
}
|
||||
},
|
||||
"security" : [ {
|
||||
"petstore_auth" : [ "write:pets", "read:pets" ]
|
||||
} ],
|
||||
"x-contentType" : "application/x-www-form-urlencoded",
|
||||
"x-accepts" : "application/json"
|
||||
},
|
||||
"delete" : {
|
||||
"tags" : [ "pet" ],
|
||||
"summary" : "Deletes a pet",
|
||||
"description" : "",
|
||||
"operationId" : "deletePet",
|
||||
"produces" : [ "application/xml", "application/json" ],
|
||||
"parameters" : [ {
|
||||
"name" : "api_key",
|
||||
"in" : "header",
|
||||
"required" : false,
|
||||
"type" : "string"
|
||||
}, {
|
||||
"name" : "petId",
|
||||
"in" : "path",
|
||||
"description" : "Pet id to delete",
|
||||
"required" : true,
|
||||
"type" : "integer",
|
||||
"format" : "int64"
|
||||
} ],
|
||||
"responses" : {
|
||||
"400" : {
|
||||
"description" : "Invalid pet value"
|
||||
}
|
||||
},
|
||||
"security" : [ {
|
||||
"petstore_auth" : [ "write:pets", "read:pets" ]
|
||||
} ],
|
||||
"x-accepts" : "application/json"
|
||||
}
|
||||
},
|
||||
"/pet/{petId}/uploadImage" : {
|
||||
"post" : {
|
||||
"tags" : [ "pet" ],
|
||||
"summary" : "uploads an image",
|
||||
"description" : "",
|
||||
"operationId" : "uploadFile",
|
||||
"consumes" : [ "multipart/form-data" ],
|
||||
"produces" : [ "application/json" ],
|
||||
"parameters" : [ {
|
||||
"name" : "petId",
|
||||
"in" : "path",
|
||||
"description" : "ID of pet to update",
|
||||
"required" : true,
|
||||
"type" : "integer",
|
||||
"format" : "int64"
|
||||
}, {
|
||||
"name" : "additionalMetadata",
|
||||
"in" : "formData",
|
||||
"description" : "Additional data to pass to server",
|
||||
"required" : false,
|
||||
"type" : "string"
|
||||
}, {
|
||||
"name" : "file",
|
||||
"in" : "formData",
|
||||
"description" : "file to upload",
|
||||
"required" : false,
|
||||
"type" : "file"
|
||||
} ],
|
||||
"responses" : {
|
||||
"200" : {
|
||||
"description" : "successful operation",
|
||||
"schema" : {
|
||||
"$ref" : "#/definitions/ApiResponse"
|
||||
}
|
||||
}
|
||||
},
|
||||
"security" : [ {
|
||||
"petstore_auth" : [ "write:pets", "read:pets" ]
|
||||
} ],
|
||||
"x-contentType" : "multipart/form-data",
|
||||
"x-accepts" : "application/json"
|
||||
}
|
||||
},
|
||||
"/store/inventory" : {
|
||||
"get" : {
|
||||
"tags" : [ "store" ],
|
||||
"summary" : "Returns pet inventories by status",
|
||||
"description" : "Returns a map of status codes to quantities",
|
||||
"operationId" : "getInventory",
|
||||
"produces" : [ "application/json" ],
|
||||
"parameters" : [ ],
|
||||
"responses" : {
|
||||
"200" : {
|
||||
"description" : "successful operation",
|
||||
"schema" : {
|
||||
"type" : "object",
|
||||
"additionalProperties" : {
|
||||
"type" : "integer",
|
||||
"format" : "int32"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"security" : [ {
|
||||
"api_key" : [ ]
|
||||
} ],
|
||||
"x-accepts" : "application/json"
|
||||
}
|
||||
},
|
||||
"/store/order" : {
|
||||
"post" : {
|
||||
"tags" : [ "store" ],
|
||||
"summary" : "Place an order for a pet",
|
||||
"description" : "",
|
||||
"operationId" : "placeOrder",
|
||||
"produces" : [ "application/xml", "application/json" ],
|
||||
"parameters" : [ {
|
||||
"in" : "body",
|
||||
"name" : "body",
|
||||
"description" : "order placed for purchasing the pet",
|
||||
"required" : true,
|
||||
"schema" : {
|
||||
"$ref" : "#/definitions/Order"
|
||||
}
|
||||
} ],
|
||||
"responses" : {
|
||||
"200" : {
|
||||
"description" : "successful operation",
|
||||
"schema" : {
|
||||
"$ref" : "#/definitions/Order"
|
||||
}
|
||||
},
|
||||
"400" : {
|
||||
"description" : "Invalid Order"
|
||||
}
|
||||
},
|
||||
"x-contentType" : "application/json",
|
||||
"x-accepts" : "application/json"
|
||||
}
|
||||
},
|
||||
"/store/order/{orderId}" : {
|
||||
"get" : {
|
||||
"tags" : [ "store" ],
|
||||
"summary" : "Find purchase order by ID",
|
||||
"description" : "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions",
|
||||
"operationId" : "getOrderById",
|
||||
"produces" : [ "application/xml", "application/json" ],
|
||||
"parameters" : [ {
|
||||
"name" : "orderId",
|
||||
"in" : "path",
|
||||
"description" : "ID of pet that needs to be fetched",
|
||||
"required" : true,
|
||||
"type" : "integer",
|
||||
"maximum" : 5,
|
||||
"minimum" : 1,
|
||||
"format" : "int64"
|
||||
} ],
|
||||
"responses" : {
|
||||
"200" : {
|
||||
"description" : "successful operation",
|
||||
"schema" : {
|
||||
"$ref" : "#/definitions/Order"
|
||||
}
|
||||
},
|
||||
"400" : {
|
||||
"description" : "Invalid ID supplied"
|
||||
},
|
||||
"404" : {
|
||||
"description" : "Order not found"
|
||||
}
|
||||
},
|
||||
"x-accepts" : "application/json"
|
||||
},
|
||||
"delete" : {
|
||||
"tags" : [ "store" ],
|
||||
"summary" : "Delete purchase order by ID",
|
||||
"description" : "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors",
|
||||
"operationId" : "deleteOrder",
|
||||
"produces" : [ "application/xml", "application/json" ],
|
||||
"parameters" : [ {
|
||||
"name" : "orderId",
|
||||
"in" : "path",
|
||||
"description" : "ID of the order that needs to be deleted",
|
||||
"required" : true,
|
||||
"type" : "string"
|
||||
} ],
|
||||
"responses" : {
|
||||
"400" : {
|
||||
"description" : "Invalid ID supplied"
|
||||
},
|
||||
"404" : {
|
||||
"description" : "Order not found"
|
||||
}
|
||||
},
|
||||
"x-accepts" : "application/json"
|
||||
}
|
||||
},
|
||||
"/user" : {
|
||||
"post" : {
|
||||
"tags" : [ "user" ],
|
||||
"summary" : "Create user",
|
||||
"description" : "This can only be done by the logged in user.",
|
||||
"operationId" : "createUser",
|
||||
"produces" : [ "application/xml", "application/json" ],
|
||||
"parameters" : [ {
|
||||
"in" : "body",
|
||||
"name" : "body",
|
||||
"description" : "Created user object",
|
||||
"required" : true,
|
||||
"schema" : {
|
||||
"$ref" : "#/definitions/User"
|
||||
}
|
||||
} ],
|
||||
"responses" : {
|
||||
"default" : {
|
||||
"description" : "successful operation"
|
||||
}
|
||||
},
|
||||
"x-contentType" : "application/json",
|
||||
"x-accepts" : "application/json"
|
||||
}
|
||||
},
|
||||
"/user/createWithArray" : {
|
||||
"post" : {
|
||||
"tags" : [ "user" ],
|
||||
"summary" : "Creates list of users with given input array",
|
||||
"description" : "",
|
||||
"operationId" : "createUsersWithArrayInput",
|
||||
"produces" : [ "application/xml", "application/json" ],
|
||||
"parameters" : [ {
|
||||
"in" : "body",
|
||||
"name" : "body",
|
||||
"description" : "List of user object",
|
||||
"required" : true,
|
||||
"schema" : {
|
||||
"type" : "array",
|
||||
"items" : {
|
||||
"$ref" : "#/definitions/User"
|
||||
}
|
||||
}
|
||||
} ],
|
||||
"responses" : {
|
||||
"default" : {
|
||||
"description" : "successful operation"
|
||||
}
|
||||
},
|
||||
"x-contentType" : "application/json",
|
||||
"x-accepts" : "application/json"
|
||||
}
|
||||
},
|
||||
"/user/createWithList" : {
|
||||
"post" : {
|
||||
"tags" : [ "user" ],
|
||||
"summary" : "Creates list of users with given input array",
|
||||
"description" : "",
|
||||
"operationId" : "createUsersWithListInput",
|
||||
"produces" : [ "application/xml", "application/json" ],
|
||||
"parameters" : [ {
|
||||
"in" : "body",
|
||||
"name" : "body",
|
||||
"description" : "List of user object",
|
||||
"required" : true,
|
||||
"schema" : {
|
||||
"type" : "array",
|
||||
"items" : {
|
||||
"$ref" : "#/definitions/User"
|
||||
}
|
||||
}
|
||||
} ],
|
||||
"responses" : {
|
||||
"default" : {
|
||||
"description" : "successful operation"
|
||||
}
|
||||
},
|
||||
"x-contentType" : "application/json",
|
||||
"x-accepts" : "application/json"
|
||||
}
|
||||
},
|
||||
"/user/login" : {
|
||||
"get" : {
|
||||
"tags" : [ "user" ],
|
||||
"summary" : "Logs user into the system",
|
||||
"description" : "",
|
||||
"operationId" : "loginUser",
|
||||
"produces" : [ "application/xml", "application/json" ],
|
||||
"parameters" : [ {
|
||||
"name" : "username",
|
||||
"in" : "query",
|
||||
"description" : "The user name for login",
|
||||
"required" : true,
|
||||
"type" : "string"
|
||||
}, {
|
||||
"name" : "password",
|
||||
"in" : "query",
|
||||
"description" : "The password for login in clear text",
|
||||
"required" : true,
|
||||
"type" : "string"
|
||||
} ],
|
||||
"responses" : {
|
||||
"200" : {
|
||||
"description" : "successful operation",
|
||||
"schema" : {
|
||||
"type" : "string"
|
||||
},
|
||||
"headers" : {
|
||||
"X-Rate-Limit" : {
|
||||
"type" : "integer",
|
||||
"format" : "int32",
|
||||
"description" : "calls per hour allowed by the user"
|
||||
},
|
||||
"X-Expires-After" : {
|
||||
"type" : "string",
|
||||
"format" : "date-time",
|
||||
"description" : "date in UTC when toekn expires"
|
||||
}
|
||||
}
|
||||
},
|
||||
"400" : {
|
||||
"description" : "Invalid username/password supplied"
|
||||
}
|
||||
},
|
||||
"x-accepts" : "application/json"
|
||||
}
|
||||
},
|
||||
"/user/logout" : {
|
||||
"get" : {
|
||||
"tags" : [ "user" ],
|
||||
"summary" : "Logs out current logged in user session",
|
||||
"description" : "",
|
||||
"operationId" : "logoutUser",
|
||||
"produces" : [ "application/xml", "application/json" ],
|
||||
"parameters" : [ ],
|
||||
"responses" : {
|
||||
"default" : {
|
||||
"description" : "successful operation"
|
||||
}
|
||||
},
|
||||
"x-accepts" : "application/json"
|
||||
}
|
||||
},
|
||||
"/user/{username}" : {
|
||||
"get" : {
|
||||
"tags" : [ "user" ],
|
||||
"summary" : "Get user by user name",
|
||||
"description" : "",
|
||||
"operationId" : "getUserByName",
|
||||
"produces" : [ "application/xml", "application/json" ],
|
||||
"parameters" : [ {
|
||||
"name" : "username",
|
||||
"in" : "path",
|
||||
"description" : "The name that needs to be fetched. Use user1 for testing. ",
|
||||
"required" : true,
|
||||
"type" : "string"
|
||||
} ],
|
||||
"responses" : {
|
||||
"200" : {
|
||||
"description" : "successful operation",
|
||||
"schema" : {
|
||||
"$ref" : "#/definitions/User"
|
||||
}
|
||||
},
|
||||
"400" : {
|
||||
"description" : "Invalid username supplied"
|
||||
},
|
||||
"404" : {
|
||||
"description" : "User not found"
|
||||
}
|
||||
},
|
||||
"x-accepts" : "application/json"
|
||||
},
|
||||
"put" : {
|
||||
"tags" : [ "user" ],
|
||||
"summary" : "Updated user",
|
||||
"description" : "This can only be done by the logged in user.",
|
||||
"operationId" : "updateUser",
|
||||
"produces" : [ "application/xml", "application/json" ],
|
||||
"parameters" : [ {
|
||||
"name" : "username",
|
||||
"in" : "path",
|
||||
"description" : "name that need to be deleted",
|
||||
"required" : true,
|
||||
"type" : "string"
|
||||
}, {
|
||||
"in" : "body",
|
||||
"name" : "body",
|
||||
"description" : "Updated user object",
|
||||
"required" : true,
|
||||
"schema" : {
|
||||
"$ref" : "#/definitions/User"
|
||||
}
|
||||
} ],
|
||||
"responses" : {
|
||||
"400" : {
|
||||
"description" : "Invalid user supplied"
|
||||
},
|
||||
"404" : {
|
||||
"description" : "User not found"
|
||||
}
|
||||
},
|
||||
"x-contentType" : "application/json",
|
||||
"x-accepts" : "application/json"
|
||||
},
|
||||
"delete" : {
|
||||
"tags" : [ "user" ],
|
||||
"summary" : "Delete user",
|
||||
"description" : "This can only be done by the logged in user.",
|
||||
"operationId" : "deleteUser",
|
||||
"produces" : [ "application/xml", "application/json" ],
|
||||
"parameters" : [ {
|
||||
"name" : "username",
|
||||
"in" : "path",
|
||||
"description" : "The name that needs to be deleted",
|
||||
"required" : true,
|
||||
"type" : "string"
|
||||
} ],
|
||||
"responses" : {
|
||||
"400" : {
|
||||
"description" : "Invalid username supplied"
|
||||
},
|
||||
"404" : {
|
||||
"description" : "User not found"
|
||||
}
|
||||
},
|
||||
"x-accepts" : "application/json"
|
||||
}
|
||||
}
|
||||
},
|
||||
"securityDefinitions" : {
|
||||
"petstore_auth" : {
|
||||
"type" : "oauth2",
|
||||
"authorizationUrl" : "http://petstore.swagger.io/api/oauth/dialog",
|
||||
"flow" : "implicit",
|
||||
"scopes" : {
|
||||
"write:pets" : "modify pets in your account",
|
||||
"read:pets" : "read your pets"
|
||||
}
|
||||
},
|
||||
"api_key" : {
|
||||
"type" : "apiKey",
|
||||
"name" : "api_key",
|
||||
"in" : "header"
|
||||
}
|
||||
},
|
||||
"definitions" : {
|
||||
"Order" : {
|
||||
"type" : "object",
|
||||
"properties" : {
|
||||
"id" : {
|
||||
"type" : "integer",
|
||||
"format" : "int64"
|
||||
},
|
||||
"petId" : {
|
||||
"type" : "integer",
|
||||
"format" : "int64"
|
||||
},
|
||||
"quantity" : {
|
||||
"type" : "integer",
|
||||
"format" : "int32"
|
||||
},
|
||||
"shipDate" : {
|
||||
"type" : "string",
|
||||
"format" : "date-time"
|
||||
},
|
||||
"status" : {
|
||||
"type" : "string",
|
||||
"description" : "Order Status",
|
||||
"enum" : [ "placed", "approved", "delivered" ]
|
||||
},
|
||||
"complete" : {
|
||||
"type" : "boolean",
|
||||
"default" : false
|
||||
}
|
||||
},
|
||||
"title" : "Pet Order",
|
||||
"description" : "An order for a pets from the pet store",
|
||||
"example" : {
|
||||
"petId" : 6,
|
||||
"quantity" : 1,
|
||||
"id" : 0,
|
||||
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||
"complete" : false,
|
||||
"status" : "placed"
|
||||
},
|
||||
"xml" : {
|
||||
"name" : "Order"
|
||||
}
|
||||
},
|
||||
"Category" : {
|
||||
"type" : "object",
|
||||
"properties" : {
|
||||
"id" : {
|
||||
"type" : "integer",
|
||||
"format" : "int64"
|
||||
},
|
||||
"name" : {
|
||||
"type" : "string"
|
||||
}
|
||||
},
|
||||
"title" : "Pet category",
|
||||
"description" : "A category for a pet",
|
||||
"example" : {
|
||||
"name" : "name",
|
||||
"id" : 6
|
||||
},
|
||||
"xml" : {
|
||||
"name" : "Category"
|
||||
}
|
||||
},
|
||||
"User" : {
|
||||
"type" : "object",
|
||||
"properties" : {
|
||||
"id" : {
|
||||
"type" : "integer",
|
||||
"format" : "int64"
|
||||
},
|
||||
"username" : {
|
||||
"type" : "string"
|
||||
},
|
||||
"firstName" : {
|
||||
"type" : "string"
|
||||
},
|
||||
"lastName" : {
|
||||
"type" : "string"
|
||||
},
|
||||
"email" : {
|
||||
"type" : "string"
|
||||
},
|
||||
"password" : {
|
||||
"type" : "string"
|
||||
},
|
||||
"phone" : {
|
||||
"type" : "string"
|
||||
},
|
||||
"userStatus" : {
|
||||
"type" : "integer",
|
||||
"format" : "int32",
|
||||
"description" : "User Status"
|
||||
}
|
||||
},
|
||||
"title" : "a User",
|
||||
"description" : "A User who is purchasing from the pet store",
|
||||
"example" : {
|
||||
"firstName" : "firstName",
|
||||
"lastName" : "lastName",
|
||||
"password" : "password",
|
||||
"userStatus" : 6,
|
||||
"phone" : "phone",
|
||||
"id" : 0,
|
||||
"email" : "email",
|
||||
"username" : "username"
|
||||
},
|
||||
"xml" : {
|
||||
"name" : "User"
|
||||
}
|
||||
},
|
||||
"Tag" : {
|
||||
"type" : "object",
|
||||
"properties" : {
|
||||
"id" : {
|
||||
"type" : "integer",
|
||||
"format" : "int64"
|
||||
},
|
||||
"name" : {
|
||||
"type" : "string"
|
||||
}
|
||||
},
|
||||
"title" : "Pet Tag",
|
||||
"description" : "A tag for a pet",
|
||||
"example" : {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
},
|
||||
"xml" : {
|
||||
"name" : "Tag"
|
||||
}
|
||||
},
|
||||
"Pet" : {
|
||||
"type" : "object",
|
||||
"required" : [ "name", "photoUrls" ],
|
||||
"properties" : {
|
||||
"id" : {
|
||||
"type" : "integer",
|
||||
"format" : "int64"
|
||||
},
|
||||
"category" : {
|
||||
"$ref" : "#/definitions/Category"
|
||||
},
|
||||
"name" : {
|
||||
"type" : "string",
|
||||
"example" : "doggie"
|
||||
},
|
||||
"photoUrls" : {
|
||||
"type" : "array",
|
||||
"xml" : {
|
||||
"name" : "photoUrl",
|
||||
"wrapped" : true
|
||||
},
|
||||
"items" : {
|
||||
"type" : "string"
|
||||
}
|
||||
},
|
||||
"tags" : {
|
||||
"type" : "array",
|
||||
"xml" : {
|
||||
"name" : "tag",
|
||||
"wrapped" : true
|
||||
},
|
||||
"items" : {
|
||||
"$ref" : "#/definitions/Tag"
|
||||
}
|
||||
},
|
||||
"status" : {
|
||||
"type" : "string",
|
||||
"description" : "pet status in the store",
|
||||
"enum" : [ "available", "pending", "sold" ]
|
||||
}
|
||||
},
|
||||
"title" : "a Pet",
|
||||
"description" : "A pet for sale in the pet store",
|
||||
"example" : {
|
||||
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||
"name" : "doggie",
|
||||
"id" : 0,
|
||||
"category" : {
|
||||
"name" : "name",
|
||||
"id" : 6
|
||||
},
|
||||
"tags" : [ {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
}, {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
} ],
|
||||
"status" : "available"
|
||||
},
|
||||
"xml" : {
|
||||
"name" : "Pet"
|
||||
}
|
||||
},
|
||||
"ApiResponse" : {
|
||||
"type" : "object",
|
||||
"properties" : {
|
||||
"code" : {
|
||||
"type" : "integer",
|
||||
"format" : "int32"
|
||||
},
|
||||
"type" : {
|
||||
"type" : "string"
|
||||
},
|
||||
"message" : {
|
||||
"type" : "string"
|
||||
}
|
||||
},
|
||||
"title" : "An uploaded response",
|
||||
"description" : "Describes the result of uploading an image resource",
|
||||
"example" : {
|
||||
"code" : 0,
|
||||
"type" : "type",
|
||||
"message" : "message"
|
||||
}
|
||||
}
|
||||
},
|
||||
"externalDocs" : {
|
||||
"description" : "Find out more about Swagger",
|
||||
"url" : "http://swagger.io"
|
||||
}
|
||||
}
|
@ -1 +1 @@
|
||||
2.3.0-SNAPSHOT
|
||||
2.3.0
|
@ -1 +1 @@
|
||||
2.3.0-SNAPSHOT
|
||||
2.3.0
|
@ -1 +1 @@
|
||||
2.3.0-SNAPSHOT
|
||||
2.3.0
|
@ -1 +1 @@
|
||||
2.3.0-SNAPSHOT
|
||||
2.3.0
|
@ -1 +1 @@
|
||||
2.3.0-SNAPSHOT
|
||||
2.3.0
|
@ -1 +1 @@
|
||||
2.3.0-SNAPSHOT
|
||||
2.3.0
|
@ -1 +1 @@
|
||||
2.3.0-SNAPSHOT
|
||||
2.3.0
|
@ -1 +1 @@
|
||||
2.3.0-SNAPSHOT
|
||||
2.3.0
|
Loading…
Reference in New Issue
Block a user