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

This commit is contained in:
wing328 2017-04-28 02:03:42 +08:00
commit 2ac169c750
25 changed files with 197 additions and 135 deletions

View File

@ -26,6 +26,6 @@ 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/JavaSpring -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l spring --library spring-mvc -o samples/server/petstore/spring-mvc-j8-async -c bin/spring-mvc-petstore-j8-async.json -DhideGenerationTimestamp=true,java8=true,async=true"
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaSpring -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l spring -o samples/server/petstore/spring-mvc-j8-async -c bin/spring-mvc-petstore-j8-async.json -DhideGenerationTimestamp=true,java8=true,async=true"
java $JAVA_OPTS -jar $executable $ags

View File

@ -1,3 +1,6 @@
{
"library": "j8-async"
"java8": true,
"async": true,
"library": "spring-mvc",
"artifactId": "swagger-spring-mvc-server-j8-async"
}

View File

@ -16,7 +16,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;
{{#useSpringCloudClient}}
{{^useSpringCloudClient}}
import java.io.IOException;
{{/useSpringCloudClient}}

View File

@ -17,15 +17,16 @@ import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;
{{^useSpringCloudClient}}
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
{{/useSpringCloudClient}}
import java.util.List;
{{#async}}
import java.util.concurrent.Callable;
{{/async}}{{/jdk8-no-delegate}}
{{/async}}
{{/jdk8-no-delegate}}
{{^useSpringCloudClient}}
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
{{/useSpringCloudClient}}
{{#useBeanValidation}}
import javax.validation.constraints.*;
import javax.validation.Valid;

View File

@ -1,20 +1,29 @@
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
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://helloreverb.com/terms/'
termsOfService: 'http://swagger.io/terms/'
contact:
email: apiteam@wordnik.com
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:
@ -29,13 +38,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:
@ -55,13 +64,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:
@ -83,13 +92,13 @@ paths:
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
@ -97,8 +106,8 @@ paths:
- available
- pending
- sold
collectionFormat: multi
default: available
default: available
collectionFormat: csv
responses:
'200':
description: successful operation
@ -106,13 +115,6 @@ paths:
type: array
items:
$ref: '#/definitions/Pet'
examples:
application/json:
name: Puma
type: Dog
color: Black
gender: Female
breed: Mixed
'400':
description: Invalid status value
security:
@ -124,22 +126,20 @@ paths:
tags:
- pet
summary: Finds Pets by tags
description: >-
Multiple tags can be provided with comma separated strings. Use tag1,
tag2, tag3 for testing.
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
@ -158,17 +158,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
@ -183,9 +181,6 @@ paths:
description: Pet not found
security:
- api_key: []
- petstore_auth:
- 'write:pets'
- 'read:pets'
post:
tags:
- pet
@ -195,14 +190,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
@ -227,12 +223,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
@ -259,7 +254,6 @@ paths:
- multipart/form-data
produces:
- application/json
- application/xml
parameters:
- name: petId
in: path
@ -278,8 +272,10 @@ paths:
required: false
type: file
responses:
default:
'200':
description: successful operation
schema:
$ref: '#/definitions/ApiResponse'
security:
- petstore_auth:
- 'write:pets'
@ -293,7 +289,7 @@ paths:
operationId: getInventory
produces:
- application/json
- application/xml
parameters: []
responses:
'200':
description: successful operation
@ -312,13 +308,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:
@ -333,19 +329,20 @@ paths:
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
description: 'For valid response try integer IDs with value <= 5 or > 10. Other 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
minimum: 1
format: int64
responses:
'200':
description: successful operation
@ -359,13 +356,11 @@ paths:
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
description: For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
operationId: deleteOrder
produces:
- application/json
- application/xml
- application/json
parameters:
- name: orderId
in: path
@ -385,13 +380,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:
@ -405,13 +400,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:
@ -427,13 +422,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:
@ -449,24 +444,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
/user/logout:
@ -477,8 +481,9 @@ paths:
description: ''
operationId: logoutUser
produces:
- application/json
- application/xml
- application/json
parameters: []
responses:
default:
description: successful operation
@ -490,8 +495,8 @@ paths:
description: ''
operationId: getUserByName
produces:
- application/json
- application/xml
- application/json
parameters:
- name: username
in: path
@ -514,8 +519,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
@ -525,7 +530,7 @@ paths:
- in: body
name: body
description: Updated user object
required: false
required: true
schema:
$ref: '#/definitions/User'
responses:
@ -540,8 +545,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
@ -554,10 +559,6 @@ paths:
'404':
description: User not found
securityDefinitions:
api_key:
type: apiKey
name: api_key
in: header
petstore_auth:
type: oauth2
authorizationUrl: 'http://petstore.swagger.io/api/oauth/dialog'
@ -565,8 +566,56 @@ securityDefinitions:
scopes:
'write:pets': modify pets in your account
'read:pets': read your pets
api_key:
type: apiKey
name: api_key
in: header
definitions:
Order:
title: Pet Order
description: An order for a pets from the pet store
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:
title: Pet catehgry
description: A category for a pet
type: object
properties:
id:
type: integer
format: int64
name:
type: string
xml:
name: Category
User:
title: a User
description: A User who is purchasing from the pet store
type: object
properties:
id:
type: integer
@ -589,7 +638,10 @@ definitions:
description: User Status
xml:
name: User
Category:
Tag:
title: Pet Tag
description: A tag for a pet
type: object
properties:
id:
type: integer
@ -597,8 +649,11 @@ definitions:
name:
type: string
xml:
name: Category
name: Tag
Pet:
title: a Pet
description: A pet for sale in the pet store
type: object
required:
- name
- photoUrls
@ -634,37 +689,18 @@ definitions:
- sold
xml:
name: Pet
Tag:
ApiResponse:
title: An uploaded response
description: Describes the result of uploading an image resource
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'

View File

@ -13,7 +13,6 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.List;
import javax.validation.constraints.*;

View File

@ -13,7 +13,6 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.List;
import javax.validation.constraints.*;

View File

@ -13,7 +13,6 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.List;
import javax.validation.constraints.*;

View File

@ -1,9 +1,9 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>io.swagger</groupId>
<artifactId>swagger-spring</artifactId>
<artifactId>swagger-spring-mvc-server-j8-async</artifactId>
<packaging>jar</packaging>
<name>swagger-spring</name>
<name>swagger-spring-mvc-server-j8-async</name>
<version>1.0.0</version>
<build>
<sourceDirectory>src/main/java</sourceDirectory>

View File

@ -1,7 +1,8 @@
package io.swagger.api;
import org.springframework.stereotype.Controller;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import javax.validation.constraints.*;
import javax.validation.Valid;

View File

@ -1,7 +1,8 @@
package io.swagger.api;
import org.springframework.stereotype.Controller;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import javax.validation.constraints.*;
import javax.validation.Valid;

View File

@ -1,7 +1,8 @@
package io.swagger.api;
import org.springframework.stereotype.Controller;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import javax.validation.constraints.*;
import javax.validation.Valid;

View File

@ -1,7 +1,8 @@
package io.swagger.api;
import org.springframework.stereotype.Controller;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import javax.validation.constraints.*;
import javax.validation.Valid;

View File

@ -0,0 +1,16 @@
package io.swagger.configuration;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
/**
* Home redirection to swagger api documentation
*/
@Controller
public class HomeController {
@RequestMapping(value = "/")
public String index() {
System.out.println("swagger-ui.html");
return "redirect:swagger-ui.html";
}
}

View File

@ -0,0 +1,5 @@
springfox.documentation.swagger.v2.path=/api-docs
server.contextPath=/v2
server.port=80
spring.jackson.date-format=io.swagger.RFC3339DateFormat
spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false

View File

@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.List;
import javax.validation.constraints.*;

View File

@ -16,11 +16,10 @@ import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import java.util.List;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import javax.validation.constraints.*;
import javax.validation.Valid;

View File

@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.List;
import javax.validation.constraints.*;

View File

@ -13,11 +13,10 @@ import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import java.util.List;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import javax.validation.constraints.*;
import javax.validation.Valid;

View File

@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.List;
import javax.validation.constraints.*;

View File

@ -15,11 +15,10 @@ import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import java.util.List;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import javax.validation.constraints.*;
import javax.validation.Valid;

View File

@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.List;
import javax.validation.constraints.*;

View File

@ -14,11 +14,10 @@ import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import java.util.List;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import javax.validation.constraints.*;
import javax.validation.Valid;

View File

@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.List;
import javax.validation.constraints.*;

View File

@ -14,11 +14,10 @@ import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import java.util.List;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import javax.validation.constraints.*;
import javax.validation.Valid;