update server generator to use petstore.yaml

This commit is contained in:
wing328
2016-04-15 17:42:18 +08:00
parent 4f84c7d3bc
commit 0982afbca0
17 changed files with 375 additions and 507 deletions

View File

@@ -11,9 +11,10 @@ import java.util.List;
import io.swagger.model.*;
import io.swagger.model.Pet;
import io.swagger.model.ApiResponse;
import java.io.File;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaInflectorServerCodegen", date = "2016-01-19T23:33:17.124+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaInflectorServerCodegen", date = "2016-04-15T17:39:42.971+08:00")
public class PetController {
/**
* Uncomment and implement as you see fit. These operations will map
@@ -22,13 +23,13 @@ public class PetController {
**/
/*
public ResponseContext updatePet(RequestContext request , Pet body) {
public ResponseContext addPet(RequestContext request , Pet body) {
return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" );
}
*/
/*
public ResponseContext addPet(RequestContext request , Pet body) {
public ResponseContext deletePet(RequestContext request , Long petId, String apiKey) {
return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" );
}
*/
@@ -52,13 +53,13 @@ public class PetController {
*/
/*
public ResponseContext updatePetWithForm(RequestContext request , String petId, String name, String status) {
public ResponseContext updatePet(RequestContext request , Pet body) {
return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" );
}
*/
/*
public ResponseContext deletePet(RequestContext request , Long petId, String apiKey) {
public ResponseContext updatePetWithForm(RequestContext request , Long petId, String name, String status) {
return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" );
}
*/
@@ -69,11 +70,5 @@ public class PetController {
}
*/
/*
public ResponseContext getPetByIdWithByteArray(RequestContext request , Long petId) {
return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" );
}
*/
}

View File

@@ -13,7 +13,7 @@ import io.swagger.model.*;
import java.util.Map;
import io.swagger.model.Order;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaInflectorServerCodegen", date = "2016-01-19T23:33:17.124+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaInflectorServerCodegen", date = "2016-04-15T17:39:42.971+08:00")
public class StoreController {
/**
* Uncomment and implement as you see fit. These operations will map
@@ -21,29 +21,29 @@ public class StoreController {
* Code allows you to implement logic incrementally, they are disabled.
**/
/*
public ResponseContext deleteOrder(RequestContext request , String orderId) {
return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" );
}
*/
/*
public ResponseContext getInventory(RequestContext request ) {
return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" );
}
*/
/*
public ResponseContext getOrderById(RequestContext request , Long orderId) {
return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" );
}
*/
/*
public ResponseContext placeOrder(RequestContext request , Order body) {
return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" );
}
*/
/*
public ResponseContext getOrderById(RequestContext request , String orderId) {
return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" );
}
*/
/*
public ResponseContext deleteOrder(RequestContext request , String orderId) {
return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" );
}
*/
}

View File

@@ -11,9 +11,9 @@ import java.util.List;
import io.swagger.model.*;
import io.swagger.model.User;
import java.util.*;
import java.util.List;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaInflectorServerCodegen", date = "2016-01-19T23:33:17.124+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaInflectorServerCodegen", date = "2016-04-15T17:39:42.971+08:00")
public class UserController {
/**
* Uncomment and implement as you see fit. These operations will map
@@ -39,6 +39,18 @@ public class UserController {
}
*/
/*
public ResponseContext deleteUser(RequestContext request , String username) {
return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" );
}
*/
/*
public ResponseContext getUserByName(RequestContext request , String username) {
return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" );
}
*/
/*
public ResponseContext loginUser(RequestContext request , String username, String password) {
return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" );
@@ -51,23 +63,11 @@ public class UserController {
}
*/
/*
public ResponseContext getUserByName(RequestContext request , String username) {
return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" );
}
*/
/*
public ResponseContext updateUser(RequestContext request , String username, User body) {
return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" );
}
*/
/*
public ResponseContext deleteUser(RequestContext request , String username) {
return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" );
}
*/
}

View File

@@ -2,9 +2,9 @@
swagger: "2.0"
info:
description: "This is a sample server Petstore server. You can find out more about\
\ Swagger at <a href=\"http://swagger.io\">http://swagger.io</a> or on irc.freenode.net,\
\ #swagger. For this sample, you can use the api key \"special-key\" to test\
\ the authorization filters"
\ 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/"
@@ -15,6 +15,19 @@ info:
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:
@@ -29,13 +42,13 @@ paths:
- "application/json"
- "application/xml"
produces:
- "application/json"
- "application/xml"
- "application/json"
parameters:
- in: "body"
name: "body"
description: "Pet object that needs to be added to the store"
required: false
required: true
schema:
$ref: "#/definitions/Pet"
responses:
@@ -57,13 +70,13 @@ paths:
- "application/json"
- "application/xml"
produces:
- "application/json"
- "application/xml"
- "application/json"
parameters:
- in: "body"
name: "body"
description: "Pet object that needs to be added to the store"
required: false
required: true
schema:
$ref: "#/definitions/Pet"
responses:
@@ -84,21 +97,25 @@ paths:
tags:
- "pet"
summary: "Finds Pets by status"
description: "Multiple status values can be provided with comma seperated strings"
description: "Multiple status values can be provided with comma separated strings"
operationId: "findPetsByStatus"
produces:
- "application/json"
- "application/xml"
- "application/json"
parameters:
- name: "status"
in: "query"
description: "Status values that need to be considered for filter"
required: false
required: true
type: "array"
items:
type: "string"
collectionFormat: "multi"
default: "available"
default: "available"
enum:
- "available"
- "pending"
- "sold"
collectionFormat: "csv"
responses:
200:
description: "successful operation"
@@ -119,21 +136,21 @@ paths:
tags:
- "pet"
summary: "Finds Pets by tags"
description: "Muliple tags can be provided with comma seperated strings. Use\
description: "Multiple tags can be provided with comma separated strings. Use\
\ tag1, tag2, tag3 for testing."
operationId: "findPetsByTags"
produces:
- "application/json"
- "application/xml"
- "application/json"
parameters:
- name: "tags"
in: "query"
description: "Tags to filter by"
required: false
required: true
type: "array"
items:
type: "string"
collectionFormat: "multi"
collectionFormat: "csv"
responses:
200:
description: "successful operation"
@@ -154,16 +171,15 @@ paths:
tags:
- "pet"
summary: "Find pet by ID"
description: "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate\
\ API error conditions"
description: "Returns a single pet"
operationId: "getPetById"
produces:
- "application/json"
- "application/xml"
- "application/json"
parameters:
- name: "petId"
in: "path"
description: "ID of pet that needs to be fetched"
description: "ID of pet to return"
required: true
type: "integer"
format: "int64"
@@ -178,9 +194,6 @@ paths:
description: "Pet not found"
security:
- api_key: []
- petstore_auth:
- "write:pets"
- "read:pets"
x-contentType: "application/json"
x-accepts: "application/json"
post:
@@ -192,14 +205,15 @@ paths:
consumes:
- "application/x-www-form-urlencoded"
produces:
- "application/json"
- "application/xml"
- "application/json"
parameters:
- name: "petId"
in: "path"
description: "ID of pet that needs to be updated"
required: true
type: "string"
type: "integer"
format: "int64"
- name: "name"
in: "formData"
description: "Updated name of the pet"
@@ -226,12 +240,11 @@ paths:
description: ""
operationId: "deletePet"
produces:
- "application/json"
- "application/xml"
- "application/json"
parameters:
- name: "api_key"
in: "header"
description: ""
required: false
type: "string"
- name: "petId"
@@ -260,7 +273,6 @@ paths:
- "multipart/form-data"
produces:
- "application/json"
- "application/xml"
parameters:
- name: "petId"
in: "path"
@@ -279,80 +291,16 @@ paths:
required: false
type: "file"
responses:
default:
200:
description: "successful operation"
schema:
$ref: "#/definitions/ApiResponse"
security:
- petstore_auth:
- "write:pets"
- "read:pets"
x-contentType: "multipart/form-data"
x-accepts: "application/json"
/pet/{petId}?testing_byte_array=true:
get:
tags:
- "pet"
summary: "Fake endpoint to test byte array return by 'Find pet by ID'"
description: "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate\
\ API error conditions"
operationId: "getPetByIdWithByteArray"
produces:
- "application/json"
- "application/xml"
parameters:
- name: "petId"
in: "path"
description: "ID of pet that needs to be fetched"
required: true
type: "integer"
format: "int64"
responses:
200:
description: "successful operation"
schema:
type: "string"
format: "binary"
400:
description: "Invalid ID supplied"
404:
description: "Pet not found"
security:
- api_key: []
- petstore_auth:
- "write:pets"
- "read:pets"
x-contentType: "application/json"
x-accepts: "application/json"
/pet?testing_byte_array=true:
post:
tags:
- "pet"
summary: "Fake endpoint to test byte array in body parameter for adding a new\
\ pet to the store"
description: ""
operationId: "addPetUsingByteArray"
consumes:
- "application/json"
- "application/xml"
produces:
- "application/json"
- "application/xml"
parameters:
- in: "body"
name: "body"
description: "Pet object in the form of byte array"
required: false
schema:
type: "string"
format: "binary"
responses:
405:
description: "Invalid input"
security:
- petstore_auth:
- "write:pets"
- "read:pets"
x-contentType: "application/json"
x-accepts: "application/json"
/store/inventory:
get:
tags:
@@ -362,7 +310,6 @@ paths:
operationId: "getInventory"
produces:
- "application/json"
- "application/xml"
parameters: []
responses:
200:
@@ -384,13 +331,13 @@ paths:
description: ""
operationId: "placeOrder"
produces:
- "application/json"
- "application/xml"
- "application/json"
parameters:
- in: "body"
name: "body"
description: "order placed for purchasing the pet"
required: false
required: true
schema:
$ref: "#/definitions/Order"
responses:
@@ -411,14 +358,17 @@ paths:
\ values will generated exceptions"
operationId: "getOrderById"
produces:
- "application/json"
- "application/xml"
- "application/json"
parameters:
- name: "orderId"
in: "path"
description: "ID of pet that needs to be fetched"
required: true
type: "string"
type: "integer"
maximum: 5.0
minimum: 1.0
format: "int64"
responses:
200:
description: "successful operation"
@@ -438,14 +388,15 @@ paths:
\ above 1000 or nonintegers will generate API errors"
operationId: "deleteOrder"
produces:
- "application/json"
- "application/xml"
- "application/json"
parameters:
- name: "orderId"
in: "path"
description: "ID of the order that needs to be deleted"
required: true
type: "string"
minimum: 1.0
responses:
400:
description: "Invalid ID supplied"
@@ -461,13 +412,13 @@ paths:
description: "This can only be done by the logged in user."
operationId: "createUser"
produces:
- "application/json"
- "application/xml"
- "application/json"
parameters:
- in: "body"
name: "body"
description: "Created user object"
required: false
required: true
schema:
$ref: "#/definitions/User"
responses:
@@ -483,13 +434,13 @@ paths:
description: ""
operationId: "createUsersWithArrayInput"
produces:
- "application/json"
- "application/xml"
- "application/json"
parameters:
- in: "body"
name: "body"
description: "List of user object"
required: false
required: true
schema:
type: "array"
items:
@@ -507,13 +458,13 @@ paths:
description: ""
operationId: "createUsersWithListInput"
produces:
- "application/json"
- "application/xml"
- "application/json"
parameters:
- in: "body"
name: "body"
description: "List of user object"
required: false
required: true
schema:
type: "array"
items:
@@ -531,24 +482,33 @@ paths:
description: ""
operationId: "loginUser"
produces:
- "application/json"
- "application/xml"
- "application/json"
parameters:
- name: "username"
in: "query"
description: "The user name for login"
required: false
required: true
type: "string"
- name: "password"
in: "query"
description: "The password for login in clear text"
required: false
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-contentType: "application/json"
@@ -561,8 +521,8 @@ paths:
description: ""
operationId: "logoutUser"
produces:
- "application/json"
- "application/xml"
- "application/json"
parameters: []
responses:
default:
@@ -577,8 +537,8 @@ paths:
description: ""
operationId: "getUserByName"
produces:
- "application/json"
- "application/xml"
- "application/json"
parameters:
- name: "username"
in: "path"
@@ -590,16 +550,6 @@ paths:
description: "successful operation"
schema:
$ref: "#/definitions/User"
examples:
application/json:
id: 1
username: "johnp"
firstName: "John"
lastName: "Public"
email: "johnp@swagger.io"
password: "-secret-"
phone: "0123456789"
userStatus: 0
400:
description: "Invalid username supplied"
404:
@@ -613,8 +563,8 @@ paths:
description: "This can only be done by the logged in user."
operationId: "updateUser"
produces:
- "application/json"
- "application/xml"
- "application/json"
parameters:
- name: "username"
in: "path"
@@ -624,7 +574,7 @@ paths:
- in: "body"
name: "body"
description: "Updated user object"
required: false
required: true
schema:
$ref: "#/definitions/User"
responses:
@@ -641,8 +591,8 @@ paths:
description: "This can only be done by the logged in user."
operationId: "deleteUser"
produces:
- "application/json"
- "application/xml"
- "application/json"
parameters:
- name: "username"
in: "path"
@@ -669,7 +619,45 @@ securityDefinitions:
write:pets: "modify pets in your account"
read:pets: "read your pets"
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
xml:
name: "Order"
Category:
type: "object"
properties:
id:
type: "integer"
format: "int64"
name:
type: "string"
xml:
name: "Category"
User:
type: "object"
properties:
id:
type: "integer"
@@ -692,7 +680,8 @@ definitions:
description: "User Status"
xml:
name: "User"
Category:
Tag:
type: "object"
properties:
id:
type: "integer"
@@ -700,8 +689,9 @@ definitions:
name:
type: "string"
xml:
name: "Category"
name: "Tag"
Pet:
type: "object"
required:
- "name"
- "photoUrls"
@@ -737,37 +727,16 @@ definitions:
- "sold"
xml:
name: "Pet"
Tag:
ApiResponse:
type: "object"
properties:
id:
type: "integer"
format: "int64"
name:
type: "string"
xml:
name: "Tag"
Order:
properties:
id:
type: "integer"
format: "int64"
petId:
type: "integer"
format: "int64"
quantity:
code:
type: "integer"
format: "int32"
shipDate:
type:
type: "string"
format: "date-time"
status:
message:
type: "string"
description: "Order Status"
enum:
- "placed"
- "approved"
- "delivered"
complete:
type: "boolean"
xml:
name: "Order"
externalDocs:
description: "Find out more about Swagger"
url: "http://swagger.io"