forked from loafle/openapi-generator-original
remove nodejs server samples, scripts (#4919)
This commit is contained in:
parent
6dc3216f6d
commit
965efdd965
@ -1,32 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
SCRIPT="$0"
|
|
||||||
echo "# START SCRIPT: $SCRIPT"
|
|
||||||
|
|
||||||
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 -B clean package
|
|
||||||
fi
|
|
||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
|
||||||
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g nodejs-server-deprecated --additional-properties=googleCloudFunctions=true -o samples/server/petstore/nodejs-google-cloud-functions -Dservice $@"
|
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
|
@ -1,32 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
SCRIPT="$0"
|
|
||||||
echo "# START SCRIPT: $SCRIPT"
|
|
||||||
|
|
||||||
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 -B clean package
|
|
||||||
fi
|
|
||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
|
||||||
ags="generate -t modules/openapi-generator/src/main/resources/nodejs -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g nodejs-server-deprecated -o samples/server/petstore/nodejs -Dservice $@"
|
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
|
@ -1,32 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
SCRIPT="$0"
|
|
||||||
echo "# START SCRIPT: $SCRIPT"
|
|
||||||
|
|
||||||
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} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
|
||||||
ags="generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g nodejs-server-deprecated --additional-properties=googleCloudFunctions=true -o samples/server/petstore/nodejs-google-cloud-functions -Dservice $@"
|
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
|
@ -1,32 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
SCRIPT="$0"
|
|
||||||
echo "# START SCRIPT: $SCRIPT"
|
|
||||||
|
|
||||||
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} -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 -g nodejs-server-deprecated -o samples/server/petstore/nodejs -Dservice $@"
|
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "openapi-petstore",
|
"name": "{{projectName}}",
|
||||||
"version": "1.0.0",
|
"version": "{{appVersion}}",
|
||||||
"description": "This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.",
|
"description": "{{{appDescription}}}",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prestart": "npm install",
|
"prestart": "npm install",
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
# OpenAPI Generator Ignore
|
|
||||||
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
|
|
||||||
|
|
||||||
# Use this file to prevent files from being overwritten by the generator.
|
|
||||||
# The patterns follow closely to .gitignore or .dockerignore.
|
|
||||||
|
|
||||||
# As an example, the C# client generator defines ApiClient.cs.
|
|
||||||
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
|
|
||||||
#ApiClient.cs
|
|
||||||
|
|
||||||
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
|
||||||
#foo/*/qux
|
|
||||||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
|
||||||
|
|
||||||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
|
||||||
#foo/**/qux
|
|
||||||
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
|
||||||
|
|
||||||
# You can also negate patterns with an exclamation (!).
|
|
||||||
# For example, you can ignore all files in a docs folder with the file extension .md:
|
|
||||||
#docs/*.md
|
|
||||||
# Then explicitly reverse the ignore rule for a single file:
|
|
||||||
#!docs/README.md
|
|
@ -1 +0,0 @@
|
|||||||
4.0.2-SNAPSHOT
|
|
@ -1,11 +0,0 @@
|
|||||||
# Swagger generated server
|
|
||||||
|
|
||||||
## Overview
|
|
||||||
This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the [OpenAPI-Spec](https://github.com/OAI/OpenAPI-Specification) from a remote server, you can easily generate a server stub.
|
|
||||||
|
|
||||||
### Deploying the function
|
|
||||||
To deploy this module into Google Cloud Functions, you will have to use Google Cloud SDK commandline tool.
|
|
||||||
|
|
||||||
See [Google Cloud Functions quick start guide](https://cloud.google.com/functions/docs/quickstart) and [Deploying Cloud Functions](https://cloud.google.com/functions/docs/deploying/) for the details.
|
|
||||||
|
|
||||||
This project leverages the mega-awesome [swagger-tools](https://github.com/apigee-127/swagger-tools) middleware which does most all the work.
|
|
@ -1,837 +0,0 @@
|
|||||||
openapi: 3.0.0
|
|
||||||
info:
|
|
||||||
description: This is a sample server Petstore server. For this sample, you can use
|
|
||||||
the api key `special-key` to test the authorization filters.
|
|
||||||
license:
|
|
||||||
name: Apache-2.0
|
|
||||||
url: http://www.apache.org/licenses/LICENSE-2.0.html
|
|
||||||
title: OpenAPI Petstore
|
|
||||||
version: 1.0.0
|
|
||||||
externalDocs:
|
|
||||||
description: Find out more about Swagger
|
|
||||||
url: http://swagger.io
|
|
||||||
servers:
|
|
||||||
- url: http://petstore.swagger.io/v2
|
|
||||||
tags:
|
|
||||||
- description: Everything about your Pets
|
|
||||||
name: pet
|
|
||||||
- description: Access to Petstore orders
|
|
||||||
name: store
|
|
||||||
- description: Operations about user
|
|
||||||
name: user
|
|
||||||
paths:
|
|
||||||
/pet:
|
|
||||||
post:
|
|
||||||
operationId: addPet
|
|
||||||
requestBody:
|
|
||||||
$ref: '#/components/requestBodies/Pet'
|
|
||||||
responses:
|
|
||||||
405:
|
|
||||||
description: Invalid input
|
|
||||||
security:
|
|
||||||
- petstore_auth:
|
|
||||||
- write:pets
|
|
||||||
- read:pets
|
|
||||||
summary: Add a new pet to the store
|
|
||||||
tags:
|
|
||||||
- pet
|
|
||||||
x-swagger-router-controller: Pet
|
|
||||||
put:
|
|
||||||
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
|
|
||||||
summary: Update an existing pet
|
|
||||||
tags:
|
|
||||||
- pet
|
|
||||||
x-swagger-router-controller: Pet
|
|
||||||
/pet/findByStatus:
|
|
||||||
get:
|
|
||||||
description: Multiple status values can be provided with comma separated strings
|
|
||||||
operationId: findPetsByStatus
|
|
||||||
parameters:
|
|
||||||
- description: Status values that need to be considered for filter
|
|
||||||
explode: false
|
|
||||||
in: query
|
|
||||||
name: status
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
items:
|
|
||||||
default: available
|
|
||||||
enum:
|
|
||||||
- available
|
|
||||||
- pending
|
|
||||||
- sold
|
|
||||||
type: string
|
|
||||||
type: array
|
|
||||||
style: form
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
content:
|
|
||||||
application/xml:
|
|
||||||
schema:
|
|
||||||
items:
|
|
||||||
$ref: '#/components/schemas/Pet'
|
|
||||||
type: array
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
items:
|
|
||||||
$ref: '#/components/schemas/Pet'
|
|
||||||
type: array
|
|
||||||
description: successful operation
|
|
||||||
400:
|
|
||||||
description: Invalid status value
|
|
||||||
security:
|
|
||||||
- petstore_auth:
|
|
||||||
- read:pets
|
|
||||||
summary: Finds Pets by status
|
|
||||||
tags:
|
|
||||||
- pet
|
|
||||||
x-swagger-router-controller: Pet
|
|
||||||
/pet/findByTags:
|
|
||||||
get:
|
|
||||||
deprecated: true
|
|
||||||
description: Multiple tags can be provided with comma separated strings. Use
|
|
||||||
tag1, tag2, tag3 for testing.
|
|
||||||
operationId: findPetsByTags
|
|
||||||
parameters:
|
|
||||||
- description: Tags to filter by
|
|
||||||
explode: false
|
|
||||||
in: query
|
|
||||||
name: tags
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
items:
|
|
||||||
type: string
|
|
||||||
type: array
|
|
||||||
style: form
|
|
||||||
- description: Maximum number of items to return
|
|
||||||
explode: true
|
|
||||||
in: query
|
|
||||||
name: maxCount
|
|
||||||
required: false
|
|
||||||
schema:
|
|
||||||
format: int32
|
|
||||||
type: integer
|
|
||||||
style: form
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
content:
|
|
||||||
application/xml:
|
|
||||||
schema:
|
|
||||||
items:
|
|
||||||
$ref: '#/components/schemas/Pet'
|
|
||||||
type: array
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
items:
|
|
||||||
$ref: '#/components/schemas/Pet'
|
|
||||||
type: array
|
|
||||||
description: successful operation
|
|
||||||
400:
|
|
||||||
description: Invalid tag value
|
|
||||||
security:
|
|
||||||
- petstore_auth:
|
|
||||||
- read:pets
|
|
||||||
summary: Finds Pets by tags
|
|
||||||
tags:
|
|
||||||
- pet
|
|
||||||
x-swagger-router-controller: Pet
|
|
||||||
/pet/{petId}:
|
|
||||||
delete:
|
|
||||||
operationId: deletePet
|
|
||||||
parameters:
|
|
||||||
- explode: false
|
|
||||||
in: header
|
|
||||||
name: api_key
|
|
||||||
required: false
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
style: simple
|
|
||||||
- description: Pet id to delete
|
|
||||||
explode: false
|
|
||||||
in: path
|
|
||||||
name: petId
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
format: int64
|
|
||||||
type: integer
|
|
||||||
style: simple
|
|
||||||
responses:
|
|
||||||
400:
|
|
||||||
description: Invalid pet value
|
|
||||||
security:
|
|
||||||
- petstore_auth:
|
|
||||||
- write:pets
|
|
||||||
- read:pets
|
|
||||||
summary: Deletes a pet
|
|
||||||
tags:
|
|
||||||
- pet
|
|
||||||
x-swagger-router-controller: Pet
|
|
||||||
get:
|
|
||||||
description: Returns a single pet
|
|
||||||
operationId: getPetById
|
|
||||||
parameters:
|
|
||||||
- description: ID of pet to return
|
|
||||||
explode: false
|
|
||||||
in: path
|
|
||||||
name: petId
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
format: int64
|
|
||||||
type: integer
|
|
||||||
style: simple
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
content:
|
|
||||||
application/xml:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/Pet'
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/Pet'
|
|
||||||
description: successful operation
|
|
||||||
400:
|
|
||||||
description: Invalid ID supplied
|
|
||||||
404:
|
|
||||||
description: Pet not found
|
|
||||||
security:
|
|
||||||
- api_key: []
|
|
||||||
summary: Find pet by ID
|
|
||||||
tags:
|
|
||||||
- pet
|
|
||||||
x-swagger-router-controller: Pet
|
|
||||||
post:
|
|
||||||
operationId: updatePetWithForm
|
|
||||||
parameters:
|
|
||||||
- description: ID of pet that needs to be updated
|
|
||||||
explode: false
|
|
||||||
in: path
|
|
||||||
name: petId
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
format: int64
|
|
||||||
type: integer
|
|
||||||
style: simple
|
|
||||||
requestBody:
|
|
||||||
$ref: '#/components/requestBodies/inline_object'
|
|
||||||
content:
|
|
||||||
application/x-www-form-urlencoded:
|
|
||||||
schema:
|
|
||||||
properties:
|
|
||||||
name:
|
|
||||||
description: Updated name of the pet
|
|
||||||
type: string
|
|
||||||
status:
|
|
||||||
description: Updated status of the pet
|
|
||||||
type: string
|
|
||||||
type: object
|
|
||||||
responses:
|
|
||||||
405:
|
|
||||||
description: Invalid input
|
|
||||||
security:
|
|
||||||
- petstore_auth:
|
|
||||||
- write:pets
|
|
||||||
- read:pets
|
|
||||||
summary: Updates a pet in the store with form data
|
|
||||||
tags:
|
|
||||||
- pet
|
|
||||||
x-swagger-router-controller: Pet
|
|
||||||
/pet/{petId}/uploadImage:
|
|
||||||
post:
|
|
||||||
operationId: uploadFile
|
|
||||||
parameters:
|
|
||||||
- description: ID of pet to update
|
|
||||||
explode: false
|
|
||||||
in: path
|
|
||||||
name: petId
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
format: int64
|
|
||||||
type: integer
|
|
||||||
style: simple
|
|
||||||
requestBody:
|
|
||||||
$ref: '#/components/requestBodies/inline_object_1'
|
|
||||||
content:
|
|
||||||
multipart/form-data:
|
|
||||||
schema:
|
|
||||||
properties:
|
|
||||||
additionalMetadata:
|
|
||||||
description: Additional data to pass to server
|
|
||||||
type: string
|
|
||||||
file:
|
|
||||||
description: file to upload
|
|
||||||
format: binary
|
|
||||||
type: string
|
|
||||||
type: object
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/ApiResponse'
|
|
||||||
description: successful operation
|
|
||||||
security:
|
|
||||||
- petstore_auth:
|
|
||||||
- write:pets
|
|
||||||
- read:pets
|
|
||||||
summary: uploads an image
|
|
||||||
tags:
|
|
||||||
- pet
|
|
||||||
x-swagger-router-controller: Pet
|
|
||||||
/store/inventory:
|
|
||||||
get:
|
|
||||||
description: Returns a map of status codes to quantities
|
|
||||||
operationId: getInventory
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
additionalProperties:
|
|
||||||
format: int32
|
|
||||||
type: integer
|
|
||||||
type: object
|
|
||||||
description: successful operation
|
|
||||||
security:
|
|
||||||
- api_key: []
|
|
||||||
summary: Returns pet inventories by status
|
|
||||||
tags:
|
|
||||||
- store
|
|
||||||
x-swagger-router-controller: Store
|
|
||||||
/store/order:
|
|
||||||
post:
|
|
||||||
operationId: placeOrder
|
|
||||||
requestBody:
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/Order'
|
|
||||||
description: order placed for purchasing the pet
|
|
||||||
required: true
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
content:
|
|
||||||
application/xml:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/Order'
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/Order'
|
|
||||||
description: successful operation
|
|
||||||
400:
|
|
||||||
description: Invalid Order
|
|
||||||
summary: Place an order for a pet
|
|
||||||
tags:
|
|
||||||
- store
|
|
||||||
x-swagger-router-controller: Store
|
|
||||||
/store/order/{orderId}:
|
|
||||||
delete:
|
|
||||||
description: For valid response try integer IDs with value < 1000. Anything
|
|
||||||
above 1000 or nonintegers will generate API errors
|
|
||||||
operationId: deleteOrder
|
|
||||||
parameters:
|
|
||||||
- description: ID of the order that needs to be deleted
|
|
||||||
explode: false
|
|
||||||
in: path
|
|
||||||
name: orderId
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
style: simple
|
|
||||||
responses:
|
|
||||||
400:
|
|
||||||
description: Invalid ID supplied
|
|
||||||
404:
|
|
||||||
description: Order not found
|
|
||||||
summary: Delete purchase order by ID
|
|
||||||
tags:
|
|
||||||
- store
|
|
||||||
x-swagger-router-controller: Store
|
|
||||||
get:
|
|
||||||
description: For valid response try integer IDs with value <= 5 or > 10. Other
|
|
||||||
values will generated exceptions
|
|
||||||
operationId: getOrderById
|
|
||||||
parameters:
|
|
||||||
- description: ID of pet that needs to be fetched
|
|
||||||
explode: false
|
|
||||||
in: path
|
|
||||||
name: orderId
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
format: int64
|
|
||||||
maximum: 5
|
|
||||||
minimum: 1
|
|
||||||
type: integer
|
|
||||||
style: simple
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
content:
|
|
||||||
application/xml:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/Order'
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/Order'
|
|
||||||
description: successful operation
|
|
||||||
400:
|
|
||||||
description: Invalid ID supplied
|
|
||||||
404:
|
|
||||||
description: Order not found
|
|
||||||
summary: Find purchase order by ID
|
|
||||||
tags:
|
|
||||||
- store
|
|
||||||
x-swagger-router-controller: Store
|
|
||||||
/user:
|
|
||||||
post:
|
|
||||||
description: This can only be done by the logged in user.
|
|
||||||
operationId: createUser
|
|
||||||
requestBody:
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/User'
|
|
||||||
description: Created user object
|
|
||||||
required: true
|
|
||||||
responses:
|
|
||||||
default:
|
|
||||||
description: successful operation
|
|
||||||
security:
|
|
||||||
- auth_cookie: []
|
|
||||||
summary: Create user
|
|
||||||
tags:
|
|
||||||
- user
|
|
||||||
x-swagger-router-controller: User
|
|
||||||
/user/createWithArray:
|
|
||||||
post:
|
|
||||||
operationId: createUsersWithArrayInput
|
|
||||||
requestBody:
|
|
||||||
$ref: '#/components/requestBodies/UserArray'
|
|
||||||
responses:
|
|
||||||
default:
|
|
||||||
description: successful operation
|
|
||||||
security:
|
|
||||||
- auth_cookie: []
|
|
||||||
summary: Creates list of users with given input array
|
|
||||||
tags:
|
|
||||||
- user
|
|
||||||
x-swagger-router-controller: User
|
|
||||||
/user/createWithList:
|
|
||||||
post:
|
|
||||||
operationId: createUsersWithListInput
|
|
||||||
requestBody:
|
|
||||||
$ref: '#/components/requestBodies/UserArray'
|
|
||||||
responses:
|
|
||||||
default:
|
|
||||||
description: successful operation
|
|
||||||
security:
|
|
||||||
- auth_cookie: []
|
|
||||||
summary: Creates list of users with given input array
|
|
||||||
tags:
|
|
||||||
- user
|
|
||||||
x-swagger-router-controller: User
|
|
||||||
/user/login:
|
|
||||||
get:
|
|
||||||
operationId: loginUser
|
|
||||||
parameters:
|
|
||||||
- description: The user name for login
|
|
||||||
explode: true
|
|
||||||
in: query
|
|
||||||
name: username
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
pattern: ^[a-zA-Z0-9]+[a-zA-Z0-9\.\-_]*[a-zA-Z0-9]+$
|
|
||||||
type: string
|
|
||||||
style: form
|
|
||||||
- description: The password for login in clear text
|
|
||||||
explode: true
|
|
||||||
in: query
|
|
||||||
name: password
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
style: form
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
content:
|
|
||||||
application/xml:
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
description: successful operation
|
|
||||||
headers:
|
|
||||||
Set-Cookie:
|
|
||||||
description: Cookie authentication key for use with the `auth_cookie`
|
|
||||||
apiKey authentication.
|
|
||||||
explode: false
|
|
||||||
schema:
|
|
||||||
example: AUTH_KEY=abcde12345; Path=/; HttpOnly
|
|
||||||
type: string
|
|
||||||
style: simple
|
|
||||||
X-Rate-Limit:
|
|
||||||
description: calls per hour allowed by the user
|
|
||||||
explode: false
|
|
||||||
schema:
|
|
||||||
format: int32
|
|
||||||
type: integer
|
|
||||||
style: simple
|
|
||||||
X-Expires-After:
|
|
||||||
description: date in UTC when toekn expires
|
|
||||||
explode: false
|
|
||||||
schema:
|
|
||||||
format: date-time
|
|
||||||
type: string
|
|
||||||
style: simple
|
|
||||||
400:
|
|
||||||
description: Invalid username/password supplied
|
|
||||||
summary: Logs user into the system
|
|
||||||
tags:
|
|
||||||
- user
|
|
||||||
x-swagger-router-controller: User
|
|
||||||
/user/logout:
|
|
||||||
get:
|
|
||||||
operationId: logoutUser
|
|
||||||
responses:
|
|
||||||
default:
|
|
||||||
description: successful operation
|
|
||||||
security:
|
|
||||||
- auth_cookie: []
|
|
||||||
summary: Logs out current logged in user session
|
|
||||||
tags:
|
|
||||||
- user
|
|
||||||
x-swagger-router-controller: User
|
|
||||||
/user/{username}:
|
|
||||||
delete:
|
|
||||||
description: This can only be done by the logged in user.
|
|
||||||
operationId: deleteUser
|
|
||||||
parameters:
|
|
||||||
- description: The name that needs to be deleted
|
|
||||||
explode: false
|
|
||||||
in: path
|
|
||||||
name: username
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
style: simple
|
|
||||||
responses:
|
|
||||||
400:
|
|
||||||
description: Invalid username supplied
|
|
||||||
404:
|
|
||||||
description: User not found
|
|
||||||
security:
|
|
||||||
- auth_cookie: []
|
|
||||||
summary: Delete user
|
|
||||||
tags:
|
|
||||||
- user
|
|
||||||
x-swagger-router-controller: User
|
|
||||||
get:
|
|
||||||
operationId: getUserByName
|
|
||||||
parameters:
|
|
||||||
- description: The name that needs to be fetched. Use user1 for testing.
|
|
||||||
explode: false
|
|
||||||
in: path
|
|
||||||
name: username
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
style: simple
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
content:
|
|
||||||
application/xml:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/User'
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/User'
|
|
||||||
description: successful operation
|
|
||||||
400:
|
|
||||||
description: Invalid username supplied
|
|
||||||
404:
|
|
||||||
description: User not found
|
|
||||||
summary: Get user by user name
|
|
||||||
tags:
|
|
||||||
- user
|
|
||||||
x-swagger-router-controller: User
|
|
||||||
put:
|
|
||||||
description: This can only be done by the logged in user.
|
|
||||||
operationId: updateUser
|
|
||||||
parameters:
|
|
||||||
- description: name that need to be deleted
|
|
||||||
explode: false
|
|
||||||
in: path
|
|
||||||
name: username
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
style: simple
|
|
||||||
requestBody:
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/User'
|
|
||||||
description: Updated user object
|
|
||||||
required: true
|
|
||||||
responses:
|
|
||||||
400:
|
|
||||||
description: Invalid user supplied
|
|
||||||
404:
|
|
||||||
description: User not found
|
|
||||||
security:
|
|
||||||
- auth_cookie: []
|
|
||||||
summary: Updated user
|
|
||||||
tags:
|
|
||||||
- user
|
|
||||||
x-swagger-router-controller: User
|
|
||||||
components:
|
|
||||||
requestBodies:
|
|
||||||
UserArray:
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
items:
|
|
||||||
$ref: '#/components/schemas/User'
|
|
||||||
type: array
|
|
||||||
description: List of user object
|
|
||||||
required: true
|
|
||||||
Pet:
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/Pet'
|
|
||||||
application/xml:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/Pet'
|
|
||||||
description: Pet object that needs to be added to the store
|
|
||||||
required: true
|
|
||||||
inline_object:
|
|
||||||
content:
|
|
||||||
application/x-www-form-urlencoded:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/inline_object'
|
|
||||||
inline_object_1:
|
|
||||||
content:
|
|
||||||
multipart/form-data:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/inline_object_1'
|
|
||||||
schemas:
|
|
||||||
Order:
|
|
||||||
description: An order for a pets from the pet store
|
|
||||||
example:
|
|
||||||
petId: 6
|
|
||||||
quantity: 1
|
|
||||||
id: 0
|
|
||||||
shipDate: 2000-01-23T04:56:07.000+00:00
|
|
||||||
complete: false
|
|
||||||
status: placed
|
|
||||||
properties:
|
|
||||||
id:
|
|
||||||
format: int64
|
|
||||||
type: integer
|
|
||||||
petId:
|
|
||||||
format: int64
|
|
||||||
type: integer
|
|
||||||
quantity:
|
|
||||||
format: int32
|
|
||||||
type: integer
|
|
||||||
shipDate:
|
|
||||||
format: date-time
|
|
||||||
type: string
|
|
||||||
status:
|
|
||||||
description: Order Status
|
|
||||||
enum:
|
|
||||||
- placed
|
|
||||||
- approved
|
|
||||||
- delivered
|
|
||||||
type: string
|
|
||||||
complete:
|
|
||||||
default: false
|
|
||||||
type: boolean
|
|
||||||
title: Pet Order
|
|
||||||
type: object
|
|
||||||
xml:
|
|
||||||
name: Order
|
|
||||||
Category:
|
|
||||||
description: A category for a pet
|
|
||||||
example:
|
|
||||||
name: name
|
|
||||||
id: 6
|
|
||||||
properties:
|
|
||||||
id:
|
|
||||||
format: int64
|
|
||||||
type: integer
|
|
||||||
name:
|
|
||||||
pattern: ^[a-zA-Z0-9]+[a-zA-Z0-9\.\-_]*[a-zA-Z0-9]+$
|
|
||||||
type: string
|
|
||||||
title: Pet category
|
|
||||||
type: object
|
|
||||||
xml:
|
|
||||||
name: Category
|
|
||||||
User:
|
|
||||||
description: A User who is purchasing from the pet store
|
|
||||||
example:
|
|
||||||
firstName: firstName
|
|
||||||
lastName: lastName
|
|
||||||
password: password
|
|
||||||
userStatus: 6
|
|
||||||
phone: phone
|
|
||||||
id: 0
|
|
||||||
email: email
|
|
||||||
username: username
|
|
||||||
properties:
|
|
||||||
id:
|
|
||||||
format: int64
|
|
||||||
type: integer
|
|
||||||
username:
|
|
||||||
type: string
|
|
||||||
firstName:
|
|
||||||
type: string
|
|
||||||
lastName:
|
|
||||||
type: string
|
|
||||||
email:
|
|
||||||
type: string
|
|
||||||
password:
|
|
||||||
type: string
|
|
||||||
phone:
|
|
||||||
type: string
|
|
||||||
userStatus:
|
|
||||||
description: User Status
|
|
||||||
format: int32
|
|
||||||
type: integer
|
|
||||||
title: a User
|
|
||||||
type: object
|
|
||||||
xml:
|
|
||||||
name: User
|
|
||||||
Tag:
|
|
||||||
description: A tag for a pet
|
|
||||||
example:
|
|
||||||
name: name
|
|
||||||
id: 1
|
|
||||||
properties:
|
|
||||||
id:
|
|
||||||
format: int64
|
|
||||||
type: integer
|
|
||||||
name:
|
|
||||||
type: string
|
|
||||||
title: Pet Tag
|
|
||||||
type: object
|
|
||||||
xml:
|
|
||||||
name: Tag
|
|
||||||
Pet:
|
|
||||||
description: A pet for sale in the pet store
|
|
||||||
example:
|
|
||||||
photoUrls:
|
|
||||||
- photoUrls
|
|
||||||
- photoUrls
|
|
||||||
name: doggie
|
|
||||||
id: 0
|
|
||||||
category:
|
|
||||||
name: name
|
|
||||||
id: 6
|
|
||||||
tags:
|
|
||||||
- name: name
|
|
||||||
id: 1
|
|
||||||
- name: name
|
|
||||||
id: 1
|
|
||||||
status: available
|
|
||||||
properties:
|
|
||||||
id:
|
|
||||||
format: int64
|
|
||||||
type: integer
|
|
||||||
category:
|
|
||||||
$ref: '#/components/schemas/Category'
|
|
||||||
name:
|
|
||||||
example: doggie
|
|
||||||
type: string
|
|
||||||
photoUrls:
|
|
||||||
items:
|
|
||||||
type: string
|
|
||||||
type: array
|
|
||||||
xml:
|
|
||||||
name: photoUrl
|
|
||||||
wrapped: true
|
|
||||||
tags:
|
|
||||||
items:
|
|
||||||
$ref: '#/components/schemas/Tag'
|
|
||||||
type: array
|
|
||||||
xml:
|
|
||||||
name: tag
|
|
||||||
wrapped: true
|
|
||||||
status:
|
|
||||||
description: pet status in the store
|
|
||||||
enum:
|
|
||||||
- available
|
|
||||||
- pending
|
|
||||||
- sold
|
|
||||||
type: string
|
|
||||||
required:
|
|
||||||
- name
|
|
||||||
- photoUrls
|
|
||||||
title: a Pet
|
|
||||||
type: object
|
|
||||||
xml:
|
|
||||||
name: Pet
|
|
||||||
ApiResponse:
|
|
||||||
description: Describes the result of uploading an image resource
|
|
||||||
example:
|
|
||||||
code: 0
|
|
||||||
type: type
|
|
||||||
message: message
|
|
||||||
properties:
|
|
||||||
code:
|
|
||||||
format: int32
|
|
||||||
type: integer
|
|
||||||
type:
|
|
||||||
type: string
|
|
||||||
message:
|
|
||||||
type: string
|
|
||||||
title: An uploaded response
|
|
||||||
type: object
|
|
||||||
inline_object:
|
|
||||||
properties:
|
|
||||||
name:
|
|
||||||
description: Updated name of the pet
|
|
||||||
type: string
|
|
||||||
status:
|
|
||||||
description: Updated status of the pet
|
|
||||||
type: string
|
|
||||||
type: object
|
|
||||||
inline_object_1:
|
|
||||||
properties:
|
|
||||||
additionalMetadata:
|
|
||||||
description: Additional data to pass to server
|
|
||||||
type: string
|
|
||||||
file:
|
|
||||||
description: file to upload
|
|
||||||
format: binary
|
|
||||||
type: string
|
|
||||||
type: object
|
|
||||||
securitySchemes:
|
|
||||||
petstore_auth:
|
|
||||||
flows:
|
|
||||||
implicit:
|
|
||||||
authorizationUrl: http://petstore.swagger.io/api/oauth/dialog
|
|
||||||
scopes:
|
|
||||||
write:pets: modify pets in your account
|
|
||||||
read:pets: read your pets
|
|
||||||
type: oauth2
|
|
||||||
api_key:
|
|
||||||
in: header
|
|
||||||
name: api_key
|
|
||||||
type: apiKey
|
|
||||||
auth_cookie:
|
|
||||||
in: cookie
|
|
||||||
name: AUTH_KEY
|
|
||||||
type: apiKey
|
|
@ -1,775 +0,0 @@
|
|||||||
---
|
|
||||||
swagger: "2.0"
|
|
||||||
info:
|
|
||||||
description: "This is a sample server Petstore server. You can find out more about\
|
|
||||||
\ Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/).\
|
|
||||||
\ For this sample, you can use the api key `special-key` to test the authorization\
|
|
||||||
\ filters."
|
|
||||||
version: "1.0.0"
|
|
||||||
title: "Swagger Petstore"
|
|
||||||
termsOfService: "http://swagger.io/terms/"
|
|
||||||
contact:
|
|
||||||
email: "apiteam@swagger.io"
|
|
||||||
license:
|
|
||||||
name: "Apache-2.0"
|
|
||||||
url: "http://www.apache.org/licenses/LICENSE-2.0.html"
|
|
||||||
host: "petstore.swagger.io"
|
|
||||||
basePath: "/v2"
|
|
||||||
tags:
|
|
||||||
- name: "pet"
|
|
||||||
description: "Everything about your Pets"
|
|
||||||
externalDocs:
|
|
||||||
description: "Find out more"
|
|
||||||
url: "http://swagger.io"
|
|
||||||
- name: "store"
|
|
||||||
description: "Access to Petstore orders"
|
|
||||||
- name: "user"
|
|
||||||
description: "Operations about user"
|
|
||||||
externalDocs:
|
|
||||||
description: "Find out more about our store"
|
|
||||||
url: "http://swagger.io"
|
|
||||||
schemes:
|
|
||||||
- "http"
|
|
||||||
paths:
|
|
||||||
/pet:
|
|
||||||
post:
|
|
||||||
tags:
|
|
||||||
- "pet"
|
|
||||||
summary: "Add a new pet to the store"
|
|
||||||
description: ""
|
|
||||||
operationId: "addPet"
|
|
||||||
consumes:
|
|
||||||
- "application/json"
|
|
||||||
- "application/xml"
|
|
||||||
produces:
|
|
||||||
- "application/xml"
|
|
||||||
- "application/json"
|
|
||||||
parameters:
|
|
||||||
- in: "body"
|
|
||||||
name: "body"
|
|
||||||
description: "Pet object that needs to be added to the store"
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
$ref: "#/definitions/Pet"
|
|
||||||
responses:
|
|
||||||
405:
|
|
||||||
description: "Invalid input"
|
|
||||||
security:
|
|
||||||
- petstore_auth:
|
|
||||||
- "write:pets"
|
|
||||||
- "read:pets"
|
|
||||||
x-swagger-router-controller: "Pet"
|
|
||||||
put:
|
|
||||||
tags:
|
|
||||||
- "pet"
|
|
||||||
summary: "Update an existing pet"
|
|
||||||
description: ""
|
|
||||||
operationId: "updatePet"
|
|
||||||
consumes:
|
|
||||||
- "application/json"
|
|
||||||
- "application/xml"
|
|
||||||
produces:
|
|
||||||
- "application/xml"
|
|
||||||
- "application/json"
|
|
||||||
parameters:
|
|
||||||
- in: "body"
|
|
||||||
name: "body"
|
|
||||||
description: "Pet object that needs to be added to the store"
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
$ref: "#/definitions/Pet"
|
|
||||||
responses:
|
|
||||||
400:
|
|
||||||
description: "Invalid ID supplied"
|
|
||||||
404:
|
|
||||||
description: "Pet not found"
|
|
||||||
405:
|
|
||||||
description: "Validation exception"
|
|
||||||
security:
|
|
||||||
- petstore_auth:
|
|
||||||
- "write:pets"
|
|
||||||
- "read:pets"
|
|
||||||
x-swagger-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"
|
|
||||||
produces:
|
|
||||||
- "application/xml"
|
|
||||||
- "application/json"
|
|
||||||
parameters:
|
|
||||||
- name: "status"
|
|
||||||
in: "query"
|
|
||||||
description: "Status values that need to be considered for filter"
|
|
||||||
required: true
|
|
||||||
type: "array"
|
|
||||||
items:
|
|
||||||
type: "string"
|
|
||||||
default: "available"
|
|
||||||
enum:
|
|
||||||
- "available"
|
|
||||||
- "pending"
|
|
||||||
- "sold"
|
|
||||||
collectionFormat: "csv"
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
description: "successful operation"
|
|
||||||
schema:
|
|
||||||
type: "array"
|
|
||||||
items:
|
|
||||||
$ref: "#/definitions/Pet"
|
|
||||||
400:
|
|
||||||
description: "Invalid status value"
|
|
||||||
security:
|
|
||||||
- petstore_auth:
|
|
||||||
- "write:pets"
|
|
||||||
- "read:pets"
|
|
||||||
x-swagger-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"
|
|
||||||
produces:
|
|
||||||
- "application/xml"
|
|
||||||
- "application/json"
|
|
||||||
parameters:
|
|
||||||
- name: "tags"
|
|
||||||
in: "query"
|
|
||||||
description: "Tags to filter by"
|
|
||||||
required: true
|
|
||||||
type: "array"
|
|
||||||
items:
|
|
||||||
type: "string"
|
|
||||||
collectionFormat: "csv"
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
description: "successful operation"
|
|
||||||
schema:
|
|
||||||
type: "array"
|
|
||||||
items:
|
|
||||||
$ref: "#/definitions/Pet"
|
|
||||||
400:
|
|
||||||
description: "Invalid tag value"
|
|
||||||
security:
|
|
||||||
- petstore_auth:
|
|
||||||
- "write:pets"
|
|
||||||
- "read:pets"
|
|
||||||
deprecated: true
|
|
||||||
x-swagger-router-controller: "Pet"
|
|
||||||
/pet/{petId}:
|
|
||||||
get:
|
|
||||||
tags:
|
|
||||||
- "pet"
|
|
||||||
summary: "Find pet by ID"
|
|
||||||
description: "Returns a single pet"
|
|
||||||
operationId: "getPetById"
|
|
||||||
produces:
|
|
||||||
- "application/xml"
|
|
||||||
- "application/json"
|
|
||||||
parameters:
|
|
||||||
- name: "petId"
|
|
||||||
in: "path"
|
|
||||||
description: "ID of pet to return"
|
|
||||||
required: true
|
|
||||||
type: "integer"
|
|
||||||
format: "int64"
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
description: "successful operation"
|
|
||||||
schema:
|
|
||||||
$ref: "#/definitions/Pet"
|
|
||||||
400:
|
|
||||||
description: "Invalid ID supplied"
|
|
||||||
404:
|
|
||||||
description: "Pet not found"
|
|
||||||
security:
|
|
||||||
- api_key: []
|
|
||||||
x-swagger-router-controller: "Pet"
|
|
||||||
post:
|
|
||||||
tags:
|
|
||||||
- "pet"
|
|
||||||
summary: "Updates a pet in the store with form data"
|
|
||||||
description: ""
|
|
||||||
operationId: "updatePetWithForm"
|
|
||||||
consumes:
|
|
||||||
- "application/x-www-form-urlencoded"
|
|
||||||
produces:
|
|
||||||
- "application/xml"
|
|
||||||
- "application/json"
|
|
||||||
parameters:
|
|
||||||
- name: "petId"
|
|
||||||
in: "path"
|
|
||||||
description: "ID of pet that needs to be updated"
|
|
||||||
required: true
|
|
||||||
type: "integer"
|
|
||||||
format: "int64"
|
|
||||||
- name: "name"
|
|
||||||
in: "formData"
|
|
||||||
description: "Updated name of the pet"
|
|
||||||
required: false
|
|
||||||
type: "string"
|
|
||||||
- name: "status"
|
|
||||||
in: "formData"
|
|
||||||
description: "Updated status of the pet"
|
|
||||||
required: false
|
|
||||||
type: "string"
|
|
||||||
responses:
|
|
||||||
405:
|
|
||||||
description: "Invalid input"
|
|
||||||
security:
|
|
||||||
- petstore_auth:
|
|
||||||
- "write:pets"
|
|
||||||
- "read:pets"
|
|
||||||
x-swagger-router-controller: "Pet"
|
|
||||||
delete:
|
|
||||||
tags:
|
|
||||||
- "pet"
|
|
||||||
summary: "Deletes a pet"
|
|
||||||
description: ""
|
|
||||||
operationId: "deletePet"
|
|
||||||
produces:
|
|
||||||
- "application/xml"
|
|
||||||
- "application/json"
|
|
||||||
parameters:
|
|
||||||
- name: "api_key"
|
|
||||||
in: "header"
|
|
||||||
required: false
|
|
||||||
type: "string"
|
|
||||||
- name: "petId"
|
|
||||||
in: "path"
|
|
||||||
description: "Pet id to delete"
|
|
||||||
required: true
|
|
||||||
type: "integer"
|
|
||||||
format: "int64"
|
|
||||||
responses:
|
|
||||||
400:
|
|
||||||
description: "Invalid pet value"
|
|
||||||
security:
|
|
||||||
- petstore_auth:
|
|
||||||
- "write:pets"
|
|
||||||
- "read:pets"
|
|
||||||
x-swagger-router-controller: "Pet"
|
|
||||||
/pet/{petId}/uploadImage:
|
|
||||||
post:
|
|
||||||
tags:
|
|
||||||
- "pet"
|
|
||||||
summary: "uploads an image"
|
|
||||||
description: ""
|
|
||||||
operationId: "uploadFile"
|
|
||||||
consumes:
|
|
||||||
- "multipart/form-data"
|
|
||||||
produces:
|
|
||||||
- "application/json"
|
|
||||||
parameters:
|
|
||||||
- name: "petId"
|
|
||||||
in: "path"
|
|
||||||
description: "ID of pet to update"
|
|
||||||
required: true
|
|
||||||
type: "integer"
|
|
||||||
format: "int64"
|
|
||||||
- name: "additionalMetadata"
|
|
||||||
in: "formData"
|
|
||||||
description: "Additional data to pass to server"
|
|
||||||
required: false
|
|
||||||
type: "string"
|
|
||||||
- name: "file"
|
|
||||||
in: "formData"
|
|
||||||
description: "file to upload"
|
|
||||||
required: false
|
|
||||||
type: "file"
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
description: "successful operation"
|
|
||||||
schema:
|
|
||||||
$ref: "#/definitions/ApiResponse"
|
|
||||||
security:
|
|
||||||
- petstore_auth:
|
|
||||||
- "write:pets"
|
|
||||||
- "read:pets"
|
|
||||||
x-swagger-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"
|
|
||||||
produces:
|
|
||||||
- "application/json"
|
|
||||||
parameters: []
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
description: "successful operation"
|
|
||||||
schema:
|
|
||||||
type: "object"
|
|
||||||
additionalProperties:
|
|
||||||
type: "integer"
|
|
||||||
format: "int32"
|
|
||||||
security:
|
|
||||||
- api_key: []
|
|
||||||
x-swagger-router-controller: "Store"
|
|
||||||
/store/order:
|
|
||||||
post:
|
|
||||||
tags:
|
|
||||||
- "store"
|
|
||||||
summary: "Place an order for a pet"
|
|
||||||
description: ""
|
|
||||||
operationId: "placeOrder"
|
|
||||||
produces:
|
|
||||||
- "application/xml"
|
|
||||||
- "application/json"
|
|
||||||
parameters:
|
|
||||||
- in: "body"
|
|
||||||
name: "body"
|
|
||||||
description: "order placed for purchasing the pet"
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
$ref: "#/definitions/Order"
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
description: "successful operation"
|
|
||||||
schema:
|
|
||||||
$ref: "#/definitions/Order"
|
|
||||||
400:
|
|
||||||
description: "Invalid Order"
|
|
||||||
x-swagger-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"
|
|
||||||
produces:
|
|
||||||
- "application/xml"
|
|
||||||
- "application/json"
|
|
||||||
parameters:
|
|
||||||
- name: "orderId"
|
|
||||||
in: "path"
|
|
||||||
description: "ID of pet that needs to be fetched"
|
|
||||||
required: true
|
|
||||||
type: "integer"
|
|
||||||
maximum: 5
|
|
||||||
minimum: 1
|
|
||||||
format: "int64"
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
description: "successful operation"
|
|
||||||
schema:
|
|
||||||
$ref: "#/definitions/Order"
|
|
||||||
400:
|
|
||||||
description: "Invalid ID supplied"
|
|
||||||
404:
|
|
||||||
description: "Order not found"
|
|
||||||
x-swagger-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"
|
|
||||||
produces:
|
|
||||||
- "application/xml"
|
|
||||||
- "application/json"
|
|
||||||
parameters:
|
|
||||||
- name: "orderId"
|
|
||||||
in: "path"
|
|
||||||
description: "ID of the order that needs to be deleted"
|
|
||||||
required: true
|
|
||||||
type: "string"
|
|
||||||
responses:
|
|
||||||
400:
|
|
||||||
description: "Invalid ID supplied"
|
|
||||||
404:
|
|
||||||
description: "Order not found"
|
|
||||||
x-swagger-router-controller: "Store"
|
|
||||||
/user:
|
|
||||||
post:
|
|
||||||
tags:
|
|
||||||
- "user"
|
|
||||||
summary: "Create user"
|
|
||||||
description: "This can only be done by the logged in user."
|
|
||||||
operationId: "createUser"
|
|
||||||
produces:
|
|
||||||
- "application/xml"
|
|
||||||
- "application/json"
|
|
||||||
parameters:
|
|
||||||
- in: "body"
|
|
||||||
name: "body"
|
|
||||||
description: "Created user object"
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
$ref: "#/definitions/User"
|
|
||||||
responses:
|
|
||||||
default:
|
|
||||||
description: "successful operation"
|
|
||||||
x-swagger-router-controller: "User"
|
|
||||||
/user/createWithArray:
|
|
||||||
post:
|
|
||||||
tags:
|
|
||||||
- "user"
|
|
||||||
summary: "Creates list of users with given input array"
|
|
||||||
description: ""
|
|
||||||
operationId: "createUsersWithArrayInput"
|
|
||||||
produces:
|
|
||||||
- "application/xml"
|
|
||||||
- "application/json"
|
|
||||||
parameters:
|
|
||||||
- in: "body"
|
|
||||||
name: "body"
|
|
||||||
description: "List of user object"
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
type: "array"
|
|
||||||
items:
|
|
||||||
$ref: "#/definitions/User"
|
|
||||||
responses:
|
|
||||||
default:
|
|
||||||
description: "successful operation"
|
|
||||||
x-swagger-router-controller: "User"
|
|
||||||
/user/createWithList:
|
|
||||||
post:
|
|
||||||
tags:
|
|
||||||
- "user"
|
|
||||||
summary: "Creates list of users with given input array"
|
|
||||||
description: ""
|
|
||||||
operationId: "createUsersWithListInput"
|
|
||||||
produces:
|
|
||||||
- "application/xml"
|
|
||||||
- "application/json"
|
|
||||||
parameters:
|
|
||||||
- in: "body"
|
|
||||||
name: "body"
|
|
||||||
description: "List of user object"
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
type: "array"
|
|
||||||
items:
|
|
||||||
$ref: "#/definitions/User"
|
|
||||||
responses:
|
|
||||||
default:
|
|
||||||
description: "successful operation"
|
|
||||||
x-swagger-router-controller: "User"
|
|
||||||
/user/login:
|
|
||||||
get:
|
|
||||||
tags:
|
|
||||||
- "user"
|
|
||||||
summary: "Logs user into the system"
|
|
||||||
description: ""
|
|
||||||
operationId: "loginUser"
|
|
||||||
produces:
|
|
||||||
- "application/xml"
|
|
||||||
- "application/json"
|
|
||||||
parameters:
|
|
||||||
- name: "username"
|
|
||||||
in: "query"
|
|
||||||
description: "The user name for login"
|
|
||||||
required: true
|
|
||||||
type: "string"
|
|
||||||
- name: "password"
|
|
||||||
in: "query"
|
|
||||||
description: "The password for login in clear text"
|
|
||||||
required: true
|
|
||||||
type: "string"
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
description: "successful operation"
|
|
||||||
schema:
|
|
||||||
type: "string"
|
|
||||||
headers:
|
|
||||||
X-Rate-Limit:
|
|
||||||
type: "integer"
|
|
||||||
format: "int32"
|
|
||||||
description: "calls per hour allowed by the user"
|
|
||||||
X-Expires-After:
|
|
||||||
type: "string"
|
|
||||||
format: "date-time"
|
|
||||||
description: "date in UTC when toekn expires"
|
|
||||||
400:
|
|
||||||
description: "Invalid username/password supplied"
|
|
||||||
x-swagger-router-controller: "User"
|
|
||||||
/user/logout:
|
|
||||||
get:
|
|
||||||
tags:
|
|
||||||
- "user"
|
|
||||||
summary: "Logs out current logged in user session"
|
|
||||||
description: ""
|
|
||||||
operationId: "logoutUser"
|
|
||||||
produces:
|
|
||||||
- "application/xml"
|
|
||||||
- "application/json"
|
|
||||||
parameters: []
|
|
||||||
responses:
|
|
||||||
default:
|
|
||||||
description: "successful operation"
|
|
||||||
x-swagger-router-controller: "User"
|
|
||||||
/user/{username}:
|
|
||||||
get:
|
|
||||||
tags:
|
|
||||||
- "user"
|
|
||||||
summary: "Get user by user name"
|
|
||||||
description: ""
|
|
||||||
operationId: "getUserByName"
|
|
||||||
produces:
|
|
||||||
- "application/xml"
|
|
||||||
- "application/json"
|
|
||||||
parameters:
|
|
||||||
- name: "username"
|
|
||||||
in: "path"
|
|
||||||
description: "The name that needs to be fetched. Use user1 for testing."
|
|
||||||
required: true
|
|
||||||
type: "string"
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
description: "successful operation"
|
|
||||||
schema:
|
|
||||||
$ref: "#/definitions/User"
|
|
||||||
400:
|
|
||||||
description: "Invalid username supplied"
|
|
||||||
404:
|
|
||||||
description: "User not found"
|
|
||||||
x-swagger-router-controller: "User"
|
|
||||||
put:
|
|
||||||
tags:
|
|
||||||
- "user"
|
|
||||||
summary: "Updated user"
|
|
||||||
description: "This can only be done by the logged in user."
|
|
||||||
operationId: "updateUser"
|
|
||||||
produces:
|
|
||||||
- "application/xml"
|
|
||||||
- "application/json"
|
|
||||||
parameters:
|
|
||||||
- name: "username"
|
|
||||||
in: "path"
|
|
||||||
description: "name that need to be deleted"
|
|
||||||
required: true
|
|
||||||
type: "string"
|
|
||||||
- in: "body"
|
|
||||||
name: "body"
|
|
||||||
description: "Updated user object"
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
$ref: "#/definitions/User"
|
|
||||||
responses:
|
|
||||||
400:
|
|
||||||
description: "Invalid user supplied"
|
|
||||||
404:
|
|
||||||
description: "User not found"
|
|
||||||
x-swagger-router-controller: "User"
|
|
||||||
delete:
|
|
||||||
tags:
|
|
||||||
- "user"
|
|
||||||
summary: "Delete user"
|
|
||||||
description: "This can only be done by the logged in user."
|
|
||||||
operationId: "deleteUser"
|
|
||||||
produces:
|
|
||||||
- "application/xml"
|
|
||||||
- "application/json"
|
|
||||||
parameters:
|
|
||||||
- name: "username"
|
|
||||||
in: "path"
|
|
||||||
description: "The name that needs to be deleted"
|
|
||||||
required: true
|
|
||||||
type: "string"
|
|
||||||
responses:
|
|
||||||
400:
|
|
||||||
description: "Invalid username supplied"
|
|
||||||
404:
|
|
||||||
description: "User not found"
|
|
||||||
x-swagger-router-controller: "User"
|
|
||||||
securityDefinitions:
|
|
||||||
petstore_auth:
|
|
||||||
type: "oauth2"
|
|
||||||
authorizationUrl: "http://petstore.swagger.io/api/oauth/dialog"
|
|
||||||
flow: "implicit"
|
|
||||||
scopes:
|
|
||||||
write:pets: "modify pets in your account"
|
|
||||||
read:pets: "read your pets"
|
|
||||||
api_key:
|
|
||||||
type: "apiKey"
|
|
||||||
name: "api_key"
|
|
||||||
in: "header"
|
|
||||||
definitions:
|
|
||||||
Order:
|
|
||||||
type: "object"
|
|
||||||
properties:
|
|
||||||
id:
|
|
||||||
type: "integer"
|
|
||||||
format: "int64"
|
|
||||||
petId:
|
|
||||||
type: "integer"
|
|
||||||
format: "int64"
|
|
||||||
quantity:
|
|
||||||
type: "integer"
|
|
||||||
format: "int32"
|
|
||||||
shipDate:
|
|
||||||
type: "string"
|
|
||||||
format: "date-time"
|
|
||||||
status:
|
|
||||||
type: "string"
|
|
||||||
description: "Order Status"
|
|
||||||
enum:
|
|
||||||
- "placed"
|
|
||||||
- "approved"
|
|
||||||
- "delivered"
|
|
||||||
complete:
|
|
||||||
type: "boolean"
|
|
||||||
default: false
|
|
||||||
title: "Pet Order"
|
|
||||||
description: "An order for a pets from the pet store"
|
|
||||||
example:
|
|
||||||
petId: 6
|
|
||||||
quantity: 1
|
|
||||||
id: 0
|
|
||||||
shipDate: "2000-01-23T04:56:07.000+00:00"
|
|
||||||
complete: false
|
|
||||||
status: "placed"
|
|
||||||
xml:
|
|
||||||
name: "Order"
|
|
||||||
Category:
|
|
||||||
type: "object"
|
|
||||||
properties:
|
|
||||||
id:
|
|
||||||
type: "integer"
|
|
||||||
format: "int64"
|
|
||||||
name:
|
|
||||||
type: "string"
|
|
||||||
title: "Pet category"
|
|
||||||
description: "A category for a pet"
|
|
||||||
example:
|
|
||||||
name: "name"
|
|
||||||
id: 6
|
|
||||||
xml:
|
|
||||||
name: "Category"
|
|
||||||
User:
|
|
||||||
type: "object"
|
|
||||||
properties:
|
|
||||||
id:
|
|
||||||
type: "integer"
|
|
||||||
format: "int64"
|
|
||||||
username:
|
|
||||||
type: "string"
|
|
||||||
firstName:
|
|
||||||
type: "string"
|
|
||||||
lastName:
|
|
||||||
type: "string"
|
|
||||||
email:
|
|
||||||
type: "string"
|
|
||||||
password:
|
|
||||||
type: "string"
|
|
||||||
phone:
|
|
||||||
type: "string"
|
|
||||||
userStatus:
|
|
||||||
type: "integer"
|
|
||||||
format: "int32"
|
|
||||||
description: "User Status"
|
|
||||||
title: "a User"
|
|
||||||
description: "A User who is purchasing from the pet store"
|
|
||||||
example:
|
|
||||||
firstName: "firstName"
|
|
||||||
lastName: "lastName"
|
|
||||||
password: "password"
|
|
||||||
userStatus: 6
|
|
||||||
phone: "phone"
|
|
||||||
id: 0
|
|
||||||
email: "email"
|
|
||||||
username: "username"
|
|
||||||
xml:
|
|
||||||
name: "User"
|
|
||||||
Tag:
|
|
||||||
type: "object"
|
|
||||||
properties:
|
|
||||||
id:
|
|
||||||
type: "integer"
|
|
||||||
format: "int64"
|
|
||||||
name:
|
|
||||||
type: "string"
|
|
||||||
title: "Pet Tag"
|
|
||||||
description: "A tag for a pet"
|
|
||||||
example:
|
|
||||||
name: "name"
|
|
||||||
id: 1
|
|
||||||
xml:
|
|
||||||
name: "Tag"
|
|
||||||
Pet:
|
|
||||||
type: "object"
|
|
||||||
required:
|
|
||||||
- "name"
|
|
||||||
- "photoUrls"
|
|
||||||
properties:
|
|
||||||
id:
|
|
||||||
type: "integer"
|
|
||||||
format: "int64"
|
|
||||||
category:
|
|
||||||
$ref: "#/definitions/Category"
|
|
||||||
name:
|
|
||||||
type: "string"
|
|
||||||
example: "doggie"
|
|
||||||
photoUrls:
|
|
||||||
type: "array"
|
|
||||||
xml:
|
|
||||||
name: "photoUrl"
|
|
||||||
wrapped: true
|
|
||||||
items:
|
|
||||||
type: "string"
|
|
||||||
tags:
|
|
||||||
type: "array"
|
|
||||||
xml:
|
|
||||||
name: "tag"
|
|
||||||
wrapped: true
|
|
||||||
items:
|
|
||||||
$ref: "#/definitions/Tag"
|
|
||||||
status:
|
|
||||||
type: "string"
|
|
||||||
description: "pet status in the store"
|
|
||||||
enum:
|
|
||||||
- "available"
|
|
||||||
- "pending"
|
|
||||||
- "sold"
|
|
||||||
title: "a Pet"
|
|
||||||
description: "A pet for sale in the pet store"
|
|
||||||
example:
|
|
||||||
photoUrls:
|
|
||||||
- "photoUrls"
|
|
||||||
- "photoUrls"
|
|
||||||
name: "doggie"
|
|
||||||
id: 0
|
|
||||||
category:
|
|
||||||
name: "name"
|
|
||||||
id: 6
|
|
||||||
tags:
|
|
||||||
- name: "name"
|
|
||||||
id: 1
|
|
||||||
- name: "name"
|
|
||||||
id: 1
|
|
||||||
status: "available"
|
|
||||||
xml:
|
|
||||||
name: "Pet"
|
|
||||||
ApiResponse:
|
|
||||||
type: "object"
|
|
||||||
properties:
|
|
||||||
code:
|
|
||||||
type: "integer"
|
|
||||||
format: "int32"
|
|
||||||
type:
|
|
||||||
type: "string"
|
|
||||||
message:
|
|
||||||
type: "string"
|
|
||||||
title: "An uploaded response"
|
|
||||||
description: "Describes the result of uploading an image resource"
|
|
||||||
example:
|
|
||||||
code: 0
|
|
||||||
type: "type"
|
|
||||||
message: "message"
|
|
||||||
externalDocs:
|
|
||||||
description: "Find out more about Swagger"
|
|
||||||
url: "http://swagger.io"
|
|
@ -1,98 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
var utils = require('../utils/writer.js');
|
|
||||||
var Pet = require('../service/PetService');
|
|
||||||
|
|
||||||
module.exports.addPet = function addPet (req, res, next) {
|
|
||||||
var pet = req.swagger.params['Pet'].value;
|
|
||||||
Pet.addPet(pet)
|
|
||||||
.then(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
})
|
|
||||||
.catch(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports.deletePet = function deletePet (req, res, next) {
|
|
||||||
var petId = req.swagger.params['petId'].value;
|
|
||||||
var apiUnderscorekey = req.swagger.params['api_key'].value;
|
|
||||||
Pet.deletePet(petId,apiUnderscorekey)
|
|
||||||
.then(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
})
|
|
||||||
.catch(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports.findPetsByStatus = function findPetsByStatus (req, res, next) {
|
|
||||||
var status = req.swagger.params['status'].value;
|
|
||||||
Pet.findPetsByStatus(status)
|
|
||||||
.then(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
})
|
|
||||||
.catch(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports.findPetsByTags = function findPetsByTags (req, res, next) {
|
|
||||||
var tags = req.swagger.params['tags'].value;
|
|
||||||
var maxCount = req.swagger.params['maxCount'].value;
|
|
||||||
Pet.findPetsByTags(tags,maxCount)
|
|
||||||
.then(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
})
|
|
||||||
.catch(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports.getPetById = function getPetById (req, res, next) {
|
|
||||||
var petId = req.swagger.params['petId'].value;
|
|
||||||
Pet.getPetById(petId)
|
|
||||||
.then(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
})
|
|
||||||
.catch(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports.updatePet = function updatePet (req, res, next) {
|
|
||||||
var pet = req.swagger.params['Pet'].value;
|
|
||||||
Pet.updatePet(pet)
|
|
||||||
.then(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
})
|
|
||||||
.catch(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports.updatePetWithForm = function updatePetWithForm (req, res, next) {
|
|
||||||
var petId = req.swagger.params['petId'].value;
|
|
||||||
var name = req.swagger.params['name'].value;
|
|
||||||
var status = req.swagger.params['status'].value;
|
|
||||||
Pet.updatePetWithForm(petId,name,status)
|
|
||||||
.then(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
})
|
|
||||||
.catch(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports.uploadFile = function uploadFile (req, res, next) {
|
|
||||||
var petId = req.swagger.params['petId'].value;
|
|
||||||
var additionalMetadata = req.swagger.params['additionalMetadata'].value;
|
|
||||||
var file = req.swagger.params['file'].value;
|
|
||||||
Pet.uploadFile(petId,additionalMetadata,file)
|
|
||||||
.then(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
})
|
|
||||||
.catch(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
});
|
|
||||||
};
|
|
@ -1,166 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
exports.addPet = function(args, res, next) {
|
|
||||||
/**
|
|
||||||
* Add a new pet to the store
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* body Pet Pet object that needs to be added to the store
|
|
||||||
* no response value expected for this operation
|
|
||||||
**/
|
|
||||||
res.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.deletePet = function(args, res, next) {
|
|
||||||
/**
|
|
||||||
* Deletes a pet
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* petId Long Pet id to delete
|
|
||||||
* api_key String (optional)
|
|
||||||
* no response value expected for this operation
|
|
||||||
**/
|
|
||||||
res.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.findPetsByStatus = function(args, res, next) {
|
|
||||||
/**
|
|
||||||
* Finds Pets by status
|
|
||||||
* Multiple status values can be provided with comma separated strings
|
|
||||||
*
|
|
||||||
* status List Status values that need to be considered for filter
|
|
||||||
* returns List
|
|
||||||
**/
|
|
||||||
var examples = {};
|
|
||||||
examples['application/json'] = [ {
|
|
||||||
"photoUrls" : [ "aeiou" ],
|
|
||||||
"name" : "doggie",
|
|
||||||
"id" : 0,
|
|
||||||
"category" : {
|
|
||||||
"name" : "aeiou",
|
|
||||||
"id" : 6
|
|
||||||
},
|
|
||||||
"tags" : [ {
|
|
||||||
"name" : "aeiou",
|
|
||||||
"id" : 1
|
|
||||||
} ],
|
|
||||||
"status" : "available"
|
|
||||||
} ];
|
|
||||||
if (Object.keys(examples).length > 0) {
|
|
||||||
res.setHeader('Content-Type', 'application/json');
|
|
||||||
res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2));
|
|
||||||
} else {
|
|
||||||
res.end();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.findPetsByTags = function(args, res, next) {
|
|
||||||
/**
|
|
||||||
* Finds Pets by tags
|
|
||||||
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
|
||||||
*
|
|
||||||
* tags List Tags to filter by
|
|
||||||
* returns List
|
|
||||||
**/
|
|
||||||
var examples = {};
|
|
||||||
examples['application/json'] = [ {
|
|
||||||
"photoUrls" : [ "aeiou" ],
|
|
||||||
"name" : "doggie",
|
|
||||||
"id" : 0,
|
|
||||||
"category" : {
|
|
||||||
"name" : "aeiou",
|
|
||||||
"id" : 6
|
|
||||||
},
|
|
||||||
"tags" : [ {
|
|
||||||
"name" : "aeiou",
|
|
||||||
"id" : 1
|
|
||||||
} ],
|
|
||||||
"status" : "available"
|
|
||||||
} ];
|
|
||||||
if (Object.keys(examples).length > 0) {
|
|
||||||
res.setHeader('Content-Type', 'application/json');
|
|
||||||
res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2));
|
|
||||||
} else {
|
|
||||||
res.end();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.getPetById = function(args, res, next) {
|
|
||||||
/**
|
|
||||||
* Find pet by ID
|
|
||||||
* Returns a single pet
|
|
||||||
*
|
|
||||||
* petId Long ID of pet to return
|
|
||||||
* returns Pet
|
|
||||||
**/
|
|
||||||
var examples = {};
|
|
||||||
examples['application/json'] = {
|
|
||||||
"photoUrls" : [ "aeiou" ],
|
|
||||||
"name" : "doggie",
|
|
||||||
"id" : 0,
|
|
||||||
"category" : {
|
|
||||||
"name" : "aeiou",
|
|
||||||
"id" : 6
|
|
||||||
},
|
|
||||||
"tags" : [ {
|
|
||||||
"name" : "aeiou",
|
|
||||||
"id" : 1
|
|
||||||
} ],
|
|
||||||
"status" : "available"
|
|
||||||
};
|
|
||||||
if (Object.keys(examples).length > 0) {
|
|
||||||
res.setHeader('Content-Type', 'application/json');
|
|
||||||
res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2));
|
|
||||||
} else {
|
|
||||||
res.end();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.updatePet = function(args, res, next) {
|
|
||||||
/**
|
|
||||||
* Update an existing pet
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* body Pet Pet object that needs to be added to the store
|
|
||||||
* no response value expected for this operation
|
|
||||||
**/
|
|
||||||
res.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.updatePetWithForm = function(args, res, next) {
|
|
||||||
/**
|
|
||||||
* 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)
|
|
||||||
* status String Updated status of the pet (optional)
|
|
||||||
* no response value expected for this operation
|
|
||||||
**/
|
|
||||||
res.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.uploadFile = function(args, res, next) {
|
|
||||||
/**
|
|
||||||
* uploads an image
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* petId Long ID of pet to update
|
|
||||||
* additionalMetadata String Additional data to pass to server (optional)
|
|
||||||
* file File file to upload (optional)
|
|
||||||
* returns ApiResponse
|
|
||||||
**/
|
|
||||||
var examples = {};
|
|
||||||
examples['application/json'] = {
|
|
||||||
"code" : 0,
|
|
||||||
"type" : "aeiou",
|
|
||||||
"message" : "aeiou"
|
|
||||||
};
|
|
||||||
if (Object.keys(examples).length > 0) {
|
|
||||||
res.setHeader('Content-Type', 'application/json');
|
|
||||||
res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2));
|
|
||||||
} else {
|
|
||||||
res.end();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,47 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
var utils = require('../utils/writer.js');
|
|
||||||
var Store = require('../service/StoreService');
|
|
||||||
|
|
||||||
module.exports.deleteOrder = function deleteOrder (req, res, next) {
|
|
||||||
var orderId = req.swagger.params['orderId'].value;
|
|
||||||
Store.deleteOrder(orderId)
|
|
||||||
.then(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
})
|
|
||||||
.catch(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports.getInventory = function getInventory (req, res, next) {
|
|
||||||
Store.getInventory()
|
|
||||||
.then(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
})
|
|
||||||
.catch(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports.getOrderById = function getOrderById (req, res, next) {
|
|
||||||
var orderId = req.swagger.params['orderId'].value;
|
|
||||||
Store.getOrderById(orderId)
|
|
||||||
.then(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
})
|
|
||||||
.catch(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports.placeOrder = function placeOrder (req, res, next) {
|
|
||||||
var order = req.swagger.params['Order'].value;
|
|
||||||
Store.placeOrder(order)
|
|
||||||
.then(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
})
|
|
||||||
.catch(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
});
|
|
||||||
};
|
|
@ -1,82 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
exports.deleteOrder = function(args, res, next) {
|
|
||||||
/**
|
|
||||||
* Delete purchase order by ID
|
|
||||||
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
|
||||||
*
|
|
||||||
* orderId String ID of the order that needs to be deleted
|
|
||||||
* no response value expected for this operation
|
|
||||||
**/
|
|
||||||
res.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.getInventory = function(args, res, next) {
|
|
||||||
/**
|
|
||||||
* Returns pet inventories by status
|
|
||||||
* Returns a map of status codes to quantities
|
|
||||||
*
|
|
||||||
* returns Map
|
|
||||||
**/
|
|
||||||
var examples = {};
|
|
||||||
examples['application/json'] = {
|
|
||||||
"key" : 0
|
|
||||||
};
|
|
||||||
if (Object.keys(examples).length > 0) {
|
|
||||||
res.setHeader('Content-Type', 'application/json');
|
|
||||||
res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2));
|
|
||||||
} else {
|
|
||||||
res.end();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.getOrderById = function(args, res, next) {
|
|
||||||
/**
|
|
||||||
* Find purchase order by ID
|
|
||||||
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
|
||||||
*
|
|
||||||
* orderId Long ID of pet that needs to be fetched
|
|
||||||
* returns Order
|
|
||||||
**/
|
|
||||||
var examples = {};
|
|
||||||
examples['application/json'] = {
|
|
||||||
"petId" : 6,
|
|
||||||
"quantity" : 1,
|
|
||||||
"id" : 0,
|
|
||||||
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
|
||||||
"complete" : false,
|
|
||||||
"status" : "placed"
|
|
||||||
};
|
|
||||||
if (Object.keys(examples).length > 0) {
|
|
||||||
res.setHeader('Content-Type', 'application/json');
|
|
||||||
res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2));
|
|
||||||
} else {
|
|
||||||
res.end();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.placeOrder = function(args, res, next) {
|
|
||||||
/**
|
|
||||||
* Place an order for a pet
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* body Order order placed for purchasing the pet
|
|
||||||
* returns Order
|
|
||||||
**/
|
|
||||||
var examples = {};
|
|
||||||
examples['application/json'] = {
|
|
||||||
"petId" : 6,
|
|
||||||
"quantity" : 1,
|
|
||||||
"id" : 0,
|
|
||||||
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
|
||||||
"complete" : false,
|
|
||||||
"status" : "placed"
|
|
||||||
};
|
|
||||||
if (Object.keys(examples).length > 0) {
|
|
||||||
res.setHeader('Content-Type', 'application/json');
|
|
||||||
res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2));
|
|
||||||
} else {
|
|
||||||
res.end();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,93 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
var utils = require('../utils/writer.js');
|
|
||||||
var User = require('../service/UserService');
|
|
||||||
|
|
||||||
module.exports.createUser = function createUser (req, res, next) {
|
|
||||||
var user = req.swagger.params['User'].value;
|
|
||||||
User.createUser(user)
|
|
||||||
.then(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
})
|
|
||||||
.catch(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports.createUsersWithArrayInput = function createUsersWithArrayInput (req, res, next) {
|
|
||||||
var user = req.swagger.params['User'].value;
|
|
||||||
User.createUsersWithArrayInput(user)
|
|
||||||
.then(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
})
|
|
||||||
.catch(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports.createUsersWithListInput = function createUsersWithListInput (req, res, next) {
|
|
||||||
var user = req.swagger.params['User'].value;
|
|
||||||
User.createUsersWithListInput(user)
|
|
||||||
.then(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
})
|
|
||||||
.catch(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports.deleteUser = function deleteUser (req, res, next) {
|
|
||||||
var username = req.swagger.params['username'].value;
|
|
||||||
User.deleteUser(username)
|
|
||||||
.then(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
})
|
|
||||||
.catch(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports.getUserByName = function getUserByName (req, res, next) {
|
|
||||||
var username = req.swagger.params['username'].value;
|
|
||||||
User.getUserByName(username)
|
|
||||||
.then(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
})
|
|
||||||
.catch(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports.loginUser = function loginUser (req, res, next) {
|
|
||||||
var username = req.swagger.params['username'].value;
|
|
||||||
var password = req.swagger.params['password'].value;
|
|
||||||
User.loginUser(username,password)
|
|
||||||
.then(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
})
|
|
||||||
.catch(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports.logoutUser = function logoutUser (req, res, next) {
|
|
||||||
User.logoutUser()
|
|
||||||
.then(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
})
|
|
||||||
.catch(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports.updateUser = function updateUser (req, res, next) {
|
|
||||||
var username = req.swagger.params['username'].value;
|
|
||||||
var user = req.swagger.params['User'].value;
|
|
||||||
User.updateUser(username,user)
|
|
||||||
.then(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
})
|
|
||||||
.catch(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
});
|
|
||||||
};
|
|
@ -1,114 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
exports.createUser = function(args, res, next) {
|
|
||||||
/**
|
|
||||||
* Create user
|
|
||||||
* This can only be done by the logged in user.
|
|
||||||
*
|
|
||||||
* body User Created user object
|
|
||||||
* no response value expected for this operation
|
|
||||||
**/
|
|
||||||
res.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.createUsersWithArrayInput = function(args, res, next) {
|
|
||||||
/**
|
|
||||||
* Creates list of users with given input array
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* body List List of user object
|
|
||||||
* no response value expected for this operation
|
|
||||||
**/
|
|
||||||
res.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.createUsersWithListInput = function(args, res, next) {
|
|
||||||
/**
|
|
||||||
* Creates list of users with given input array
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* body List List of user object
|
|
||||||
* no response value expected for this operation
|
|
||||||
**/
|
|
||||||
res.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.deleteUser = function(args, res, next) {
|
|
||||||
/**
|
|
||||||
* Delete user
|
|
||||||
* This can only be done by the logged in user.
|
|
||||||
*
|
|
||||||
* username String The name that needs to be deleted
|
|
||||||
* no response value expected for this operation
|
|
||||||
**/
|
|
||||||
res.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.getUserByName = function(args, res, next) {
|
|
||||||
/**
|
|
||||||
* Get user by user name
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* username String The name that needs to be fetched. Use user1 for testing.
|
|
||||||
* returns User
|
|
||||||
**/
|
|
||||||
var examples = {};
|
|
||||||
examples['application/json'] = {
|
|
||||||
"firstName" : "aeiou",
|
|
||||||
"lastName" : "aeiou",
|
|
||||||
"password" : "aeiou",
|
|
||||||
"userStatus" : 6,
|
|
||||||
"phone" : "aeiou",
|
|
||||||
"id" : 0,
|
|
||||||
"email" : "aeiou",
|
|
||||||
"username" : "aeiou"
|
|
||||||
};
|
|
||||||
if (Object.keys(examples).length > 0) {
|
|
||||||
res.setHeader('Content-Type', 'application/json');
|
|
||||||
res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2));
|
|
||||||
} else {
|
|
||||||
res.end();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.loginUser = function(args, res, next) {
|
|
||||||
/**
|
|
||||||
* Logs user into the system
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* username String The user name for login
|
|
||||||
* password String The password for login in clear text
|
|
||||||
* returns String
|
|
||||||
**/
|
|
||||||
var examples = {};
|
|
||||||
examples['application/json'] = "aeiou";
|
|
||||||
if (Object.keys(examples).length > 0) {
|
|
||||||
res.setHeader('Content-Type', 'application/json');
|
|
||||||
res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2));
|
|
||||||
} else {
|
|
||||||
res.end();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.logoutUser = function(args, res, next) {
|
|
||||||
/**
|
|
||||||
* Logs out current logged in user session
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* no response value expected for this operation
|
|
||||||
**/
|
|
||||||
res.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.updateUser = function(args, res, next) {
|
|
||||||
/**
|
|
||||||
* Updated user
|
|
||||||
* This can only be done by the logged in user.
|
|
||||||
*
|
|
||||||
* username String name that need to be deleted
|
|
||||||
* body User Updated user object
|
|
||||||
* no response value expected for this operation
|
|
||||||
**/
|
|
||||||
res.end();
|
|
||||||
}
|
|
||||||
|
|
@ -1,44 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
var swaggerTools = require('swagger-tools');
|
|
||||||
var jsyaml = require('js-yaml');
|
|
||||||
var fs = require('fs');
|
|
||||||
|
|
||||||
// swaggerRouter configuration
|
|
||||||
var options = {
|
|
||||||
controllers: './controllers',
|
|
||||||
useStubs: false
|
|
||||||
};
|
|
||||||
|
|
||||||
// The Swagger document (require it, build it programmatically, fetch it from a URL, ...)
|
|
||||||
var spec = fs.readFileSync('./api/swagger.yaml', 'utf8');
|
|
||||||
var swaggerDoc = jsyaml.safeLoad(spec);
|
|
||||||
|
|
||||||
function toPromise(f, req, res) {
|
|
||||||
return new Promise(function(resolve, reject) {
|
|
||||||
f(req, res, function(err) {
|
|
||||||
if (err) {
|
|
||||||
reject(err);
|
|
||||||
} else {
|
|
||||||
resolve();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.v2 = function(req, res) {
|
|
||||||
swaggerTools.initializeMiddleware(swaggerDoc, function(middleware) {
|
|
||||||
var metadata = middleware.swaggerMetadata();
|
|
||||||
var validator = middleware.swaggerValidator();
|
|
||||||
var router = middleware.swaggerRouter(options);
|
|
||||||
req.url = swaggerDoc.basePath + req.url;
|
|
||||||
toPromise(metadata, req, res).then(function() {
|
|
||||||
return toPromise(validator, req, res);
|
|
||||||
}).then(function() {
|
|
||||||
return toPromise(router, req, res);
|
|
||||||
}).catch(function(err) {
|
|
||||||
console.error(err);
|
|
||||||
res.status(res.statusCode || 400).send(err);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "swagger-petstore",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"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.",
|
|
||||||
"main": "index.js",
|
|
||||||
"keywords": [
|
|
||||||
"swagger"
|
|
||||||
],
|
|
||||||
"license": "Unlicense",
|
|
||||||
"private": true,
|
|
||||||
"dependencies": {
|
|
||||||
"js-yaml": "^3.3.0",
|
|
||||||
"swagger-tools": "0.10.1"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,191 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a new pet 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(pet) {
|
|
||||||
return new Promise(function(resolve, reject) {
|
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deletes a pet
|
|
||||||
*
|
|
||||||
* petId Long Pet id to delete
|
|
||||||
* apiUnderscorekey String (optional)
|
|
||||||
* no response value expected for this operation
|
|
||||||
**/
|
|
||||||
exports.deletePet = function(petId,apiUnderscorekey) {
|
|
||||||
return new Promise(function(resolve, reject) {
|
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds Pets by status
|
|
||||||
* Multiple status values can be provided with comma separated strings
|
|
||||||
*
|
|
||||||
* status List Status values that need to be considered for filter
|
|
||||||
* returns List
|
|
||||||
**/
|
|
||||||
exports.findPetsByStatus = function(status) {
|
|
||||||
return new Promise(function(resolve, reject) {
|
|
||||||
var examples = {};
|
|
||||||
examples['application/json'] = {
|
|
||||||
"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 {
|
|
||||||
resolve();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds Pets by tags
|
|
||||||
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
|
||||||
*
|
|
||||||
* tags List Tags to filter by
|
|
||||||
* maxCount Integer Maximum number of items to return (optional)
|
|
||||||
* returns List
|
|
||||||
**/
|
|
||||||
exports.findPetsByTags = function(tags,maxCount) {
|
|
||||||
return new Promise(function(resolve, reject) {
|
|
||||||
var examples = {};
|
|
||||||
examples['application/json'] = {
|
|
||||||
"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 {
|
|
||||||
resolve();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Find pet by ID
|
|
||||||
* Returns a single pet
|
|
||||||
*
|
|
||||||
* petId Long ID of pet to return
|
|
||||||
* returns Pet
|
|
||||||
**/
|
|
||||||
exports.getPetById = function(petId) {
|
|
||||||
return new Promise(function(resolve, reject) {
|
|
||||||
var examples = {};
|
|
||||||
examples['application/json'] = {
|
|
||||||
"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 {
|
|
||||||
resolve();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update an existing pet
|
|
||||||
*
|
|
||||||
* pet Pet Pet object that needs to be added to the store
|
|
||||||
* no response value expected for this operation
|
|
||||||
**/
|
|
||||||
exports.updatePet = function(pet) {
|
|
||||||
return new Promise(function(resolve, reject) {
|
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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)
|
|
||||||
* status String Updated status of the pet (optional)
|
|
||||||
* no response value expected for this operation
|
|
||||||
**/
|
|
||||||
exports.updatePetWithForm = function(petId,name,status) {
|
|
||||||
return new Promise(function(resolve, reject) {
|
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* uploads an image
|
|
||||||
*
|
|
||||||
* petId Long ID of pet to update
|
|
||||||
* additionalMetadata String Additional data to pass to server (optional)
|
|
||||||
* file File file to upload (optional)
|
|
||||||
* returns ApiResponse
|
|
||||||
**/
|
|
||||||
exports.uploadFile = function(petId,additionalMetadata,file) {
|
|
||||||
return new Promise(function(resolve, reject) {
|
|
||||||
var examples = {};
|
|
||||||
examples['application/json'] = {
|
|
||||||
"code" : 0,
|
|
||||||
"type" : "type",
|
|
||||||
"message" : "message"
|
|
||||||
};
|
|
||||||
if (Object.keys(examples).length > 0) {
|
|
||||||
resolve(examples[Object.keys(examples)[0]]);
|
|
||||||
} else {
|
|
||||||
resolve();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
@ -1,87 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete purchase order by ID
|
|
||||||
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
|
||||||
*
|
|
||||||
* orderId String ID of the order that needs to be deleted
|
|
||||||
* no response value expected for this operation
|
|
||||||
**/
|
|
||||||
exports.deleteOrder = function(orderId) {
|
|
||||||
return new Promise(function(resolve, reject) {
|
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns pet inventories by status
|
|
||||||
* Returns a map of status codes to quantities
|
|
||||||
*
|
|
||||||
* returns Map
|
|
||||||
**/
|
|
||||||
exports.getInventory = function() {
|
|
||||||
return new Promise(function(resolve, reject) {
|
|
||||||
var examples = {};
|
|
||||||
if (Object.keys(examples).length > 0) {
|
|
||||||
resolve(examples[Object.keys(examples)[0]]);
|
|
||||||
} else {
|
|
||||||
resolve();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Find purchase order by ID
|
|
||||||
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
|
||||||
*
|
|
||||||
* orderId Long ID of pet that needs to be fetched
|
|
||||||
* returns Order
|
|
||||||
**/
|
|
||||||
exports.getOrderById = function(orderId) {
|
|
||||||
return new Promise(function(resolve, reject) {
|
|
||||||
var examples = {};
|
|
||||||
examples['application/json'] = {
|
|
||||||
"petId" : 6,
|
|
||||||
"quantity" : 1,
|
|
||||||
"id" : 0,
|
|
||||||
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
|
||||||
"complete" : false,
|
|
||||||
"status" : "placed"
|
|
||||||
};
|
|
||||||
if (Object.keys(examples).length > 0) {
|
|
||||||
resolve(examples[Object.keys(examples)[0]]);
|
|
||||||
} else {
|
|
||||||
resolve();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Place an order for a pet
|
|
||||||
*
|
|
||||||
* order Order order placed for purchasing the pet
|
|
||||||
* returns Order
|
|
||||||
**/
|
|
||||||
exports.placeOrder = function(order) {
|
|
||||||
return new Promise(function(resolve, reject) {
|
|
||||||
var examples = {};
|
|
||||||
examples['application/json'] = {
|
|
||||||
"petId" : 6,
|
|
||||||
"quantity" : 1,
|
|
||||||
"id" : 0,
|
|
||||||
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
|
||||||
"complete" : false,
|
|
||||||
"status" : "placed"
|
|
||||||
};
|
|
||||||
if (Object.keys(examples).length > 0) {
|
|
||||||
resolve(examples[Object.keys(examples)[0]]);
|
|
||||||
} else {
|
|
||||||
resolve();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
@ -1,130 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create user
|
|
||||||
* This can only be done by the logged in user.
|
|
||||||
*
|
|
||||||
* user User Created user object
|
|
||||||
* no response value expected for this operation
|
|
||||||
**/
|
|
||||||
exports.createUser = function(user) {
|
|
||||||
return new Promise(function(resolve, reject) {
|
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates list of users with given input array
|
|
||||||
*
|
|
||||||
* user List List of user object
|
|
||||||
* no response value expected for this operation
|
|
||||||
**/
|
|
||||||
exports.createUsersWithArrayInput = function(user) {
|
|
||||||
return new Promise(function(resolve, reject) {
|
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates list of users with given input array
|
|
||||||
*
|
|
||||||
* user List List of user object
|
|
||||||
* no response value expected for this operation
|
|
||||||
**/
|
|
||||||
exports.createUsersWithListInput = function(user) {
|
|
||||||
return new Promise(function(resolve, reject) {
|
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete user
|
|
||||||
* This can only be done by the logged in user.
|
|
||||||
*
|
|
||||||
* username String The name that needs to be deleted
|
|
||||||
* no response value expected for this operation
|
|
||||||
**/
|
|
||||||
exports.deleteUser = function(username) {
|
|
||||||
return new Promise(function(resolve, reject) {
|
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get user by user name
|
|
||||||
*
|
|
||||||
* username String The name that needs to be fetched. Use user1 for testing.
|
|
||||||
* returns User
|
|
||||||
**/
|
|
||||||
exports.getUserByName = function(username) {
|
|
||||||
return new Promise(function(resolve, reject) {
|
|
||||||
var examples = {};
|
|
||||||
examples['application/json'] = {
|
|
||||||
"firstName" : "firstName",
|
|
||||||
"lastName" : "lastName",
|
|
||||||
"password" : "password",
|
|
||||||
"userStatus" : 6,
|
|
||||||
"phone" : "phone",
|
|
||||||
"id" : 0,
|
|
||||||
"email" : "email",
|
|
||||||
"username" : "username"
|
|
||||||
};
|
|
||||||
if (Object.keys(examples).length > 0) {
|
|
||||||
resolve(examples[Object.keys(examples)[0]]);
|
|
||||||
} else {
|
|
||||||
resolve();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Logs user into the system
|
|
||||||
*
|
|
||||||
* username String The user name for login
|
|
||||||
* password String The password for login in clear text
|
|
||||||
* returns String
|
|
||||||
**/
|
|
||||||
exports.loginUser = function(username,password) {
|
|
||||||
return new Promise(function(resolve, reject) {
|
|
||||||
var examples = {};
|
|
||||||
if (Object.keys(examples).length > 0) {
|
|
||||||
resolve(examples[Object.keys(examples)[0]]);
|
|
||||||
} else {
|
|
||||||
resolve();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Logs out current logged in user session
|
|
||||||
*
|
|
||||||
* no response value expected for this operation
|
|
||||||
**/
|
|
||||||
exports.logoutUser = function() {
|
|
||||||
return new Promise(function(resolve, reject) {
|
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updated user
|
|
||||||
* This can only be done by the logged in user.
|
|
||||||
*
|
|
||||||
* username String name that need to be deleted
|
|
||||||
* user User Updated user object
|
|
||||||
* no response value expected for this operation
|
|
||||||
**/
|
|
||||||
exports.updateUser = function(username,user) {
|
|
||||||
return new Promise(function(resolve, reject) {
|
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
@ -1,43 +0,0 @@
|
|||||||
var ResponsePayload = function(code, payload) {
|
|
||||||
this.code = code;
|
|
||||||
this.payload = payload;
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.respondWithCode = function(code, payload) {
|
|
||||||
return new ResponsePayload(code, payload);
|
|
||||||
}
|
|
||||||
|
|
||||||
var writeJson = exports.writeJson = function(response, arg1, arg2) {
|
|
||||||
var code;
|
|
||||||
var payload;
|
|
||||||
|
|
||||||
if(arg1 && arg1 instanceof ResponsePayload) {
|
|
||||||
writeJson(response, arg1.payload, arg1.code);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(arg2 && Number.isInteger(arg2)) {
|
|
||||||
code = arg2;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if(arg1 && Number.isInteger(arg1)) {
|
|
||||||
code = arg1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(code && arg1) {
|
|
||||||
payload = arg1;
|
|
||||||
}
|
|
||||||
else if(arg1) {
|
|
||||||
payload = arg1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!code) {
|
|
||||||
// if no response code given, we default to 200
|
|
||||||
code = 200;
|
|
||||||
}
|
|
||||||
if(typeof payload === 'object') {
|
|
||||||
payload = JSON.stringify(payload, null, 2);
|
|
||||||
}
|
|
||||||
response.writeHead(code, {'Content-Type': 'application/json'});
|
|
||||||
response.end(payload);
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
# OpenAPI Generator Ignore
|
|
||||||
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
|
|
||||||
|
|
||||||
# Use this file to prevent files from being overwritten by the generator.
|
|
||||||
# The patterns follow closely to .gitignore or .dockerignore.
|
|
||||||
|
|
||||||
# As an example, the C# client generator defines ApiClient.cs.
|
|
||||||
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
|
|
||||||
#ApiClient.cs
|
|
||||||
|
|
||||||
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
|
||||||
#foo/*/qux
|
|
||||||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
|
||||||
|
|
||||||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
|
||||||
#foo/**/qux
|
|
||||||
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
|
||||||
|
|
||||||
# You can also negate patterns with an exclamation (!).
|
|
||||||
# For example, you can ignore all files in a docs folder with the file extension .md:
|
|
||||||
#docs/*.md
|
|
||||||
# Then explicitly reverse the ignore rule for a single file:
|
|
||||||
#!docs/README.md
|
|
@ -1 +0,0 @@
|
|||||||
4.0.2-SNAPSHOT
|
|
@ -1,19 +0,0 @@
|
|||||||
# OpenAPI generated server
|
|
||||||
|
|
||||||
## Overview
|
|
||||||
This server was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [OpenAPI-Spec](https://github.com/OAI/OpenAPI-Specification) from a remote server, you can easily generate a server stub.
|
|
||||||
|
|
||||||
### Running the server
|
|
||||||
To run the server, run:
|
|
||||||
|
|
||||||
```
|
|
||||||
npm start
|
|
||||||
```
|
|
||||||
|
|
||||||
To view the Swagger UI interface:
|
|
||||||
|
|
||||||
```
|
|
||||||
open http://localhost:8080/docs
|
|
||||||
```
|
|
||||||
|
|
||||||
This project leverages the mega-awesome [swagger-tools](https://github.com/apigee-127/swagger-tools) middleware which does most all the work.
|
|
@ -1,837 +0,0 @@
|
|||||||
openapi: 3.0.0
|
|
||||||
info:
|
|
||||||
description: This is a sample server Petstore server. For this sample, you can use
|
|
||||||
the api key `special-key` to test the authorization filters.
|
|
||||||
license:
|
|
||||||
name: Apache-2.0
|
|
||||||
url: http://www.apache.org/licenses/LICENSE-2.0.html
|
|
||||||
title: OpenAPI Petstore
|
|
||||||
version: 1.0.0
|
|
||||||
externalDocs:
|
|
||||||
description: Find out more about Swagger
|
|
||||||
url: http://swagger.io
|
|
||||||
servers:
|
|
||||||
- url: http://petstore.swagger.io/v2
|
|
||||||
tags:
|
|
||||||
- description: Everything about your Pets
|
|
||||||
name: pet
|
|
||||||
- description: Access to Petstore orders
|
|
||||||
name: store
|
|
||||||
- description: Operations about user
|
|
||||||
name: user
|
|
||||||
paths:
|
|
||||||
/pet:
|
|
||||||
post:
|
|
||||||
operationId: addPet
|
|
||||||
requestBody:
|
|
||||||
$ref: '#/components/requestBodies/Pet'
|
|
||||||
responses:
|
|
||||||
405:
|
|
||||||
description: Invalid input
|
|
||||||
security:
|
|
||||||
- petstore_auth:
|
|
||||||
- write:pets
|
|
||||||
- read:pets
|
|
||||||
summary: Add a new pet to the store
|
|
||||||
tags:
|
|
||||||
- pet
|
|
||||||
x-swagger-router-controller: Pet
|
|
||||||
put:
|
|
||||||
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
|
|
||||||
summary: Update an existing pet
|
|
||||||
tags:
|
|
||||||
- pet
|
|
||||||
x-swagger-router-controller: Pet
|
|
||||||
/pet/findByStatus:
|
|
||||||
get:
|
|
||||||
description: Multiple status values can be provided with comma separated strings
|
|
||||||
operationId: findPetsByStatus
|
|
||||||
parameters:
|
|
||||||
- description: Status values that need to be considered for filter
|
|
||||||
explode: false
|
|
||||||
in: query
|
|
||||||
name: status
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
items:
|
|
||||||
default: available
|
|
||||||
enum:
|
|
||||||
- available
|
|
||||||
- pending
|
|
||||||
- sold
|
|
||||||
type: string
|
|
||||||
type: array
|
|
||||||
style: form
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
content:
|
|
||||||
application/xml:
|
|
||||||
schema:
|
|
||||||
items:
|
|
||||||
$ref: '#/components/schemas/Pet'
|
|
||||||
type: array
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
items:
|
|
||||||
$ref: '#/components/schemas/Pet'
|
|
||||||
type: array
|
|
||||||
description: successful operation
|
|
||||||
400:
|
|
||||||
description: Invalid status value
|
|
||||||
security:
|
|
||||||
- petstore_auth:
|
|
||||||
- read:pets
|
|
||||||
summary: Finds Pets by status
|
|
||||||
tags:
|
|
||||||
- pet
|
|
||||||
x-swagger-router-controller: Pet
|
|
||||||
/pet/findByTags:
|
|
||||||
get:
|
|
||||||
deprecated: true
|
|
||||||
description: Multiple tags can be provided with comma separated strings. Use
|
|
||||||
tag1, tag2, tag3 for testing.
|
|
||||||
operationId: findPetsByTags
|
|
||||||
parameters:
|
|
||||||
- description: Tags to filter by
|
|
||||||
explode: false
|
|
||||||
in: query
|
|
||||||
name: tags
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
items:
|
|
||||||
type: string
|
|
||||||
type: array
|
|
||||||
style: form
|
|
||||||
- description: Maximum number of items to return
|
|
||||||
explode: true
|
|
||||||
in: query
|
|
||||||
name: maxCount
|
|
||||||
required: false
|
|
||||||
schema:
|
|
||||||
format: int32
|
|
||||||
type: integer
|
|
||||||
style: form
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
content:
|
|
||||||
application/xml:
|
|
||||||
schema:
|
|
||||||
items:
|
|
||||||
$ref: '#/components/schemas/Pet'
|
|
||||||
type: array
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
items:
|
|
||||||
$ref: '#/components/schemas/Pet'
|
|
||||||
type: array
|
|
||||||
description: successful operation
|
|
||||||
400:
|
|
||||||
description: Invalid tag value
|
|
||||||
security:
|
|
||||||
- petstore_auth:
|
|
||||||
- read:pets
|
|
||||||
summary: Finds Pets by tags
|
|
||||||
tags:
|
|
||||||
- pet
|
|
||||||
x-swagger-router-controller: Pet
|
|
||||||
/pet/{petId}:
|
|
||||||
delete:
|
|
||||||
operationId: deletePet
|
|
||||||
parameters:
|
|
||||||
- explode: false
|
|
||||||
in: header
|
|
||||||
name: api_key
|
|
||||||
required: false
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
style: simple
|
|
||||||
- description: Pet id to delete
|
|
||||||
explode: false
|
|
||||||
in: path
|
|
||||||
name: petId
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
format: int64
|
|
||||||
type: integer
|
|
||||||
style: simple
|
|
||||||
responses:
|
|
||||||
400:
|
|
||||||
description: Invalid pet value
|
|
||||||
security:
|
|
||||||
- petstore_auth:
|
|
||||||
- write:pets
|
|
||||||
- read:pets
|
|
||||||
summary: Deletes a pet
|
|
||||||
tags:
|
|
||||||
- pet
|
|
||||||
x-swagger-router-controller: Pet
|
|
||||||
get:
|
|
||||||
description: Returns a single pet
|
|
||||||
operationId: getPetById
|
|
||||||
parameters:
|
|
||||||
- description: ID of pet to return
|
|
||||||
explode: false
|
|
||||||
in: path
|
|
||||||
name: petId
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
format: int64
|
|
||||||
type: integer
|
|
||||||
style: simple
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
content:
|
|
||||||
application/xml:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/Pet'
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/Pet'
|
|
||||||
description: successful operation
|
|
||||||
400:
|
|
||||||
description: Invalid ID supplied
|
|
||||||
404:
|
|
||||||
description: Pet not found
|
|
||||||
security:
|
|
||||||
- api_key: []
|
|
||||||
summary: Find pet by ID
|
|
||||||
tags:
|
|
||||||
- pet
|
|
||||||
x-swagger-router-controller: Pet
|
|
||||||
post:
|
|
||||||
operationId: updatePetWithForm
|
|
||||||
parameters:
|
|
||||||
- description: ID of pet that needs to be updated
|
|
||||||
explode: false
|
|
||||||
in: path
|
|
||||||
name: petId
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
format: int64
|
|
||||||
type: integer
|
|
||||||
style: simple
|
|
||||||
requestBody:
|
|
||||||
$ref: '#/components/requestBodies/inline_object'
|
|
||||||
content:
|
|
||||||
application/x-www-form-urlencoded:
|
|
||||||
schema:
|
|
||||||
properties:
|
|
||||||
name:
|
|
||||||
description: Updated name of the pet
|
|
||||||
type: string
|
|
||||||
status:
|
|
||||||
description: Updated status of the pet
|
|
||||||
type: string
|
|
||||||
type: object
|
|
||||||
responses:
|
|
||||||
405:
|
|
||||||
description: Invalid input
|
|
||||||
security:
|
|
||||||
- petstore_auth:
|
|
||||||
- write:pets
|
|
||||||
- read:pets
|
|
||||||
summary: Updates a pet in the store with form data
|
|
||||||
tags:
|
|
||||||
- pet
|
|
||||||
x-swagger-router-controller: Pet
|
|
||||||
/pet/{petId}/uploadImage:
|
|
||||||
post:
|
|
||||||
operationId: uploadFile
|
|
||||||
parameters:
|
|
||||||
- description: ID of pet to update
|
|
||||||
explode: false
|
|
||||||
in: path
|
|
||||||
name: petId
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
format: int64
|
|
||||||
type: integer
|
|
||||||
style: simple
|
|
||||||
requestBody:
|
|
||||||
$ref: '#/components/requestBodies/inline_object_1'
|
|
||||||
content:
|
|
||||||
multipart/form-data:
|
|
||||||
schema:
|
|
||||||
properties:
|
|
||||||
additionalMetadata:
|
|
||||||
description: Additional data to pass to server
|
|
||||||
type: string
|
|
||||||
file:
|
|
||||||
description: file to upload
|
|
||||||
format: binary
|
|
||||||
type: string
|
|
||||||
type: object
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/ApiResponse'
|
|
||||||
description: successful operation
|
|
||||||
security:
|
|
||||||
- petstore_auth:
|
|
||||||
- write:pets
|
|
||||||
- read:pets
|
|
||||||
summary: uploads an image
|
|
||||||
tags:
|
|
||||||
- pet
|
|
||||||
x-swagger-router-controller: Pet
|
|
||||||
/store/inventory:
|
|
||||||
get:
|
|
||||||
description: Returns a map of status codes to quantities
|
|
||||||
operationId: getInventory
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
additionalProperties:
|
|
||||||
format: int32
|
|
||||||
type: integer
|
|
||||||
type: object
|
|
||||||
description: successful operation
|
|
||||||
security:
|
|
||||||
- api_key: []
|
|
||||||
summary: Returns pet inventories by status
|
|
||||||
tags:
|
|
||||||
- store
|
|
||||||
x-swagger-router-controller: Store
|
|
||||||
/store/order:
|
|
||||||
post:
|
|
||||||
operationId: placeOrder
|
|
||||||
requestBody:
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/Order'
|
|
||||||
description: order placed for purchasing the pet
|
|
||||||
required: true
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
content:
|
|
||||||
application/xml:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/Order'
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/Order'
|
|
||||||
description: successful operation
|
|
||||||
400:
|
|
||||||
description: Invalid Order
|
|
||||||
summary: Place an order for a pet
|
|
||||||
tags:
|
|
||||||
- store
|
|
||||||
x-swagger-router-controller: Store
|
|
||||||
/store/order/{orderId}:
|
|
||||||
delete:
|
|
||||||
description: For valid response try integer IDs with value < 1000. Anything
|
|
||||||
above 1000 or nonintegers will generate API errors
|
|
||||||
operationId: deleteOrder
|
|
||||||
parameters:
|
|
||||||
- description: ID of the order that needs to be deleted
|
|
||||||
explode: false
|
|
||||||
in: path
|
|
||||||
name: orderId
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
style: simple
|
|
||||||
responses:
|
|
||||||
400:
|
|
||||||
description: Invalid ID supplied
|
|
||||||
404:
|
|
||||||
description: Order not found
|
|
||||||
summary: Delete purchase order by ID
|
|
||||||
tags:
|
|
||||||
- store
|
|
||||||
x-swagger-router-controller: Store
|
|
||||||
get:
|
|
||||||
description: For valid response try integer IDs with value <= 5 or > 10. Other
|
|
||||||
values will generated exceptions
|
|
||||||
operationId: getOrderById
|
|
||||||
parameters:
|
|
||||||
- description: ID of pet that needs to be fetched
|
|
||||||
explode: false
|
|
||||||
in: path
|
|
||||||
name: orderId
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
format: int64
|
|
||||||
maximum: 5
|
|
||||||
minimum: 1
|
|
||||||
type: integer
|
|
||||||
style: simple
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
content:
|
|
||||||
application/xml:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/Order'
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/Order'
|
|
||||||
description: successful operation
|
|
||||||
400:
|
|
||||||
description: Invalid ID supplied
|
|
||||||
404:
|
|
||||||
description: Order not found
|
|
||||||
summary: Find purchase order by ID
|
|
||||||
tags:
|
|
||||||
- store
|
|
||||||
x-swagger-router-controller: Store
|
|
||||||
/user:
|
|
||||||
post:
|
|
||||||
description: This can only be done by the logged in user.
|
|
||||||
operationId: createUser
|
|
||||||
requestBody:
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/User'
|
|
||||||
description: Created user object
|
|
||||||
required: true
|
|
||||||
responses:
|
|
||||||
default:
|
|
||||||
description: successful operation
|
|
||||||
security:
|
|
||||||
- auth_cookie: []
|
|
||||||
summary: Create user
|
|
||||||
tags:
|
|
||||||
- user
|
|
||||||
x-swagger-router-controller: User
|
|
||||||
/user/createWithArray:
|
|
||||||
post:
|
|
||||||
operationId: createUsersWithArrayInput
|
|
||||||
requestBody:
|
|
||||||
$ref: '#/components/requestBodies/UserArray'
|
|
||||||
responses:
|
|
||||||
default:
|
|
||||||
description: successful operation
|
|
||||||
security:
|
|
||||||
- auth_cookie: []
|
|
||||||
summary: Creates list of users with given input array
|
|
||||||
tags:
|
|
||||||
- user
|
|
||||||
x-swagger-router-controller: User
|
|
||||||
/user/createWithList:
|
|
||||||
post:
|
|
||||||
operationId: createUsersWithListInput
|
|
||||||
requestBody:
|
|
||||||
$ref: '#/components/requestBodies/UserArray'
|
|
||||||
responses:
|
|
||||||
default:
|
|
||||||
description: successful operation
|
|
||||||
security:
|
|
||||||
- auth_cookie: []
|
|
||||||
summary: Creates list of users with given input array
|
|
||||||
tags:
|
|
||||||
- user
|
|
||||||
x-swagger-router-controller: User
|
|
||||||
/user/login:
|
|
||||||
get:
|
|
||||||
operationId: loginUser
|
|
||||||
parameters:
|
|
||||||
- description: The user name for login
|
|
||||||
explode: true
|
|
||||||
in: query
|
|
||||||
name: username
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
pattern: ^[a-zA-Z0-9]+[a-zA-Z0-9\.\-_]*[a-zA-Z0-9]+$
|
|
||||||
type: string
|
|
||||||
style: form
|
|
||||||
- description: The password for login in clear text
|
|
||||||
explode: true
|
|
||||||
in: query
|
|
||||||
name: password
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
style: form
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
content:
|
|
||||||
application/xml:
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
description: successful operation
|
|
||||||
headers:
|
|
||||||
Set-Cookie:
|
|
||||||
description: Cookie authentication key for use with the `auth_cookie`
|
|
||||||
apiKey authentication.
|
|
||||||
explode: false
|
|
||||||
schema:
|
|
||||||
example: AUTH_KEY=abcde12345; Path=/; HttpOnly
|
|
||||||
type: string
|
|
||||||
style: simple
|
|
||||||
X-Rate-Limit:
|
|
||||||
description: calls per hour allowed by the user
|
|
||||||
explode: false
|
|
||||||
schema:
|
|
||||||
format: int32
|
|
||||||
type: integer
|
|
||||||
style: simple
|
|
||||||
X-Expires-After:
|
|
||||||
description: date in UTC when toekn expires
|
|
||||||
explode: false
|
|
||||||
schema:
|
|
||||||
format: date-time
|
|
||||||
type: string
|
|
||||||
style: simple
|
|
||||||
400:
|
|
||||||
description: Invalid username/password supplied
|
|
||||||
summary: Logs user into the system
|
|
||||||
tags:
|
|
||||||
- user
|
|
||||||
x-swagger-router-controller: User
|
|
||||||
/user/logout:
|
|
||||||
get:
|
|
||||||
operationId: logoutUser
|
|
||||||
responses:
|
|
||||||
default:
|
|
||||||
description: successful operation
|
|
||||||
security:
|
|
||||||
- auth_cookie: []
|
|
||||||
summary: Logs out current logged in user session
|
|
||||||
tags:
|
|
||||||
- user
|
|
||||||
x-swagger-router-controller: User
|
|
||||||
/user/{username}:
|
|
||||||
delete:
|
|
||||||
description: This can only be done by the logged in user.
|
|
||||||
operationId: deleteUser
|
|
||||||
parameters:
|
|
||||||
- description: The name that needs to be deleted
|
|
||||||
explode: false
|
|
||||||
in: path
|
|
||||||
name: username
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
style: simple
|
|
||||||
responses:
|
|
||||||
400:
|
|
||||||
description: Invalid username supplied
|
|
||||||
404:
|
|
||||||
description: User not found
|
|
||||||
security:
|
|
||||||
- auth_cookie: []
|
|
||||||
summary: Delete user
|
|
||||||
tags:
|
|
||||||
- user
|
|
||||||
x-swagger-router-controller: User
|
|
||||||
get:
|
|
||||||
operationId: getUserByName
|
|
||||||
parameters:
|
|
||||||
- description: The name that needs to be fetched. Use user1 for testing.
|
|
||||||
explode: false
|
|
||||||
in: path
|
|
||||||
name: username
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
style: simple
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
content:
|
|
||||||
application/xml:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/User'
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/User'
|
|
||||||
description: successful operation
|
|
||||||
400:
|
|
||||||
description: Invalid username supplied
|
|
||||||
404:
|
|
||||||
description: User not found
|
|
||||||
summary: Get user by user name
|
|
||||||
tags:
|
|
||||||
- user
|
|
||||||
x-swagger-router-controller: User
|
|
||||||
put:
|
|
||||||
description: This can only be done by the logged in user.
|
|
||||||
operationId: updateUser
|
|
||||||
parameters:
|
|
||||||
- description: name that need to be deleted
|
|
||||||
explode: false
|
|
||||||
in: path
|
|
||||||
name: username
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
style: simple
|
|
||||||
requestBody:
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/User'
|
|
||||||
description: Updated user object
|
|
||||||
required: true
|
|
||||||
responses:
|
|
||||||
400:
|
|
||||||
description: Invalid user supplied
|
|
||||||
404:
|
|
||||||
description: User not found
|
|
||||||
security:
|
|
||||||
- auth_cookie: []
|
|
||||||
summary: Updated user
|
|
||||||
tags:
|
|
||||||
- user
|
|
||||||
x-swagger-router-controller: User
|
|
||||||
components:
|
|
||||||
requestBodies:
|
|
||||||
UserArray:
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
items:
|
|
||||||
$ref: '#/components/schemas/User'
|
|
||||||
type: array
|
|
||||||
description: List of user object
|
|
||||||
required: true
|
|
||||||
Pet:
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/Pet'
|
|
||||||
application/xml:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/Pet'
|
|
||||||
description: Pet object that needs to be added to the store
|
|
||||||
required: true
|
|
||||||
inline_object:
|
|
||||||
content:
|
|
||||||
application/x-www-form-urlencoded:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/inline_object'
|
|
||||||
inline_object_1:
|
|
||||||
content:
|
|
||||||
multipart/form-data:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/inline_object_1'
|
|
||||||
schemas:
|
|
||||||
Order:
|
|
||||||
description: An order for a pets from the pet store
|
|
||||||
example:
|
|
||||||
petId: 6
|
|
||||||
quantity: 1
|
|
||||||
id: 0
|
|
||||||
shipDate: 2000-01-23T04:56:07.000+00:00
|
|
||||||
complete: false
|
|
||||||
status: placed
|
|
||||||
properties:
|
|
||||||
id:
|
|
||||||
format: int64
|
|
||||||
type: integer
|
|
||||||
petId:
|
|
||||||
format: int64
|
|
||||||
type: integer
|
|
||||||
quantity:
|
|
||||||
format: int32
|
|
||||||
type: integer
|
|
||||||
shipDate:
|
|
||||||
format: date-time
|
|
||||||
type: string
|
|
||||||
status:
|
|
||||||
description: Order Status
|
|
||||||
enum:
|
|
||||||
- placed
|
|
||||||
- approved
|
|
||||||
- delivered
|
|
||||||
type: string
|
|
||||||
complete:
|
|
||||||
default: false
|
|
||||||
type: boolean
|
|
||||||
title: Pet Order
|
|
||||||
type: object
|
|
||||||
xml:
|
|
||||||
name: Order
|
|
||||||
Category:
|
|
||||||
description: A category for a pet
|
|
||||||
example:
|
|
||||||
name: name
|
|
||||||
id: 6
|
|
||||||
properties:
|
|
||||||
id:
|
|
||||||
format: int64
|
|
||||||
type: integer
|
|
||||||
name:
|
|
||||||
pattern: ^[a-zA-Z0-9]+[a-zA-Z0-9\.\-_]*[a-zA-Z0-9]+$
|
|
||||||
type: string
|
|
||||||
title: Pet category
|
|
||||||
type: object
|
|
||||||
xml:
|
|
||||||
name: Category
|
|
||||||
User:
|
|
||||||
description: A User who is purchasing from the pet store
|
|
||||||
example:
|
|
||||||
firstName: firstName
|
|
||||||
lastName: lastName
|
|
||||||
password: password
|
|
||||||
userStatus: 6
|
|
||||||
phone: phone
|
|
||||||
id: 0
|
|
||||||
email: email
|
|
||||||
username: username
|
|
||||||
properties:
|
|
||||||
id:
|
|
||||||
format: int64
|
|
||||||
type: integer
|
|
||||||
username:
|
|
||||||
type: string
|
|
||||||
firstName:
|
|
||||||
type: string
|
|
||||||
lastName:
|
|
||||||
type: string
|
|
||||||
email:
|
|
||||||
type: string
|
|
||||||
password:
|
|
||||||
type: string
|
|
||||||
phone:
|
|
||||||
type: string
|
|
||||||
userStatus:
|
|
||||||
description: User Status
|
|
||||||
format: int32
|
|
||||||
type: integer
|
|
||||||
title: a User
|
|
||||||
type: object
|
|
||||||
xml:
|
|
||||||
name: User
|
|
||||||
Tag:
|
|
||||||
description: A tag for a pet
|
|
||||||
example:
|
|
||||||
name: name
|
|
||||||
id: 1
|
|
||||||
properties:
|
|
||||||
id:
|
|
||||||
format: int64
|
|
||||||
type: integer
|
|
||||||
name:
|
|
||||||
type: string
|
|
||||||
title: Pet Tag
|
|
||||||
type: object
|
|
||||||
xml:
|
|
||||||
name: Tag
|
|
||||||
Pet:
|
|
||||||
description: A pet for sale in the pet store
|
|
||||||
example:
|
|
||||||
photoUrls:
|
|
||||||
- photoUrls
|
|
||||||
- photoUrls
|
|
||||||
name: doggie
|
|
||||||
id: 0
|
|
||||||
category:
|
|
||||||
name: name
|
|
||||||
id: 6
|
|
||||||
tags:
|
|
||||||
- name: name
|
|
||||||
id: 1
|
|
||||||
- name: name
|
|
||||||
id: 1
|
|
||||||
status: available
|
|
||||||
properties:
|
|
||||||
id:
|
|
||||||
format: int64
|
|
||||||
type: integer
|
|
||||||
category:
|
|
||||||
$ref: '#/components/schemas/Category'
|
|
||||||
name:
|
|
||||||
example: doggie
|
|
||||||
type: string
|
|
||||||
photoUrls:
|
|
||||||
items:
|
|
||||||
type: string
|
|
||||||
type: array
|
|
||||||
xml:
|
|
||||||
name: photoUrl
|
|
||||||
wrapped: true
|
|
||||||
tags:
|
|
||||||
items:
|
|
||||||
$ref: '#/components/schemas/Tag'
|
|
||||||
type: array
|
|
||||||
xml:
|
|
||||||
name: tag
|
|
||||||
wrapped: true
|
|
||||||
status:
|
|
||||||
description: pet status in the store
|
|
||||||
enum:
|
|
||||||
- available
|
|
||||||
- pending
|
|
||||||
- sold
|
|
||||||
type: string
|
|
||||||
required:
|
|
||||||
- name
|
|
||||||
- photoUrls
|
|
||||||
title: a Pet
|
|
||||||
type: object
|
|
||||||
xml:
|
|
||||||
name: Pet
|
|
||||||
ApiResponse:
|
|
||||||
description: Describes the result of uploading an image resource
|
|
||||||
example:
|
|
||||||
code: 0
|
|
||||||
type: type
|
|
||||||
message: message
|
|
||||||
properties:
|
|
||||||
code:
|
|
||||||
format: int32
|
|
||||||
type: integer
|
|
||||||
type:
|
|
||||||
type: string
|
|
||||||
message:
|
|
||||||
type: string
|
|
||||||
title: An uploaded response
|
|
||||||
type: object
|
|
||||||
inline_object:
|
|
||||||
properties:
|
|
||||||
name:
|
|
||||||
description: Updated name of the pet
|
|
||||||
type: string
|
|
||||||
status:
|
|
||||||
description: Updated status of the pet
|
|
||||||
type: string
|
|
||||||
type: object
|
|
||||||
inline_object_1:
|
|
||||||
properties:
|
|
||||||
additionalMetadata:
|
|
||||||
description: Additional data to pass to server
|
|
||||||
type: string
|
|
||||||
file:
|
|
||||||
description: file to upload
|
|
||||||
format: binary
|
|
||||||
type: string
|
|
||||||
type: object
|
|
||||||
securitySchemes:
|
|
||||||
petstore_auth:
|
|
||||||
flows:
|
|
||||||
implicit:
|
|
||||||
authorizationUrl: http://petstore.swagger.io/api/oauth/dialog
|
|
||||||
scopes:
|
|
||||||
write:pets: modify pets in your account
|
|
||||||
read:pets: read your pets
|
|
||||||
type: oauth2
|
|
||||||
api_key:
|
|
||||||
in: header
|
|
||||||
name: api_key
|
|
||||||
type: apiKey
|
|
||||||
auth_cookie:
|
|
||||||
in: cookie
|
|
||||||
name: AUTH_KEY
|
|
||||||
type: apiKey
|
|
@ -1,98 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
var utils = require('../utils/writer.js');
|
|
||||||
var Pet = require('../service/PetService');
|
|
||||||
|
|
||||||
module.exports.addPet = function addPet (req, res, next) {
|
|
||||||
var pet = req.swagger.params['Pet'].value;
|
|
||||||
Pet.addPet(pet)
|
|
||||||
.then(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
})
|
|
||||||
.catch(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports.deletePet = function deletePet (req, res, next) {
|
|
||||||
var petId = req.swagger.params['petId'].value;
|
|
||||||
var apiUnderscorekey = req.swagger.params['api_key'].value;
|
|
||||||
Pet.deletePet(petId,apiUnderscorekey)
|
|
||||||
.then(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
})
|
|
||||||
.catch(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports.findPetsByStatus = function findPetsByStatus (req, res, next) {
|
|
||||||
var status = req.swagger.params['status'].value;
|
|
||||||
Pet.findPetsByStatus(status)
|
|
||||||
.then(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
})
|
|
||||||
.catch(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports.findPetsByTags = function findPetsByTags (req, res, next) {
|
|
||||||
var tags = req.swagger.params['tags'].value;
|
|
||||||
var maxCount = req.swagger.params['maxCount'].value;
|
|
||||||
Pet.findPetsByTags(tags,maxCount)
|
|
||||||
.then(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
})
|
|
||||||
.catch(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports.getPetById = function getPetById (req, res, next) {
|
|
||||||
var petId = req.swagger.params['petId'].value;
|
|
||||||
Pet.getPetById(petId)
|
|
||||||
.then(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
})
|
|
||||||
.catch(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports.updatePet = function updatePet (req, res, next) {
|
|
||||||
var pet = req.swagger.params['Pet'].value;
|
|
||||||
Pet.updatePet(pet)
|
|
||||||
.then(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
})
|
|
||||||
.catch(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports.updatePetWithForm = function updatePetWithForm (req, res, next) {
|
|
||||||
var petId = req.swagger.params['petId'].value;
|
|
||||||
var name = req.swagger.params['name'].value;
|
|
||||||
var status = req.swagger.params['status'].value;
|
|
||||||
Pet.updatePetWithForm(petId,name,status)
|
|
||||||
.then(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
})
|
|
||||||
.catch(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports.uploadFile = function uploadFile (req, res, next) {
|
|
||||||
var petId = req.swagger.params['petId'].value;
|
|
||||||
var additionalMetadata = req.swagger.params['additionalMetadata'].value;
|
|
||||||
var file = req.swagger.params['file'].value;
|
|
||||||
Pet.uploadFile(petId,additionalMetadata,file)
|
|
||||||
.then(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
})
|
|
||||||
.catch(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
});
|
|
||||||
};
|
|
@ -1,47 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
var utils = require('../utils/writer.js');
|
|
||||||
var Store = require('../service/StoreService');
|
|
||||||
|
|
||||||
module.exports.deleteOrder = function deleteOrder (req, res, next) {
|
|
||||||
var orderId = req.swagger.params['orderId'].value;
|
|
||||||
Store.deleteOrder(orderId)
|
|
||||||
.then(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
})
|
|
||||||
.catch(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports.getInventory = function getInventory (req, res, next) {
|
|
||||||
Store.getInventory()
|
|
||||||
.then(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
})
|
|
||||||
.catch(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports.getOrderById = function getOrderById (req, res, next) {
|
|
||||||
var orderId = req.swagger.params['orderId'].value;
|
|
||||||
Store.getOrderById(orderId)
|
|
||||||
.then(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
})
|
|
||||||
.catch(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports.placeOrder = function placeOrder (req, res, next) {
|
|
||||||
var order = req.swagger.params['Order'].value;
|
|
||||||
Store.placeOrder(order)
|
|
||||||
.then(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
})
|
|
||||||
.catch(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
});
|
|
||||||
};
|
|
@ -1,93 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
var utils = require('../utils/writer.js');
|
|
||||||
var User = require('../service/UserService');
|
|
||||||
|
|
||||||
module.exports.createUser = function createUser (req, res, next) {
|
|
||||||
var user = req.swagger.params['User'].value;
|
|
||||||
User.createUser(user)
|
|
||||||
.then(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
})
|
|
||||||
.catch(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports.createUsersWithArrayInput = function createUsersWithArrayInput (req, res, next) {
|
|
||||||
var user = req.swagger.params['User'].value;
|
|
||||||
User.createUsersWithArrayInput(user)
|
|
||||||
.then(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
})
|
|
||||||
.catch(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports.createUsersWithListInput = function createUsersWithListInput (req, res, next) {
|
|
||||||
var user = req.swagger.params['User'].value;
|
|
||||||
User.createUsersWithListInput(user)
|
|
||||||
.then(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
})
|
|
||||||
.catch(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports.deleteUser = function deleteUser (req, res, next) {
|
|
||||||
var username = req.swagger.params['username'].value;
|
|
||||||
User.deleteUser(username)
|
|
||||||
.then(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
})
|
|
||||||
.catch(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports.getUserByName = function getUserByName (req, res, next) {
|
|
||||||
var username = req.swagger.params['username'].value;
|
|
||||||
User.getUserByName(username)
|
|
||||||
.then(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
})
|
|
||||||
.catch(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports.loginUser = function loginUser (req, res, next) {
|
|
||||||
var username = req.swagger.params['username'].value;
|
|
||||||
var password = req.swagger.params['password'].value;
|
|
||||||
User.loginUser(username,password)
|
|
||||||
.then(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
})
|
|
||||||
.catch(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports.logoutUser = function logoutUser (req, res, next) {
|
|
||||||
User.logoutUser()
|
|
||||||
.then(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
})
|
|
||||||
.catch(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports.updateUser = function updateUser (req, res, next) {
|
|
||||||
var username = req.swagger.params['username'].value;
|
|
||||||
var user = req.swagger.params['User'].value;
|
|
||||||
User.updateUser(username,user)
|
|
||||||
.then(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
})
|
|
||||||
.catch(function (response) {
|
|
||||||
utils.writeJson(res, response);
|
|
||||||
});
|
|
||||||
};
|
|
@ -1,44 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
var fs = require('fs'),
|
|
||||||
path = require('path'),
|
|
||||||
http = require('http');
|
|
||||||
|
|
||||||
var app = require('connect')();
|
|
||||||
var swaggerTools = require('swagger-tools');
|
|
||||||
var jsyaml = require('js-yaml');
|
|
||||||
var serverPort = 8080;
|
|
||||||
|
|
||||||
// swaggerRouter configuration
|
|
||||||
var options = {
|
|
||||||
swaggerUi: path.join(__dirname, '/openapi.json'),
|
|
||||||
controllers: path.join(__dirname, './controllers'),
|
|
||||||
useStubs: process.env.NODE_ENV === 'development' // Conditionally turn on stubs (mock mode)
|
|
||||||
};
|
|
||||||
|
|
||||||
// The Swagger document (require it, build it programmatically, fetch it from a URL, ...)
|
|
||||||
var spec = fs.readFileSync(path.join(__dirname,'api/openapi.yaml'), 'utf8');
|
|
||||||
var swaggerDoc = jsyaml.safeLoad(spec);
|
|
||||||
|
|
||||||
// Initialize the Swagger middleware
|
|
||||||
swaggerTools.initializeMiddleware(swaggerDoc, function (middleware) {
|
|
||||||
|
|
||||||
// Interpret Swagger resources and attach metadata to request - must be first in swagger-tools middleware chain
|
|
||||||
app.use(middleware.swaggerMetadata());
|
|
||||||
|
|
||||||
// Validate Swagger requests
|
|
||||||
app.use(middleware.swaggerValidator());
|
|
||||||
|
|
||||||
// Route validated requests to appropriate controller
|
|
||||||
app.use(middleware.swaggerRouter(options));
|
|
||||||
|
|
||||||
// Serve the Swagger documents and Swagger UI
|
|
||||||
app.use(middleware.swaggerUi());
|
|
||||||
|
|
||||||
// Start the server
|
|
||||||
http.createServer(app).listen(serverPort, function () {
|
|
||||||
console.log('Your server is listening on port %d (http://localhost:%d)', serverPort, serverPort);
|
|
||||||
console.log('Swagger-ui is available on http://localhost:%d/docs', serverPort);
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
@ -1,20 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "swagger-petstore",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"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.",
|
|
||||||
"main": "index.js",
|
|
||||||
"scripts": {
|
|
||||||
"prestart": "npm install",
|
|
||||||
"start": "node index.js"
|
|
||||||
},
|
|
||||||
"keywords": [
|
|
||||||
"openapi-tools"
|
|
||||||
],
|
|
||||||
"license": "Unlicense",
|
|
||||||
"private": true,
|
|
||||||
"dependencies": {
|
|
||||||
"connect": "^3.2.0",
|
|
||||||
"js-yaml": "^3.3.0",
|
|
||||||
"swagger-tools": "0.10.1"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,191 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a new pet 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(pet) {
|
|
||||||
return new Promise(function(resolve, reject) {
|
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deletes a pet
|
|
||||||
*
|
|
||||||
* petId Long Pet id to delete
|
|
||||||
* apiUnderscorekey String (optional)
|
|
||||||
* no response value expected for this operation
|
|
||||||
**/
|
|
||||||
exports.deletePet = function(petId,apiUnderscorekey) {
|
|
||||||
return new Promise(function(resolve, reject) {
|
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds Pets by status
|
|
||||||
* Multiple status values can be provided with comma separated strings
|
|
||||||
*
|
|
||||||
* status List Status values that need to be considered for filter
|
|
||||||
* returns List
|
|
||||||
**/
|
|
||||||
exports.findPetsByStatus = function(status) {
|
|
||||||
return new Promise(function(resolve, reject) {
|
|
||||||
var examples = {};
|
|
||||||
examples['application/json'] = {
|
|
||||||
"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 {
|
|
||||||
resolve();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds Pets by tags
|
|
||||||
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
|
||||||
*
|
|
||||||
* tags List Tags to filter by
|
|
||||||
* maxCount Integer Maximum number of items to return (optional)
|
|
||||||
* returns List
|
|
||||||
**/
|
|
||||||
exports.findPetsByTags = function(tags,maxCount) {
|
|
||||||
return new Promise(function(resolve, reject) {
|
|
||||||
var examples = {};
|
|
||||||
examples['application/json'] = {
|
|
||||||
"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 {
|
|
||||||
resolve();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Find pet by ID
|
|
||||||
* Returns a single pet
|
|
||||||
*
|
|
||||||
* petId Long ID of pet to return
|
|
||||||
* returns Pet
|
|
||||||
**/
|
|
||||||
exports.getPetById = function(petId) {
|
|
||||||
return new Promise(function(resolve, reject) {
|
|
||||||
var examples = {};
|
|
||||||
examples['application/json'] = {
|
|
||||||
"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 {
|
|
||||||
resolve();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update an existing pet
|
|
||||||
*
|
|
||||||
* pet Pet Pet object that needs to be added to the store
|
|
||||||
* no response value expected for this operation
|
|
||||||
**/
|
|
||||||
exports.updatePet = function(pet) {
|
|
||||||
return new Promise(function(resolve, reject) {
|
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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)
|
|
||||||
* status String Updated status of the pet (optional)
|
|
||||||
* no response value expected for this operation
|
|
||||||
**/
|
|
||||||
exports.updatePetWithForm = function(petId,name,status) {
|
|
||||||
return new Promise(function(resolve, reject) {
|
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* uploads an image
|
|
||||||
*
|
|
||||||
* petId Long ID of pet to update
|
|
||||||
* additionalMetadata String Additional data to pass to server (optional)
|
|
||||||
* file File file to upload (optional)
|
|
||||||
* returns ApiResponse
|
|
||||||
**/
|
|
||||||
exports.uploadFile = function(petId,additionalMetadata,file) {
|
|
||||||
return new Promise(function(resolve, reject) {
|
|
||||||
var examples = {};
|
|
||||||
examples['application/json'] = {
|
|
||||||
"code" : 0,
|
|
||||||
"type" : "type",
|
|
||||||
"message" : "message"
|
|
||||||
};
|
|
||||||
if (Object.keys(examples).length > 0) {
|
|
||||||
resolve(examples[Object.keys(examples)[0]]);
|
|
||||||
} else {
|
|
||||||
resolve();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
@ -1,87 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete purchase order by ID
|
|
||||||
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
|
||||||
*
|
|
||||||
* orderId String ID of the order that needs to be deleted
|
|
||||||
* no response value expected for this operation
|
|
||||||
**/
|
|
||||||
exports.deleteOrder = function(orderId) {
|
|
||||||
return new Promise(function(resolve, reject) {
|
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns pet inventories by status
|
|
||||||
* Returns a map of status codes to quantities
|
|
||||||
*
|
|
||||||
* returns Map
|
|
||||||
**/
|
|
||||||
exports.getInventory = function() {
|
|
||||||
return new Promise(function(resolve, reject) {
|
|
||||||
var examples = {};
|
|
||||||
if (Object.keys(examples).length > 0) {
|
|
||||||
resolve(examples[Object.keys(examples)[0]]);
|
|
||||||
} else {
|
|
||||||
resolve();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Find purchase order by ID
|
|
||||||
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
|
||||||
*
|
|
||||||
* orderId Long ID of pet that needs to be fetched
|
|
||||||
* returns Order
|
|
||||||
**/
|
|
||||||
exports.getOrderById = function(orderId) {
|
|
||||||
return new Promise(function(resolve, reject) {
|
|
||||||
var examples = {};
|
|
||||||
examples['application/json'] = {
|
|
||||||
"petId" : 6,
|
|
||||||
"quantity" : 1,
|
|
||||||
"id" : 0,
|
|
||||||
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
|
||||||
"complete" : false,
|
|
||||||
"status" : "placed"
|
|
||||||
};
|
|
||||||
if (Object.keys(examples).length > 0) {
|
|
||||||
resolve(examples[Object.keys(examples)[0]]);
|
|
||||||
} else {
|
|
||||||
resolve();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Place an order for a pet
|
|
||||||
*
|
|
||||||
* order Order order placed for purchasing the pet
|
|
||||||
* returns Order
|
|
||||||
**/
|
|
||||||
exports.placeOrder = function(order) {
|
|
||||||
return new Promise(function(resolve, reject) {
|
|
||||||
var examples = {};
|
|
||||||
examples['application/json'] = {
|
|
||||||
"petId" : 6,
|
|
||||||
"quantity" : 1,
|
|
||||||
"id" : 0,
|
|
||||||
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
|
||||||
"complete" : false,
|
|
||||||
"status" : "placed"
|
|
||||||
};
|
|
||||||
if (Object.keys(examples).length > 0) {
|
|
||||||
resolve(examples[Object.keys(examples)[0]]);
|
|
||||||
} else {
|
|
||||||
resolve();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
@ -1,130 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create user
|
|
||||||
* This can only be done by the logged in user.
|
|
||||||
*
|
|
||||||
* user User Created user object
|
|
||||||
* no response value expected for this operation
|
|
||||||
**/
|
|
||||||
exports.createUser = function(user) {
|
|
||||||
return new Promise(function(resolve, reject) {
|
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates list of users with given input array
|
|
||||||
*
|
|
||||||
* user List List of user object
|
|
||||||
* no response value expected for this operation
|
|
||||||
**/
|
|
||||||
exports.createUsersWithArrayInput = function(user) {
|
|
||||||
return new Promise(function(resolve, reject) {
|
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates list of users with given input array
|
|
||||||
*
|
|
||||||
* user List List of user object
|
|
||||||
* no response value expected for this operation
|
|
||||||
**/
|
|
||||||
exports.createUsersWithListInput = function(user) {
|
|
||||||
return new Promise(function(resolve, reject) {
|
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete user
|
|
||||||
* This can only be done by the logged in user.
|
|
||||||
*
|
|
||||||
* username String The name that needs to be deleted
|
|
||||||
* no response value expected for this operation
|
|
||||||
**/
|
|
||||||
exports.deleteUser = function(username) {
|
|
||||||
return new Promise(function(resolve, reject) {
|
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get user by user name
|
|
||||||
*
|
|
||||||
* username String The name that needs to be fetched. Use user1 for testing.
|
|
||||||
* returns User
|
|
||||||
**/
|
|
||||||
exports.getUserByName = function(username) {
|
|
||||||
return new Promise(function(resolve, reject) {
|
|
||||||
var examples = {};
|
|
||||||
examples['application/json'] = {
|
|
||||||
"firstName" : "firstName",
|
|
||||||
"lastName" : "lastName",
|
|
||||||
"password" : "password",
|
|
||||||
"userStatus" : 6,
|
|
||||||
"phone" : "phone",
|
|
||||||
"id" : 0,
|
|
||||||
"email" : "email",
|
|
||||||
"username" : "username"
|
|
||||||
};
|
|
||||||
if (Object.keys(examples).length > 0) {
|
|
||||||
resolve(examples[Object.keys(examples)[0]]);
|
|
||||||
} else {
|
|
||||||
resolve();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Logs user into the system
|
|
||||||
*
|
|
||||||
* username String The user name for login
|
|
||||||
* password String The password for login in clear text
|
|
||||||
* returns String
|
|
||||||
**/
|
|
||||||
exports.loginUser = function(username,password) {
|
|
||||||
return new Promise(function(resolve, reject) {
|
|
||||||
var examples = {};
|
|
||||||
if (Object.keys(examples).length > 0) {
|
|
||||||
resolve(examples[Object.keys(examples)[0]]);
|
|
||||||
} else {
|
|
||||||
resolve();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Logs out current logged in user session
|
|
||||||
*
|
|
||||||
* no response value expected for this operation
|
|
||||||
**/
|
|
||||||
exports.logoutUser = function() {
|
|
||||||
return new Promise(function(resolve, reject) {
|
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updated user
|
|
||||||
* This can only be done by the logged in user.
|
|
||||||
*
|
|
||||||
* username String name that need to be deleted
|
|
||||||
* user User Updated user object
|
|
||||||
* no response value expected for this operation
|
|
||||||
**/
|
|
||||||
exports.updateUser = function(username,user) {
|
|
||||||
return new Promise(function(resolve, reject) {
|
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
@ -1,43 +0,0 @@
|
|||||||
var ResponsePayload = function(code, payload) {
|
|
||||||
this.code = code;
|
|
||||||
this.payload = payload;
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.respondWithCode = function(code, payload) {
|
|
||||||
return new ResponsePayload(code, payload);
|
|
||||||
}
|
|
||||||
|
|
||||||
var writeJson = exports.writeJson = function(response, arg1, arg2) {
|
|
||||||
var code;
|
|
||||||
var payload;
|
|
||||||
|
|
||||||
if(arg1 && arg1 instanceof ResponsePayload) {
|
|
||||||
writeJson(response, arg1.payload, arg1.code);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(arg2 && Number.isInteger(arg2)) {
|
|
||||||
code = arg2;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if(arg1 && Number.isInteger(arg1)) {
|
|
||||||
code = arg1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(code && arg1) {
|
|
||||||
payload = arg1;
|
|
||||||
}
|
|
||||||
else if(arg1) {
|
|
||||||
payload = arg1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!code) {
|
|
||||||
// if no response code given, we default to 200
|
|
||||||
code = 200;
|
|
||||||
}
|
|
||||||
if(typeof payload === 'object') {
|
|
||||||
payload = JSON.stringify(payload, null, 2);
|
|
||||||
}
|
|
||||||
response.writeHead(code, {'Content-Type': 'application/json'});
|
|
||||||
response.end(payload);
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user