mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-07 10:58:55 +00:00
Update NodeJS server petstore samples with OAS2, OAS3 (#113)
* update nodejs server oas2 * update nodejs server petstore with oas3 * update nodejs google cloud with oas2 petstore * update nodejs server google function with oas3
This commit is contained in:
parent
dc0cbd23b6
commit
ddf10b98dc
31
bin/openapi3/nodejs-petstore-google-cloud-functions.sh
Executable file
31
bin/openapi3/nodejs-petstore-google-cloud-functions.sh
Executable file
@ -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/openapi-generator-cli/target/openapi-generator-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 -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -l nodejs-server --additional-properties=googleCloudFunctions=true -o samples/server/petstore/nodejs-google-cloud-functions -Dservice"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
31
bin/openapi3/nodejs-petstore-server.sh
Executable file
31
bin/openapi3/nodejs-petstore-server.sh
Executable file
@ -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/openapi-generator-cli/target/openapi-generator-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/openapi-generator/src/main/resources/nodejs -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -l nodejs-server -o samples/server/petstore/nodejs -Dservice"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
@ -391,7 +391,8 @@ public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig
|
||||
if (operation.getOperationId() == null) {
|
||||
operation.setOperationId(getOrGenerateOperationId(operation, pathname, method.toString()));
|
||||
}
|
||||
if (operation.getExtensions().get("x-openapi-router-controller") == null) {
|
||||
if (operation.getExtensions() == null ||
|
||||
operation.getExtensions().get("x-openapi-router-controller") == null) {
|
||||
operation.addExtension("x-openapi-router-controller", sanitizeTag(tag));
|
||||
}
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
2.4.0-SNAPSHOT
|
||||
3.0.0-SNAPSHOT
|
@ -0,0 +1,784 @@
|
||||
openapi: 3.0.0
|
||||
info:
|
||||
title: Swagger Petstore
|
||||
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.'
|
||||
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
|
||||
version: 1.0.0
|
||||
externalDocs:
|
||||
description: Find out more about Swagger
|
||||
url: http://swagger.io
|
||||
servers:
|
||||
- url: http://petstore.swagger.io/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
|
||||
paths:
|
||||
/pet:
|
||||
put:
|
||||
tags:
|
||||
- pet
|
||||
summary: Update an existing pet
|
||||
operationId: updatePet
|
||||
requestBody:
|
||||
$ref: '#/components/requestBodies/Pet'
|
||||
responses:
|
||||
400:
|
||||
description: Invalid ID supplied
|
||||
404:
|
||||
description: Pet not found
|
||||
405:
|
||||
description: Validation exception
|
||||
security:
|
||||
- petstore_auth:
|
||||
- write:pets
|
||||
- read:pets
|
||||
x-openapi-router-controller: Pet
|
||||
post:
|
||||
tags:
|
||||
- pet
|
||||
summary: Add a new pet to the store
|
||||
operationId: addPet
|
||||
requestBody:
|
||||
$ref: '#/components/requestBodies/Pet'
|
||||
responses:
|
||||
405:
|
||||
description: Invalid input
|
||||
security:
|
||||
- petstore_auth:
|
||||
- write:pets
|
||||
- read:pets
|
||||
x-openapi-router-controller: Pet
|
||||
/pet/findByStatus:
|
||||
get:
|
||||
tags:
|
||||
- pet
|
||||
summary: Finds Pets by status
|
||||
description: Multiple status values can be provided with comma separated strings
|
||||
operationId: findPetsByStatus
|
||||
parameters:
|
||||
- name: status
|
||||
in: query
|
||||
description: Status values that need to be considered for filter
|
||||
required: true
|
||||
style: form
|
||||
explode: false
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
default: available
|
||||
enum:
|
||||
- available
|
||||
- pending
|
||||
- sold
|
||||
responses:
|
||||
200:
|
||||
description: successful operation
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
400:
|
||||
description: Invalid status value
|
||||
security:
|
||||
- petstore_auth:
|
||||
- write:pets
|
||||
- read:pets
|
||||
x-openapi-router-controller: Pet
|
||||
/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
|
||||
parameters:
|
||||
- name: tags
|
||||
in: query
|
||||
description: Tags to filter by
|
||||
required: true
|
||||
style: form
|
||||
explode: false
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
responses:
|
||||
200:
|
||||
description: successful operation
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
400:
|
||||
description: Invalid tag value
|
||||
deprecated: true
|
||||
security:
|
||||
- petstore_auth:
|
||||
- write:pets
|
||||
- read:pets
|
||||
x-openapi-router-controller: Pet
|
||||
/pet/{petId}:
|
||||
get:
|
||||
tags:
|
||||
- pet
|
||||
summary: Find pet by ID
|
||||
description: Returns a single pet
|
||||
operationId: getPetById
|
||||
parameters:
|
||||
- name: petId
|
||||
in: path
|
||||
description: ID of pet to return
|
||||
required: true
|
||||
style: simple
|
||||
explode: false
|
||||
schema:
|
||||
type: integer
|
||||
format: int64
|
||||
responses:
|
||||
200:
|
||||
description: successful operation
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
400:
|
||||
description: Invalid ID supplied
|
||||
404:
|
||||
description: Pet not found
|
||||
security:
|
||||
- api_key: []
|
||||
x-openapi-router-controller: Pet
|
||||
post:
|
||||
tags:
|
||||
- pet
|
||||
summary: Updates a pet in the store with form data
|
||||
operationId: updatePetWithForm
|
||||
parameters:
|
||||
- name: petId
|
||||
in: path
|
||||
description: ID of pet that needs to be updated
|
||||
required: true
|
||||
style: simple
|
||||
explode: false
|
||||
schema:
|
||||
type: integer
|
||||
format: int64
|
||||
requestBody:
|
||||
content:
|
||||
application/x-www-form-urlencoded:
|
||||
schema:
|
||||
$ref: '#/components/schemas/body'
|
||||
responses:
|
||||
405:
|
||||
description: Invalid input
|
||||
security:
|
||||
- petstore_auth:
|
||||
- write:pets
|
||||
- read:pets
|
||||
x-openapi-router-controller: Pet
|
||||
delete:
|
||||
tags:
|
||||
- pet
|
||||
summary: Deletes a pet
|
||||
operationId: deletePet
|
||||
parameters:
|
||||
- name: api_key
|
||||
in: header
|
||||
required: false
|
||||
style: simple
|
||||
explode: false
|
||||
schema:
|
||||
type: string
|
||||
- name: petId
|
||||
in: path
|
||||
description: Pet id to delete
|
||||
required: true
|
||||
style: simple
|
||||
explode: false
|
||||
schema:
|
||||
type: integer
|
||||
format: int64
|
||||
responses:
|
||||
400:
|
||||
description: Invalid pet value
|
||||
security:
|
||||
- petstore_auth:
|
||||
- write:pets
|
||||
- read:pets
|
||||
x-openapi-router-controller: Pet
|
||||
/pet/{petId}/uploadImage:
|
||||
post:
|
||||
tags:
|
||||
- pet
|
||||
summary: uploads an image
|
||||
operationId: uploadFile
|
||||
parameters:
|
||||
- name: petId
|
||||
in: path
|
||||
description: ID of pet to update
|
||||
required: true
|
||||
style: simple
|
||||
explode: false
|
||||
schema:
|
||||
type: integer
|
||||
format: int64
|
||||
requestBody:
|
||||
content:
|
||||
multipart/form-data:
|
||||
schema:
|
||||
$ref: '#/components/schemas/body_1'
|
||||
responses:
|
||||
200:
|
||||
description: successful operation
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ApiResponse'
|
||||
security:
|
||||
- petstore_auth:
|
||||
- write:pets
|
||||
- read:pets
|
||||
x-openapi-router-controller: Pet
|
||||
/store/inventory:
|
||||
get:
|
||||
tags:
|
||||
- store
|
||||
summary: Returns pet inventories by status
|
||||
description: Returns a map of status codes to quantities
|
||||
operationId: getInventory
|
||||
responses:
|
||||
200:
|
||||
description: successful operation
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
additionalProperties:
|
||||
type: integer
|
||||
format: int32
|
||||
security:
|
||||
- api_key: []
|
||||
x-openapi-router-controller: Store
|
||||
/store/order:
|
||||
post:
|
||||
tags:
|
||||
- store
|
||||
summary: Place an order for a pet
|
||||
operationId: placeOrder
|
||||
requestBody:
|
||||
description: order placed for purchasing the pet
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Order'
|
||||
required: true
|
||||
responses:
|
||||
200:
|
||||
description: successful operation
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Order'
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Order'
|
||||
400:
|
||||
description: Invalid Order
|
||||
x-openapi-router-controller: Store
|
||||
/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
|
||||
parameters:
|
||||
- name: orderId
|
||||
in: path
|
||||
description: ID of pet that needs to be fetched
|
||||
required: true
|
||||
style: simple
|
||||
explode: false
|
||||
schema:
|
||||
maximum: 5
|
||||
minimum: 1
|
||||
type: integer
|
||||
format: int64
|
||||
responses:
|
||||
200:
|
||||
description: successful operation
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Order'
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Order'
|
||||
400:
|
||||
description: Invalid ID supplied
|
||||
404:
|
||||
description: Order not found
|
||||
x-openapi-router-controller: Store
|
||||
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
|
||||
parameters:
|
||||
- name: orderId
|
||||
in: path
|
||||
description: ID of the order that needs to be deleted
|
||||
required: true
|
||||
style: simple
|
||||
explode: false
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
400:
|
||||
description: Invalid ID supplied
|
||||
404:
|
||||
description: Order not found
|
||||
x-openapi-router-controller: Store
|
||||
/user:
|
||||
post:
|
||||
tags:
|
||||
- user
|
||||
summary: Create user
|
||||
description: This can only be done by the logged in user.
|
||||
operationId: createUser
|
||||
requestBody:
|
||||
description: Created user object
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/User'
|
||||
required: true
|
||||
responses:
|
||||
default:
|
||||
description: successful operation
|
||||
x-openapi-router-controller: User
|
||||
/user/createWithArray:
|
||||
post:
|
||||
tags:
|
||||
- user
|
||||
summary: Creates list of users with given input array
|
||||
operationId: createUsersWithArrayInput
|
||||
requestBody:
|
||||
$ref: '#/components/requestBodies/UserArray'
|
||||
responses:
|
||||
default:
|
||||
description: successful operation
|
||||
x-openapi-router-controller: User
|
||||
/user/createWithList:
|
||||
post:
|
||||
tags:
|
||||
- user
|
||||
summary: Creates list of users with given input array
|
||||
operationId: createUsersWithListInput
|
||||
requestBody:
|
||||
$ref: '#/components/requestBodies/UserArray'
|
||||
responses:
|
||||
default:
|
||||
description: successful operation
|
||||
x-openapi-router-controller: User
|
||||
/user/login:
|
||||
get:
|
||||
tags:
|
||||
- user
|
||||
summary: Logs user into the system
|
||||
operationId: loginUser
|
||||
parameters:
|
||||
- name: username
|
||||
in: query
|
||||
description: The user name for login
|
||||
required: true
|
||||
style: form
|
||||
explode: true
|
||||
schema:
|
||||
type: string
|
||||
- name: password
|
||||
in: query
|
||||
description: The password for login in clear text
|
||||
required: true
|
||||
style: form
|
||||
explode: true
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
200:
|
||||
description: successful operation
|
||||
headers:
|
||||
X-Rate-Limit:
|
||||
description: calls per hour allowed by the user
|
||||
style: simple
|
||||
explode: false
|
||||
schema:
|
||||
type: integer
|
||||
format: int32
|
||||
X-Expires-After:
|
||||
description: date in UTC when toekn expires
|
||||
style: simple
|
||||
explode: false
|
||||
schema:
|
||||
type: string
|
||||
format: date-time
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
type: string
|
||||
application/json:
|
||||
schema:
|
||||
type: string
|
||||
400:
|
||||
description: Invalid username/password supplied
|
||||
x-openapi-router-controller: User
|
||||
/user/logout:
|
||||
get:
|
||||
tags:
|
||||
- user
|
||||
summary: Logs out current logged in user session
|
||||
operationId: logoutUser
|
||||
responses:
|
||||
default:
|
||||
description: successful operation
|
||||
x-openapi-router-controller: User
|
||||
/user/{username}:
|
||||
get:
|
||||
tags:
|
||||
- user
|
||||
summary: Get user by user name
|
||||
operationId: getUserByName
|
||||
parameters:
|
||||
- name: username
|
||||
in: path
|
||||
description: The name that needs to be fetched. Use user1 for testing.
|
||||
required: true
|
||||
style: simple
|
||||
explode: false
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
200:
|
||||
description: successful operation
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
$ref: '#/components/schemas/User'
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/User'
|
||||
400:
|
||||
description: Invalid username supplied
|
||||
404:
|
||||
description: User not found
|
||||
x-openapi-router-controller: User
|
||||
put:
|
||||
tags:
|
||||
- user
|
||||
summary: Updated user
|
||||
description: This can only be done by the logged in user.
|
||||
operationId: updateUser
|
||||
parameters:
|
||||
- name: username
|
||||
in: path
|
||||
description: name that need to be deleted
|
||||
required: true
|
||||
style: simple
|
||||
explode: false
|
||||
schema:
|
||||
type: string
|
||||
requestBody:
|
||||
description: Updated user object
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/User'
|
||||
required: true
|
||||
responses:
|
||||
400:
|
||||
description: Invalid user supplied
|
||||
404:
|
||||
description: User not found
|
||||
x-openapi-router-controller: User
|
||||
delete:
|
||||
tags:
|
||||
- user
|
||||
summary: Delete user
|
||||
description: This can only be done by the logged in user.
|
||||
operationId: deleteUser
|
||||
parameters:
|
||||
- name: username
|
||||
in: path
|
||||
description: The name that needs to be deleted
|
||||
required: true
|
||||
style: simple
|
||||
explode: false
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
400:
|
||||
description: Invalid username supplied
|
||||
404:
|
||||
description: User not found
|
||||
x-openapi-router-controller: User
|
||||
components:
|
||||
schemas:
|
||||
Order:
|
||||
title: Pet 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
|
||||
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:
|
||||
title: Pet category
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
format: int64
|
||||
name:
|
||||
type: string
|
||||
description: A category for a pet
|
||||
example:
|
||||
name: name
|
||||
id: 6
|
||||
xml:
|
||||
name: Category
|
||||
User:
|
||||
title: a 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
|
||||
description: User Status
|
||||
format: int32
|
||||
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:
|
||||
title: Pet Tag
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
format: int64
|
||||
name:
|
||||
type: string
|
||||
description: A tag for a pet
|
||||
example:
|
||||
name: name
|
||||
id: 1
|
||||
xml:
|
||||
name: Tag
|
||||
Pet:
|
||||
title: a Pet
|
||||
required:
|
||||
- name
|
||||
- photoUrls
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
format: int64
|
||||
category:
|
||||
$ref: '#/components/schemas/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: '#/components/schemas/Tag'
|
||||
status:
|
||||
type: string
|
||||
description: pet status in the store
|
||||
enum:
|
||||
- available
|
||||
- pending
|
||||
- sold
|
||||
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:
|
||||
title: An uploaded response
|
||||
type: object
|
||||
properties:
|
||||
code:
|
||||
type: integer
|
||||
format: int32
|
||||
type:
|
||||
type: string
|
||||
message:
|
||||
type: string
|
||||
description: Describes the result of uploading an image resource
|
||||
example:
|
||||
code: 0
|
||||
type: type
|
||||
message: message
|
||||
body:
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
description: Updated name of the pet
|
||||
status:
|
||||
type: string
|
||||
description: Updated status of the pet
|
||||
body_1:
|
||||
type: object
|
||||
properties:
|
||||
additionalMetadata:
|
||||
type: string
|
||||
description: Additional data to pass to server
|
||||
file:
|
||||
type: string
|
||||
description: file to upload
|
||||
format: binary
|
||||
requestBodies:
|
||||
UserArray:
|
||||
description: List of user object
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/User'
|
||||
required: true
|
||||
Pet:
|
||||
description: Pet object that needs to be added to the store
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
application/xml:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
required: true
|
||||
securitySchemes:
|
||||
petstore_auth:
|
||||
type: oauth2
|
||||
flows:
|
||||
implicit:
|
||||
authorizationUrl: http://petstore.swagger.io/api/oauth/dialog
|
||||
scopes:
|
||||
write:pets: modify pets in your account
|
||||
read:pets: read your pets
|
||||
api_key:
|
||||
type: apiKey
|
||||
name: api_key
|
||||
in: header
|
@ -4,8 +4,8 @@ var utils = require('../utils/writer.js');
|
||||
var Pet = require('../service/PetService');
|
||||
|
||||
module.exports.addPet = function addPet (req, res, next) {
|
||||
var body = req.swagger.params['body'].value;
|
||||
Pet.addPet(body)
|
||||
var pet = req.swagger.params['Pet'].value;
|
||||
Pet.addPet(pet)
|
||||
.then(function (response) {
|
||||
utils.writeJson(res, response);
|
||||
})
|
||||
@ -60,8 +60,8 @@ module.exports.getPetById = function getPetById (req, res, next) {
|
||||
};
|
||||
|
||||
module.exports.updatePet = function updatePet (req, res, next) {
|
||||
var body = req.swagger.params['body'].value;
|
||||
Pet.updatePet(body)
|
||||
var pet = req.swagger.params['Pet'].value;
|
||||
Pet.updatePet(pet)
|
||||
.then(function (response) {
|
||||
utils.writeJson(res, response);
|
||||
})
|
||||
|
@ -36,8 +36,8 @@ module.exports.getOrderById = function getOrderById (req, res, next) {
|
||||
};
|
||||
|
||||
module.exports.placeOrder = function placeOrder (req, res, next) {
|
||||
var body = req.swagger.params['body'].value;
|
||||
Store.placeOrder(body)
|
||||
var order = req.swagger.params['Order'].value;
|
||||
Store.placeOrder(order)
|
||||
.then(function (response) {
|
||||
utils.writeJson(res, response);
|
||||
})
|
||||
|
@ -4,8 +4,8 @@ var utils = require('../utils/writer.js');
|
||||
var User = require('../service/UserService');
|
||||
|
||||
module.exports.createUser = function createUser (req, res, next) {
|
||||
var body = req.swagger.params['body'].value;
|
||||
User.createUser(body)
|
||||
var user = req.swagger.params['User'].value;
|
||||
User.createUser(user)
|
||||
.then(function (response) {
|
||||
utils.writeJson(res, response);
|
||||
})
|
||||
@ -15,8 +15,8 @@ module.exports.createUser = function createUser (req, res, next) {
|
||||
};
|
||||
|
||||
module.exports.createUsersWithArrayInput = function createUsersWithArrayInput (req, res, next) {
|
||||
var body = req.swagger.params['body'].value;
|
||||
User.createUsersWithArrayInput(body)
|
||||
var user = req.swagger.params['User'].value;
|
||||
User.createUsersWithArrayInput(user)
|
||||
.then(function (response) {
|
||||
utils.writeJson(res, response);
|
||||
})
|
||||
@ -26,8 +26,8 @@ module.exports.createUsersWithArrayInput = function createUsersWithArrayInput (r
|
||||
};
|
||||
|
||||
module.exports.createUsersWithListInput = function createUsersWithListInput (req, res, next) {
|
||||
var body = req.swagger.params['body'].value;
|
||||
User.createUsersWithListInput(body)
|
||||
var user = req.swagger.params['User'].value;
|
||||
User.createUsersWithListInput(user)
|
||||
.then(function (response) {
|
||||
utils.writeJson(res, response);
|
||||
})
|
||||
@ -82,8 +82,8 @@ module.exports.logoutUser = function logoutUser (req, res, next) {
|
||||
|
||||
module.exports.updateUser = function updateUser (req, res, next) {
|
||||
var username = req.swagger.params['username'].value;
|
||||
var body = req.swagger.params['body'].value;
|
||||
User.updateUser(username,body)
|
||||
var user = req.swagger.params['User'].value;
|
||||
User.updateUser(username,user)
|
||||
.then(function (response) {
|
||||
utils.writeJson(res, response);
|
||||
})
|
||||
|
@ -3,12 +3,11 @@
|
||||
|
||||
/**
|
||||
* Add a new pet to the store
|
||||
*
|
||||
*
|
||||
* body Pet Pet object that needs to be added to the store
|
||||
* pet Pet Pet object that needs to be added to the store
|
||||
* no response value expected for this operation
|
||||
**/
|
||||
exports.addPet = function(body) {
|
||||
exports.addPet = function(pet) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
resolve();
|
||||
});
|
||||
@ -17,7 +16,6 @@ exports.addPet = function(body) {
|
||||
|
||||
/**
|
||||
* Deletes a pet
|
||||
*
|
||||
*
|
||||
* petId Long Pet id to delete
|
||||
* api_key String (optional)
|
||||
@ -40,7 +38,7 @@ exports.deletePet = function(petId,api_key) {
|
||||
exports.findPetsByStatus = function(status) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
var examples = {};
|
||||
examples['application/json'] = [ {
|
||||
examples['application/json'] = {
|
||||
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||
"name" : "doggie",
|
||||
"id" : 0,
|
||||
@ -56,23 +54,7 @@ exports.findPetsByStatus = function(status) {
|
||||
"id" : 1
|
||||
} ],
|
||||
"status" : "available"
|
||||
}, {
|
||||
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||
"name" : "doggie",
|
||||
"id" : 0,
|
||||
"category" : {
|
||||
"name" : "name",
|
||||
"id" : 6
|
||||
},
|
||||
"tags" : [ {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
}, {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
} ],
|
||||
"status" : "available"
|
||||
} ];
|
||||
};
|
||||
if (Object.keys(examples).length > 0) {
|
||||
resolve(examples[Object.keys(examples)[0]]);
|
||||
} else {
|
||||
@ -92,7 +74,7 @@ exports.findPetsByStatus = function(status) {
|
||||
exports.findPetsByTags = function(tags) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
var examples = {};
|
||||
examples['application/json'] = [ {
|
||||
examples['application/json'] = {
|
||||
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||
"name" : "doggie",
|
||||
"id" : 0,
|
||||
@ -108,23 +90,7 @@ exports.findPetsByTags = function(tags) {
|
||||
"id" : 1
|
||||
} ],
|
||||
"status" : "available"
|
||||
}, {
|
||||
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||
"name" : "doggie",
|
||||
"id" : 0,
|
||||
"category" : {
|
||||
"name" : "name",
|
||||
"id" : 6
|
||||
},
|
||||
"tags" : [ {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
}, {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
} ],
|
||||
"status" : "available"
|
||||
} ];
|
||||
};
|
||||
if (Object.keys(examples).length > 0) {
|
||||
resolve(examples[Object.keys(examples)[0]]);
|
||||
} else {
|
||||
@ -172,12 +138,11 @@ exports.getPetById = function(petId) {
|
||||
|
||||
/**
|
||||
* Update an existing pet
|
||||
*
|
||||
*
|
||||
* body Pet Pet object that needs to be added to the store
|
||||
* pet Pet Pet object that needs to be added to the store
|
||||
* no response value expected for this operation
|
||||
**/
|
||||
exports.updatePet = function(body) {
|
||||
exports.updatePet = function(pet) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
resolve();
|
||||
});
|
||||
@ -186,7 +151,6 @@ exports.updatePet = function(body) {
|
||||
|
||||
/**
|
||||
* Updates a pet in the store with form data
|
||||
*
|
||||
*
|
||||
* petId Long ID of pet that needs to be updated
|
||||
* name String Updated name of the pet (optional)
|
||||
@ -202,7 +166,6 @@ exports.updatePetWithForm = function(petId,name,status) {
|
||||
|
||||
/**
|
||||
* uploads an image
|
||||
*
|
||||
*
|
||||
* petId Long ID of pet to update
|
||||
* additionalMetadata String Additional data to pass to server (optional)
|
||||
|
@ -65,12 +65,11 @@ exports.getOrderById = function(orderId) {
|
||||
|
||||
/**
|
||||
* Place an order for a pet
|
||||
*
|
||||
*
|
||||
* body Order order placed for purchasing the pet
|
||||
* order Order order placed for purchasing the pet
|
||||
* returns Order
|
||||
**/
|
||||
exports.placeOrder = function(body) {
|
||||
exports.placeOrder = function(order) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
var examples = {};
|
||||
examples['application/json'] = {
|
||||
|
@ -5,10 +5,10 @@
|
||||
* Create user
|
||||
* This can only be done by the logged in user.
|
||||
*
|
||||
* body User Created user object
|
||||
* user User Created user object
|
||||
* no response value expected for this operation
|
||||
**/
|
||||
exports.createUser = function(body) {
|
||||
exports.createUser = function(user) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
resolve();
|
||||
});
|
||||
@ -17,12 +17,11 @@ exports.createUser = function(body) {
|
||||
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
*
|
||||
*
|
||||
* body List List of user object
|
||||
* user List List of user object
|
||||
* no response value expected for this operation
|
||||
**/
|
||||
exports.createUsersWithArrayInput = function(body) {
|
||||
exports.createUsersWithArrayInput = function(user) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
resolve();
|
||||
});
|
||||
@ -31,12 +30,11 @@ exports.createUsersWithArrayInput = function(body) {
|
||||
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
*
|
||||
*
|
||||
* body List List of user object
|
||||
* user List List of user object
|
||||
* no response value expected for this operation
|
||||
**/
|
||||
exports.createUsersWithListInput = function(body) {
|
||||
exports.createUsersWithListInput = function(user) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
resolve();
|
||||
});
|
||||
@ -59,7 +57,6 @@ exports.deleteUser = function(username) {
|
||||
|
||||
/**
|
||||
* Get user by user name
|
||||
*
|
||||
*
|
||||
* username String The name that needs to be fetched. Use user1 for testing.
|
||||
* returns User
|
||||
@ -88,7 +85,6 @@ exports.getUserByName = function(username) {
|
||||
|
||||
/**
|
||||
* Logs user into the system
|
||||
*
|
||||
*
|
||||
* username String The user name for login
|
||||
* password String The password for login in clear text
|
||||
@ -109,7 +105,6 @@ exports.loginUser = function(username,password) {
|
||||
|
||||
/**
|
||||
* Logs out current logged in user session
|
||||
*
|
||||
*
|
||||
* no response value expected for this operation
|
||||
**/
|
||||
@ -125,10 +120,10 @@ exports.logoutUser = function() {
|
||||
* This can only be done by the logged in user.
|
||||
*
|
||||
* username String name that need to be deleted
|
||||
* body User Updated user object
|
||||
* user User Updated user object
|
||||
* no response value expected for this operation
|
||||
**/
|
||||
exports.updateUser = function(username,body) {
|
||||
exports.updateUser = function(username,user) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
resolve();
|
||||
});
|
||||
|
@ -1 +1 @@
|
||||
2.4.0-SNAPSHOT
|
||||
3.0.0-SNAPSHOT
|
784
samples/server/petstore/nodejs/api/openapi.yaml
Normal file
784
samples/server/petstore/nodejs/api/openapi.yaml
Normal file
@ -0,0 +1,784 @@
|
||||
openapi: 3.0.0
|
||||
info:
|
||||
title: Swagger Petstore
|
||||
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.'
|
||||
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
|
||||
version: 1.0.0
|
||||
externalDocs:
|
||||
description: Find out more about Swagger
|
||||
url: http://swagger.io
|
||||
servers:
|
||||
- url: http://petstore.swagger.io/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
|
||||
paths:
|
||||
/pet:
|
||||
put:
|
||||
tags:
|
||||
- pet
|
||||
summary: Update an existing pet
|
||||
operationId: updatePet
|
||||
requestBody:
|
||||
$ref: '#/components/requestBodies/Pet'
|
||||
responses:
|
||||
400:
|
||||
description: Invalid ID supplied
|
||||
404:
|
||||
description: Pet not found
|
||||
405:
|
||||
description: Validation exception
|
||||
security:
|
||||
- petstore_auth:
|
||||
- write:pets
|
||||
- read:pets
|
||||
x-openapi-router-controller: Pet
|
||||
post:
|
||||
tags:
|
||||
- pet
|
||||
summary: Add a new pet to the store
|
||||
operationId: addPet
|
||||
requestBody:
|
||||
$ref: '#/components/requestBodies/Pet'
|
||||
responses:
|
||||
405:
|
||||
description: Invalid input
|
||||
security:
|
||||
- petstore_auth:
|
||||
- write:pets
|
||||
- read:pets
|
||||
x-openapi-router-controller: Pet
|
||||
/pet/findByStatus:
|
||||
get:
|
||||
tags:
|
||||
- pet
|
||||
summary: Finds Pets by status
|
||||
description: Multiple status values can be provided with comma separated strings
|
||||
operationId: findPetsByStatus
|
||||
parameters:
|
||||
- name: status
|
||||
in: query
|
||||
description: Status values that need to be considered for filter
|
||||
required: true
|
||||
style: form
|
||||
explode: false
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
default: available
|
||||
enum:
|
||||
- available
|
||||
- pending
|
||||
- sold
|
||||
responses:
|
||||
200:
|
||||
description: successful operation
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
400:
|
||||
description: Invalid status value
|
||||
security:
|
||||
- petstore_auth:
|
||||
- write:pets
|
||||
- read:pets
|
||||
x-openapi-router-controller: Pet
|
||||
/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
|
||||
parameters:
|
||||
- name: tags
|
||||
in: query
|
||||
description: Tags to filter by
|
||||
required: true
|
||||
style: form
|
||||
explode: false
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
responses:
|
||||
200:
|
||||
description: successful operation
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
400:
|
||||
description: Invalid tag value
|
||||
deprecated: true
|
||||
security:
|
||||
- petstore_auth:
|
||||
- write:pets
|
||||
- read:pets
|
||||
x-openapi-router-controller: Pet
|
||||
/pet/{petId}:
|
||||
get:
|
||||
tags:
|
||||
- pet
|
||||
summary: Find pet by ID
|
||||
description: Returns a single pet
|
||||
operationId: getPetById
|
||||
parameters:
|
||||
- name: petId
|
||||
in: path
|
||||
description: ID of pet to return
|
||||
required: true
|
||||
style: simple
|
||||
explode: false
|
||||
schema:
|
||||
type: integer
|
||||
format: int64
|
||||
responses:
|
||||
200:
|
||||
description: successful operation
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
400:
|
||||
description: Invalid ID supplied
|
||||
404:
|
||||
description: Pet not found
|
||||
security:
|
||||
- api_key: []
|
||||
x-openapi-router-controller: Pet
|
||||
post:
|
||||
tags:
|
||||
- pet
|
||||
summary: Updates a pet in the store with form data
|
||||
operationId: updatePetWithForm
|
||||
parameters:
|
||||
- name: petId
|
||||
in: path
|
||||
description: ID of pet that needs to be updated
|
||||
required: true
|
||||
style: simple
|
||||
explode: false
|
||||
schema:
|
||||
type: integer
|
||||
format: int64
|
||||
requestBody:
|
||||
content:
|
||||
application/x-www-form-urlencoded:
|
||||
schema:
|
||||
$ref: '#/components/schemas/body'
|
||||
responses:
|
||||
405:
|
||||
description: Invalid input
|
||||
security:
|
||||
- petstore_auth:
|
||||
- write:pets
|
||||
- read:pets
|
||||
x-openapi-router-controller: Pet
|
||||
delete:
|
||||
tags:
|
||||
- pet
|
||||
summary: Deletes a pet
|
||||
operationId: deletePet
|
||||
parameters:
|
||||
- name: api_key
|
||||
in: header
|
||||
required: false
|
||||
style: simple
|
||||
explode: false
|
||||
schema:
|
||||
type: string
|
||||
- name: petId
|
||||
in: path
|
||||
description: Pet id to delete
|
||||
required: true
|
||||
style: simple
|
||||
explode: false
|
||||
schema:
|
||||
type: integer
|
||||
format: int64
|
||||
responses:
|
||||
400:
|
||||
description: Invalid pet value
|
||||
security:
|
||||
- petstore_auth:
|
||||
- write:pets
|
||||
- read:pets
|
||||
x-openapi-router-controller: Pet
|
||||
/pet/{petId}/uploadImage:
|
||||
post:
|
||||
tags:
|
||||
- pet
|
||||
summary: uploads an image
|
||||
operationId: uploadFile
|
||||
parameters:
|
||||
- name: petId
|
||||
in: path
|
||||
description: ID of pet to update
|
||||
required: true
|
||||
style: simple
|
||||
explode: false
|
||||
schema:
|
||||
type: integer
|
||||
format: int64
|
||||
requestBody:
|
||||
content:
|
||||
multipart/form-data:
|
||||
schema:
|
||||
$ref: '#/components/schemas/body_1'
|
||||
responses:
|
||||
200:
|
||||
description: successful operation
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ApiResponse'
|
||||
security:
|
||||
- petstore_auth:
|
||||
- write:pets
|
||||
- read:pets
|
||||
x-openapi-router-controller: Pet
|
||||
/store/inventory:
|
||||
get:
|
||||
tags:
|
||||
- store
|
||||
summary: Returns pet inventories by status
|
||||
description: Returns a map of status codes to quantities
|
||||
operationId: getInventory
|
||||
responses:
|
||||
200:
|
||||
description: successful operation
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
additionalProperties:
|
||||
type: integer
|
||||
format: int32
|
||||
security:
|
||||
- api_key: []
|
||||
x-openapi-router-controller: Store
|
||||
/store/order:
|
||||
post:
|
||||
tags:
|
||||
- store
|
||||
summary: Place an order for a pet
|
||||
operationId: placeOrder
|
||||
requestBody:
|
||||
description: order placed for purchasing the pet
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Order'
|
||||
required: true
|
||||
responses:
|
||||
200:
|
||||
description: successful operation
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Order'
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Order'
|
||||
400:
|
||||
description: Invalid Order
|
||||
x-openapi-router-controller: Store
|
||||
/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
|
||||
parameters:
|
||||
- name: orderId
|
||||
in: path
|
||||
description: ID of pet that needs to be fetched
|
||||
required: true
|
||||
style: simple
|
||||
explode: false
|
||||
schema:
|
||||
maximum: 5
|
||||
minimum: 1
|
||||
type: integer
|
||||
format: int64
|
||||
responses:
|
||||
200:
|
||||
description: successful operation
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Order'
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Order'
|
||||
400:
|
||||
description: Invalid ID supplied
|
||||
404:
|
||||
description: Order not found
|
||||
x-openapi-router-controller: Store
|
||||
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
|
||||
parameters:
|
||||
- name: orderId
|
||||
in: path
|
||||
description: ID of the order that needs to be deleted
|
||||
required: true
|
||||
style: simple
|
||||
explode: false
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
400:
|
||||
description: Invalid ID supplied
|
||||
404:
|
||||
description: Order not found
|
||||
x-openapi-router-controller: Store
|
||||
/user:
|
||||
post:
|
||||
tags:
|
||||
- user
|
||||
summary: Create user
|
||||
description: This can only be done by the logged in user.
|
||||
operationId: createUser
|
||||
requestBody:
|
||||
description: Created user object
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/User'
|
||||
required: true
|
||||
responses:
|
||||
default:
|
||||
description: successful operation
|
||||
x-openapi-router-controller: User
|
||||
/user/createWithArray:
|
||||
post:
|
||||
tags:
|
||||
- user
|
||||
summary: Creates list of users with given input array
|
||||
operationId: createUsersWithArrayInput
|
||||
requestBody:
|
||||
$ref: '#/components/requestBodies/UserArray'
|
||||
responses:
|
||||
default:
|
||||
description: successful operation
|
||||
x-openapi-router-controller: User
|
||||
/user/createWithList:
|
||||
post:
|
||||
tags:
|
||||
- user
|
||||
summary: Creates list of users with given input array
|
||||
operationId: createUsersWithListInput
|
||||
requestBody:
|
||||
$ref: '#/components/requestBodies/UserArray'
|
||||
responses:
|
||||
default:
|
||||
description: successful operation
|
||||
x-openapi-router-controller: User
|
||||
/user/login:
|
||||
get:
|
||||
tags:
|
||||
- user
|
||||
summary: Logs user into the system
|
||||
operationId: loginUser
|
||||
parameters:
|
||||
- name: username
|
||||
in: query
|
||||
description: The user name for login
|
||||
required: true
|
||||
style: form
|
||||
explode: true
|
||||
schema:
|
||||
type: string
|
||||
- name: password
|
||||
in: query
|
||||
description: The password for login in clear text
|
||||
required: true
|
||||
style: form
|
||||
explode: true
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
200:
|
||||
description: successful operation
|
||||
headers:
|
||||
X-Rate-Limit:
|
||||
description: calls per hour allowed by the user
|
||||
style: simple
|
||||
explode: false
|
||||
schema:
|
||||
type: integer
|
||||
format: int32
|
||||
X-Expires-After:
|
||||
description: date in UTC when toekn expires
|
||||
style: simple
|
||||
explode: false
|
||||
schema:
|
||||
type: string
|
||||
format: date-time
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
type: string
|
||||
application/json:
|
||||
schema:
|
||||
type: string
|
||||
400:
|
||||
description: Invalid username/password supplied
|
||||
x-openapi-router-controller: User
|
||||
/user/logout:
|
||||
get:
|
||||
tags:
|
||||
- user
|
||||
summary: Logs out current logged in user session
|
||||
operationId: logoutUser
|
||||
responses:
|
||||
default:
|
||||
description: successful operation
|
||||
x-openapi-router-controller: User
|
||||
/user/{username}:
|
||||
get:
|
||||
tags:
|
||||
- user
|
||||
summary: Get user by user name
|
||||
operationId: getUserByName
|
||||
parameters:
|
||||
- name: username
|
||||
in: path
|
||||
description: The name that needs to be fetched. Use user1 for testing.
|
||||
required: true
|
||||
style: simple
|
||||
explode: false
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
200:
|
||||
description: successful operation
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
$ref: '#/components/schemas/User'
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/User'
|
||||
400:
|
||||
description: Invalid username supplied
|
||||
404:
|
||||
description: User not found
|
||||
x-openapi-router-controller: User
|
||||
put:
|
||||
tags:
|
||||
- user
|
||||
summary: Updated user
|
||||
description: This can only be done by the logged in user.
|
||||
operationId: updateUser
|
||||
parameters:
|
||||
- name: username
|
||||
in: path
|
||||
description: name that need to be deleted
|
||||
required: true
|
||||
style: simple
|
||||
explode: false
|
||||
schema:
|
||||
type: string
|
||||
requestBody:
|
||||
description: Updated user object
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/User'
|
||||
required: true
|
||||
responses:
|
||||
400:
|
||||
description: Invalid user supplied
|
||||
404:
|
||||
description: User not found
|
||||
x-openapi-router-controller: User
|
||||
delete:
|
||||
tags:
|
||||
- user
|
||||
summary: Delete user
|
||||
description: This can only be done by the logged in user.
|
||||
operationId: deleteUser
|
||||
parameters:
|
||||
- name: username
|
||||
in: path
|
||||
description: The name that needs to be deleted
|
||||
required: true
|
||||
style: simple
|
||||
explode: false
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
400:
|
||||
description: Invalid username supplied
|
||||
404:
|
||||
description: User not found
|
||||
x-openapi-router-controller: User
|
||||
components:
|
||||
schemas:
|
||||
Order:
|
||||
title: Pet 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
|
||||
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:
|
||||
title: Pet category
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
format: int64
|
||||
name:
|
||||
type: string
|
||||
description: A category for a pet
|
||||
example:
|
||||
name: name
|
||||
id: 6
|
||||
xml:
|
||||
name: Category
|
||||
User:
|
||||
title: a 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
|
||||
description: User Status
|
||||
format: int32
|
||||
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:
|
||||
title: Pet Tag
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
format: int64
|
||||
name:
|
||||
type: string
|
||||
description: A tag for a pet
|
||||
example:
|
||||
name: name
|
||||
id: 1
|
||||
xml:
|
||||
name: Tag
|
||||
Pet:
|
||||
title: a Pet
|
||||
required:
|
||||
- name
|
||||
- photoUrls
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
format: int64
|
||||
category:
|
||||
$ref: '#/components/schemas/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: '#/components/schemas/Tag'
|
||||
status:
|
||||
type: string
|
||||
description: pet status in the store
|
||||
enum:
|
||||
- available
|
||||
- pending
|
||||
- sold
|
||||
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:
|
||||
title: An uploaded response
|
||||
type: object
|
||||
properties:
|
||||
code:
|
||||
type: integer
|
||||
format: int32
|
||||
type:
|
||||
type: string
|
||||
message:
|
||||
type: string
|
||||
description: Describes the result of uploading an image resource
|
||||
example:
|
||||
code: 0
|
||||
type: type
|
||||
message: message
|
||||
body:
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
description: Updated name of the pet
|
||||
status:
|
||||
type: string
|
||||
description: Updated status of the pet
|
||||
body_1:
|
||||
type: object
|
||||
properties:
|
||||
additionalMetadata:
|
||||
type: string
|
||||
description: Additional data to pass to server
|
||||
file:
|
||||
type: string
|
||||
description: file to upload
|
||||
format: binary
|
||||
requestBodies:
|
||||
UserArray:
|
||||
description: List of user object
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/User'
|
||||
required: true
|
||||
Pet:
|
||||
description: Pet object that needs to be added to the store
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
application/xml:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
required: true
|
||||
securitySchemes:
|
||||
petstore_auth:
|
||||
type: oauth2
|
||||
flows:
|
||||
implicit:
|
||||
authorizationUrl: http://petstore.swagger.io/api/oauth/dialog
|
||||
scopes:
|
||||
write:pets: modify pets in your account
|
||||
read:pets: read your pets
|
||||
api_key:
|
||||
type: apiKey
|
||||
name: api_key
|
||||
in: header
|
@ -4,8 +4,8 @@ var utils = require('../utils/writer.js');
|
||||
var Pet = require('../service/PetService');
|
||||
|
||||
module.exports.addPet = function addPet (req, res, next) {
|
||||
var body = req.swagger.params['body'].value;
|
||||
Pet.addPet(body)
|
||||
var pet = req.swagger.params['Pet'].value;
|
||||
Pet.addPet(pet)
|
||||
.then(function (response) {
|
||||
utils.writeJson(res, response);
|
||||
})
|
||||
@ -60,8 +60,8 @@ module.exports.getPetById = function getPetById (req, res, next) {
|
||||
};
|
||||
|
||||
module.exports.updatePet = function updatePet (req, res, next) {
|
||||
var body = req.swagger.params['body'].value;
|
||||
Pet.updatePet(body)
|
||||
var pet = req.swagger.params['Pet'].value;
|
||||
Pet.updatePet(pet)
|
||||
.then(function (response) {
|
||||
utils.writeJson(res, response);
|
||||
})
|
||||
|
@ -36,8 +36,8 @@ module.exports.getOrderById = function getOrderById (req, res, next) {
|
||||
};
|
||||
|
||||
module.exports.placeOrder = function placeOrder (req, res, next) {
|
||||
var body = req.swagger.params['body'].value;
|
||||
Store.placeOrder(body)
|
||||
var order = req.swagger.params['Order'].value;
|
||||
Store.placeOrder(order)
|
||||
.then(function (response) {
|
||||
utils.writeJson(res, response);
|
||||
})
|
||||
|
@ -4,8 +4,8 @@ var utils = require('../utils/writer.js');
|
||||
var User = require('../service/UserService');
|
||||
|
||||
module.exports.createUser = function createUser (req, res, next) {
|
||||
var body = req.swagger.params['body'].value;
|
||||
User.createUser(body)
|
||||
var user = req.swagger.params['User'].value;
|
||||
User.createUser(user)
|
||||
.then(function (response) {
|
||||
utils.writeJson(res, response);
|
||||
})
|
||||
@ -15,8 +15,8 @@ module.exports.createUser = function createUser (req, res, next) {
|
||||
};
|
||||
|
||||
module.exports.createUsersWithArrayInput = function createUsersWithArrayInput (req, res, next) {
|
||||
var body = req.swagger.params['body'].value;
|
||||
User.createUsersWithArrayInput(body)
|
||||
var user = req.swagger.params['User'].value;
|
||||
User.createUsersWithArrayInput(user)
|
||||
.then(function (response) {
|
||||
utils.writeJson(res, response);
|
||||
})
|
||||
@ -26,8 +26,8 @@ module.exports.createUsersWithArrayInput = function createUsersWithArrayInput (r
|
||||
};
|
||||
|
||||
module.exports.createUsersWithListInput = function createUsersWithListInput (req, res, next) {
|
||||
var body = req.swagger.params['body'].value;
|
||||
User.createUsersWithListInput(body)
|
||||
var user = req.swagger.params['User'].value;
|
||||
User.createUsersWithListInput(user)
|
||||
.then(function (response) {
|
||||
utils.writeJson(res, response);
|
||||
})
|
||||
@ -82,8 +82,8 @@ module.exports.logoutUser = function logoutUser (req, res, next) {
|
||||
|
||||
module.exports.updateUser = function updateUser (req, res, next) {
|
||||
var username = req.swagger.params['username'].value;
|
||||
var body = req.swagger.params['body'].value;
|
||||
User.updateUser(username,body)
|
||||
var user = req.swagger.params['User'].value;
|
||||
User.updateUser(username,user)
|
||||
.then(function (response) {
|
||||
utils.writeJson(res, response);
|
||||
})
|
||||
|
@ -3,12 +3,11 @@
|
||||
|
||||
/**
|
||||
* Add a new pet to the store
|
||||
*
|
||||
*
|
||||
* body Pet Pet object that needs to be added to the store
|
||||
* pet Pet Pet object that needs to be added to the store
|
||||
* no response value expected for this operation
|
||||
**/
|
||||
exports.addPet = function(body) {
|
||||
exports.addPet = function(pet) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
resolve();
|
||||
});
|
||||
@ -17,7 +16,6 @@ exports.addPet = function(body) {
|
||||
|
||||
/**
|
||||
* Deletes a pet
|
||||
*
|
||||
*
|
||||
* petId Long Pet id to delete
|
||||
* api_key String (optional)
|
||||
@ -40,7 +38,7 @@ exports.deletePet = function(petId,api_key) {
|
||||
exports.findPetsByStatus = function(status) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
var examples = {};
|
||||
examples['application/json'] = [ {
|
||||
examples['application/json'] = {
|
||||
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||
"name" : "doggie",
|
||||
"id" : 0,
|
||||
@ -56,23 +54,7 @@ exports.findPetsByStatus = function(status) {
|
||||
"id" : 1
|
||||
} ],
|
||||
"status" : "available"
|
||||
}, {
|
||||
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||
"name" : "doggie",
|
||||
"id" : 0,
|
||||
"category" : {
|
||||
"name" : "name",
|
||||
"id" : 6
|
||||
},
|
||||
"tags" : [ {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
}, {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
} ],
|
||||
"status" : "available"
|
||||
} ];
|
||||
};
|
||||
if (Object.keys(examples).length > 0) {
|
||||
resolve(examples[Object.keys(examples)[0]]);
|
||||
} else {
|
||||
@ -92,7 +74,7 @@ exports.findPetsByStatus = function(status) {
|
||||
exports.findPetsByTags = function(tags) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
var examples = {};
|
||||
examples['application/json'] = [ {
|
||||
examples['application/json'] = {
|
||||
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||
"name" : "doggie",
|
||||
"id" : 0,
|
||||
@ -108,23 +90,7 @@ exports.findPetsByTags = function(tags) {
|
||||
"id" : 1
|
||||
} ],
|
||||
"status" : "available"
|
||||
}, {
|
||||
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||
"name" : "doggie",
|
||||
"id" : 0,
|
||||
"category" : {
|
||||
"name" : "name",
|
||||
"id" : 6
|
||||
},
|
||||
"tags" : [ {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
}, {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
} ],
|
||||
"status" : "available"
|
||||
} ];
|
||||
};
|
||||
if (Object.keys(examples).length > 0) {
|
||||
resolve(examples[Object.keys(examples)[0]]);
|
||||
} else {
|
||||
@ -172,12 +138,11 @@ exports.getPetById = function(petId) {
|
||||
|
||||
/**
|
||||
* Update an existing pet
|
||||
*
|
||||
*
|
||||
* body Pet Pet object that needs to be added to the store
|
||||
* pet Pet Pet object that needs to be added to the store
|
||||
* no response value expected for this operation
|
||||
**/
|
||||
exports.updatePet = function(body) {
|
||||
exports.updatePet = function(pet) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
resolve();
|
||||
});
|
||||
@ -186,7 +151,6 @@ exports.updatePet = function(body) {
|
||||
|
||||
/**
|
||||
* Updates a pet in the store with form data
|
||||
*
|
||||
*
|
||||
* petId Long ID of pet that needs to be updated
|
||||
* name String Updated name of the pet (optional)
|
||||
@ -202,7 +166,6 @@ exports.updatePetWithForm = function(petId,name,status) {
|
||||
|
||||
/**
|
||||
* uploads an image
|
||||
*
|
||||
*
|
||||
* petId Long ID of pet to update
|
||||
* additionalMetadata String Additional data to pass to server (optional)
|
||||
|
@ -65,12 +65,11 @@ exports.getOrderById = function(orderId) {
|
||||
|
||||
/**
|
||||
* Place an order for a pet
|
||||
*
|
||||
*
|
||||
* body Order order placed for purchasing the pet
|
||||
* order Order order placed for purchasing the pet
|
||||
* returns Order
|
||||
**/
|
||||
exports.placeOrder = function(body) {
|
||||
exports.placeOrder = function(order) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
var examples = {};
|
||||
examples['application/json'] = {
|
||||
|
@ -5,10 +5,10 @@
|
||||
* Create user
|
||||
* This can only be done by the logged in user.
|
||||
*
|
||||
* body User Created user object
|
||||
* user User Created user object
|
||||
* no response value expected for this operation
|
||||
**/
|
||||
exports.createUser = function(body) {
|
||||
exports.createUser = function(user) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
resolve();
|
||||
});
|
||||
@ -17,12 +17,11 @@ exports.createUser = function(body) {
|
||||
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
*
|
||||
*
|
||||
* body List List of user object
|
||||
* user List List of user object
|
||||
* no response value expected for this operation
|
||||
**/
|
||||
exports.createUsersWithArrayInput = function(body) {
|
||||
exports.createUsersWithArrayInput = function(user) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
resolve();
|
||||
});
|
||||
@ -31,12 +30,11 @@ exports.createUsersWithArrayInput = function(body) {
|
||||
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
*
|
||||
*
|
||||
* body List List of user object
|
||||
* user List List of user object
|
||||
* no response value expected for this operation
|
||||
**/
|
||||
exports.createUsersWithListInput = function(body) {
|
||||
exports.createUsersWithListInput = function(user) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
resolve();
|
||||
});
|
||||
@ -59,7 +57,6 @@ exports.deleteUser = function(username) {
|
||||
|
||||
/**
|
||||
* Get user by user name
|
||||
*
|
||||
*
|
||||
* username String The name that needs to be fetched. Use user1 for testing.
|
||||
* returns User
|
||||
@ -88,7 +85,6 @@ exports.getUserByName = function(username) {
|
||||
|
||||
/**
|
||||
* Logs user into the system
|
||||
*
|
||||
*
|
||||
* username String The user name for login
|
||||
* password String The password for login in clear text
|
||||
@ -109,7 +105,6 @@ exports.loginUser = function(username,password) {
|
||||
|
||||
/**
|
||||
* Logs out current logged in user session
|
||||
*
|
||||
*
|
||||
* no response value expected for this operation
|
||||
**/
|
||||
@ -125,10 +120,10 @@ exports.logoutUser = function() {
|
||||
* This can only be done by the logged in user.
|
||||
*
|
||||
* username String name that need to be deleted
|
||||
* body User Updated user object
|
||||
* user User Updated user object
|
||||
* no response value expected for this operation
|
||||
**/
|
||||
exports.updateUser = function(username,body) {
|
||||
exports.updateUser = function(username,user) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
resolve();
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user