forked from loafle/openapi-generator-original
fixes #1581, rebuilt server
This commit is contained in:
parent
195359008a
commit
c7e5c305a9
@ -1,19 +1,8 @@
|
|||||||
package io.swagger.codegen;
|
package io.swagger.codegen;
|
||||||
|
|
||||||
import static org.apache.commons.lang3.StringUtils.capitalize;
|
|
||||||
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
|
|
||||||
|
|
||||||
import com.samskivert.mustache.Mustache;
|
import com.samskivert.mustache.Mustache;
|
||||||
import com.samskivert.mustache.Template;
|
import com.samskivert.mustache.Template;
|
||||||
import io.swagger.models.ComposedModel;
|
import io.swagger.models.*;
|
||||||
import io.swagger.models.Contact;
|
|
||||||
import io.swagger.models.Info;
|
|
||||||
import io.swagger.models.License;
|
|
||||||
import io.swagger.models.Model;
|
|
||||||
import io.swagger.models.Operation;
|
|
||||||
import io.swagger.models.Path;
|
|
||||||
import io.swagger.models.SecurityRequirement;
|
|
||||||
import io.swagger.models.Swagger;
|
|
||||||
import io.swagger.models.auth.OAuth2Definition;
|
import io.swagger.models.auth.OAuth2Definition;
|
||||||
import io.swagger.models.auth.SecuritySchemeDefinition;
|
import io.swagger.models.auth.SecuritySchemeDefinition;
|
||||||
import io.swagger.models.parameters.Parameter;
|
import io.swagger.models.parameters.Parameter;
|
||||||
@ -23,14 +12,12 @@ import org.joda.time.DateTime;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.*;
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.io.Reader;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import static org.apache.commons.lang3.StringUtils.capitalize;
|
||||||
|
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
|
||||||
|
|
||||||
public class DefaultGenerator extends AbstractGenerator implements Generator {
|
public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||||
Logger LOGGER = LoggerFactory.getLogger(DefaultGenerator.class);
|
Logger LOGGER = LoggerFactory.getLogger(DefaultGenerator.class);
|
||||||
|
|
||||||
@ -321,6 +308,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
|||||||
if (swagger.getHost() != null) {
|
if (swagger.getHost() != null) {
|
||||||
bundle.put("host", swagger.getHost());
|
bundle.put("host", swagger.getHost());
|
||||||
}
|
}
|
||||||
|
bundle.put("swagger", this.swagger);
|
||||||
bundle.put("basePath", basePath);
|
bundle.put("basePath", basePath);
|
||||||
bundle.put("scheme", scheme);
|
bundle.put("scheme", scheme);
|
||||||
bundle.put("contextPath", contextPath);
|
bundle.put("contextPath", contextPath);
|
||||||
|
@ -1,27 +1,16 @@
|
|||||||
package io.swagger.codegen.languages;
|
package io.swagger.codegen.languages;
|
||||||
|
|
||||||
import io.swagger.codegen.CodegenConfig;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import io.swagger.codegen.CodegenOperation;
|
|
||||||
import io.swagger.codegen.CodegenParameter;
|
|
||||||
import io.swagger.codegen.CodegenResponse;
|
|
||||||
import io.swagger.codegen.CodegenType;
|
|
||||||
import io.swagger.codegen.DefaultCodegen;
|
|
||||||
import io.swagger.codegen.SupportingFile;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
import com.google.common.collect.ArrayListMultimap;
|
import com.google.common.collect.ArrayListMultimap;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
|
import io.swagger.codegen.*;
|
||||||
|
import io.swagger.models.Swagger;
|
||||||
|
import io.swagger.util.Yaml;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig {
|
public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||||
protected String apiVersion = "1.0.0";
|
protected String apiVersion = "1.0.0";
|
||||||
@ -87,7 +76,7 @@ public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
// );
|
// );
|
||||||
supportingFiles.add(new SupportingFile("swagger.mustache",
|
supportingFiles.add(new SupportingFile("swagger.mustache",
|
||||||
"api",
|
"api",
|
||||||
"swagger.json")
|
"swagger.yaml")
|
||||||
);
|
);
|
||||||
supportingFiles.add(new SupportingFile("index.mustache",
|
supportingFiles.add(new SupportingFile("index.mustache",
|
||||||
"",
|
"",
|
||||||
@ -97,6 +86,10 @@ public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
"",
|
"",
|
||||||
"package.json")
|
"package.json")
|
||||||
);
|
);
|
||||||
|
supportingFiles.add(new SupportingFile("README.mustache",
|
||||||
|
"",
|
||||||
|
"README.md")
|
||||||
|
);
|
||||||
if (System.getProperty("noservice") == null) {
|
if (System.getProperty("noservice") == null) {
|
||||||
apiTemplateFiles.put(
|
apiTemplateFiles.put(
|
||||||
"service.mustache", // the template to use
|
"service.mustache", // the template to use
|
||||||
@ -242,6 +235,14 @@ public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> postProcessSupportingFileData(Map<String, Object> objs) {
|
public Map<String, Object> postProcessSupportingFileData(Map<String, Object> objs) {
|
||||||
|
Swagger swagger = (Swagger)objs.get("swagger");
|
||||||
|
if(swagger != null) {
|
||||||
|
try {
|
||||||
|
objs.put("swagger-yaml", Yaml.mapper().writeValueAsString(swagger));
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
for (Map<String, Object> operations : getOperations(objs)) {
|
for (Map<String, Object> operations : getOperations(objs)) {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
||||||
|
@ -9,17 +9,7 @@ var {{classname}} = require('./{{classname}}Service');
|
|||||||
{{#operation}}
|
{{#operation}}
|
||||||
|
|
||||||
module.exports.{{nickname}} = function {{nickname}} (req, res, next) {
|
module.exports.{{nickname}} = function {{nickname}} (req, res, next) {
|
||||||
{{#allParams}}var {{paramName}} = req.swagger.params['{{baseName}}'].value;
|
{{classname}}.{{nickname}}(req.swagger.params, res, next);
|
||||||
{{/allParams}}
|
|
||||||
|
|
||||||
var result = {{classname}}.{{nickname}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
|
||||||
|
|
||||||
if(typeof result !== 'undefined') {
|
|
||||||
res.setHeader('Content-Type', 'application/json');
|
|
||||||
res.end(JSON.stringify(result || {}, null, 2));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
res.end();
|
|
||||||
};
|
};
|
||||||
{{/operation}}
|
{{/operation}}
|
||||||
{{/operations}}
|
{{/operations}}
|
@ -3,7 +3,8 @@
|
|||||||
var app = require('connect')();
|
var app = require('connect')();
|
||||||
var http = require('http');
|
var http = require('http');
|
||||||
var swaggerTools = require('swagger-tools');
|
var swaggerTools = require('swagger-tools');
|
||||||
|
var jsyaml = require('js-yaml');
|
||||||
|
var fs = require('fs');
|
||||||
var serverPort = {{serverPort}};
|
var serverPort = {{serverPort}};
|
||||||
|
|
||||||
// swaggerRouter configuration
|
// swaggerRouter configuration
|
||||||
@ -14,7 +15,8 @@ var options = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// The Swagger document (require it, build it programmatically, fetch it from a URL, ...)
|
// The Swagger document (require it, build it programmatically, fetch it from a URL, ...)
|
||||||
var swaggerDoc = require('./api/swagger.json');
|
var spec = fs.readFileSync('./api/swagger.yaml', 'utf8');
|
||||||
|
var swaggerDoc = jsyaml.safeLoad(spec);
|
||||||
|
|
||||||
// Initialize the Swagger middleware
|
// Initialize the Swagger middleware
|
||||||
swaggerTools.initializeMiddleware(swaggerDoc, function (middleware) {
|
swaggerTools.initializeMiddleware(swaggerDoc, function (middleware) {
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"connect": "^3.2.0",
|
"connect": "^3.2.0",
|
||||||
"swagger-tools": "0.8.*"
|
"js-yaml": "^3.3.0",
|
||||||
|
"swagger-tools": "0.9.*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,17 +2,27 @@
|
|||||||
|
|
||||||
{{#operations}}
|
{{#operations}}
|
||||||
{{#operation}}
|
{{#operation}}
|
||||||
exports.{{nickname}} = function({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {
|
exports.{{nickname}} = function(args, res, next) {
|
||||||
|
/**
|
||||||
|
* parameters expected in the args:
|
||||||
|
{{#allParams}}* {{paramName}} ({{dataType}})
|
||||||
|
{{/allParams}}**/
|
||||||
|
|
||||||
var examples = {};
|
var examples = {};
|
||||||
{{#examples}}
|
{{#examples}}
|
||||||
examples['{{contentType}}'] = {{{example}}};
|
examples['{{contentType}}'] = {{{example}}};
|
||||||
{{/examples}}
|
{{/examples}}
|
||||||
|
|
||||||
{{#returnType}}
|
{{#returnType}}
|
||||||
if(Object.keys(examples).length > 0)
|
if(Object.keys(examples).length > 0) {
|
||||||
return examples[Object.keys(examples)[0]];
|
res.setHeader('Content-Type', 'application/json');
|
||||||
|
res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
res.end();
|
||||||
|
}
|
||||||
{{/returnType}}
|
{{/returnType}}
|
||||||
|
{{^returnType}}res.end();{{/returnType}}
|
||||||
}
|
}
|
||||||
{{/operation}}
|
{{/operation}}
|
||||||
{{/operations}}
|
{{/operations}}
|
||||||
|
@ -1,43 +1 @@
|
|||||||
{
|
{{{swagger-yaml}}}
|
||||||
"swagger": "2.0",
|
|
||||||
"info": {
|
|
||||||
"title": "{{appName}}",
|
|
||||||
"description": "{{{appDescription}}}",
|
|
||||||
"version": "{{apiVersion}}"
|
|
||||||
},
|
|
||||||
{{#apiInfo}}
|
|
||||||
"produces": ["application/json"],
|
|
||||||
"host": "localhost:{{serverPort}}",
|
|
||||||
"basePath": "{{contextPath}}",
|
|
||||||
"paths": {
|
|
||||||
{{#apis}}
|
|
||||||
{{#operations}}
|
|
||||||
{{#operationsByPath}}
|
|
||||||
"{{{path}}}": {
|
|
||||||
{{#operation}}
|
|
||||||
"{{httpMethod}}": {
|
|
||||||
"summary": "{{summary}}",
|
|
||||||
"description":"{{notes}}",
|
|
||||||
"x-swagger-router-controller": "{{classname}}",
|
|
||||||
"tags": ["{{baseName}}"],
|
|
||||||
"operationId": "{{operationId}}",{{#hasParams}}
|
|
||||||
"parameters": [
|
|
||||||
{{#allParams}}{{{jsonSchema}}}{{#hasMore}},{{/hasMore}}
|
|
||||||
{{/allParams}}
|
|
||||||
],{{/hasParams}}
|
|
||||||
"responses": {
|
|
||||||
{{#responses}}"{{code}}": {{{jsonSchema}}}
|
|
||||||
{{#hasMore}},{{/hasMore}}
|
|
||||||
{{/responses}}
|
|
||||||
}
|
|
||||||
} {{#hasMore}},{{/hasMore}}
|
|
||||||
{{/operation}}
|
|
||||||
} {{#hasMore}},{{/hasMore}}
|
|
||||||
{{/operationsByPath}}
|
|
||||||
{{/operations}}
|
|
||||||
{{/apis}}
|
|
||||||
{{/apiInfo}}
|
|
||||||
}, "definitions": {
|
|
||||||
{{#models}}{{#model}}"{{classVarName}}": {{{modelJson}}}{{#hasMoreModels}},{{/hasMoreModels}}{{/model}}{{/models}}
|
|
||||||
}
|
|
||||||
}
|
|
24
samples/server/petstore/nodejs/README.md
Normal file
24
samples/server/petstore/nodejs/README.md
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# Swagger generated server
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the [swagger-spec](https://github.com/swagger-api/swagger-spec) from a remote server, you can easily generate a server stub. This is an example of building a node.js server.
|
||||||
|
|
||||||
|
This example uses the [expressjs](http://expressjs.com/) framework. To see how to make this your own, look here:
|
||||||
|
|
||||||
|
[README](https://github.com/swagger-api/swagger-codegen/README.md)
|
||||||
|
|
||||||
|
### Running the server
|
||||||
|
To run the server, follow these simple steps:
|
||||||
|
|
||||||
|
```
|
||||||
|
npm install
|
||||||
|
node .
|
||||||
|
```
|
||||||
|
|
||||||
|
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,867 +0,0 @@
|
|||||||
{
|
|
||||||
"swagger": "2.0",
|
|
||||||
"info": {
|
|
||||||
"title": "Swagger Petstore",
|
|
||||||
"description": "This is a sample server Petstore server. You can find out more about Swagger at <a href=\"http://swagger.io\">http://swagger.io</a> or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters",
|
|
||||||
"version": "1.0.0"
|
|
||||||
},
|
|
||||||
"produces": ["application/json"],
|
|
||||||
"host": "localhost:8080",
|
|
||||||
"basePath": "/v2",
|
|
||||||
"paths": {
|
|
||||||
|
|
||||||
"/user/createWithList": {
|
|
||||||
|
|
||||||
"post": {
|
|
||||||
"summary": "Creates list of users with given input array",
|
|
||||||
"description":"",
|
|
||||||
"x-swagger-router-controller": "User",
|
|
||||||
"tags": ["User"],
|
|
||||||
"operationId": "createUsersWithListInput",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"in" : "body",
|
|
||||||
"name" : "body",
|
|
||||||
"description" : "List of user object",
|
|
||||||
"required" : false,
|
|
||||||
"schema" : {
|
|
||||||
"type" : "array",
|
|
||||||
"items" : {
|
|
||||||
"$ref" : "#/definitions/User"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"default": {
|
|
||||||
"description" : "successful operation"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} ,
|
|
||||||
|
|
||||||
"/user/createWithArray": {
|
|
||||||
|
|
||||||
"post": {
|
|
||||||
"summary": "Creates list of users with given input array",
|
|
||||||
"description":"",
|
|
||||||
"x-swagger-router-controller": "User",
|
|
||||||
"tags": ["User"],
|
|
||||||
"operationId": "createUsersWithArrayInput",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"in" : "body",
|
|
||||||
"name" : "body",
|
|
||||||
"description" : "List of user object",
|
|
||||||
"required" : false,
|
|
||||||
"schema" : {
|
|
||||||
"type" : "array",
|
|
||||||
"items" : {
|
|
||||||
"$ref" : "#/definitions/User"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"default": {
|
|
||||||
"description" : "successful operation"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} ,
|
|
||||||
|
|
||||||
"/user/{username}": {
|
|
||||||
|
|
||||||
"get": {
|
|
||||||
"summary": "Get user by user name",
|
|
||||||
"description":"",
|
|
||||||
"x-swagger-router-controller": "User",
|
|
||||||
"tags": ["User"],
|
|
||||||
"operationId": "getUserByName",
|
|
||||||
"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"
|
|
||||||
},
|
|
||||||
"examples" : {
|
|
||||||
"application/json" : {
|
|
||||||
"id" : 1,
|
|
||||||
"username" : "johnp",
|
|
||||||
"firstName" : "John",
|
|
||||||
"lastName" : "Public",
|
|
||||||
"email" : "johnp@swagger.io",
|
|
||||||
"password" : "-secret-",
|
|
||||||
"phone" : "0123456789",
|
|
||||||
"userStatus" : 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
,
|
|
||||||
"400": {
|
|
||||||
"description" : "Invalid username supplied"
|
|
||||||
}
|
|
||||||
,
|
|
||||||
"404": {
|
|
||||||
"description" : "User not found"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
} ,
|
|
||||||
|
|
||||||
"put": {
|
|
||||||
"summary": "Updated user",
|
|
||||||
"description":"This can only be done by the logged in user.",
|
|
||||||
"x-swagger-router-controller": "User",
|
|
||||||
"tags": ["User"],
|
|
||||||
"operationId": "updateUser",
|
|
||||||
"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" : false,
|
|
||||||
"schema" : {
|
|
||||||
"$ref" : "#/definitions/User"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"400": {
|
|
||||||
"description" : "Invalid user supplied"
|
|
||||||
}
|
|
||||||
,
|
|
||||||
"404": {
|
|
||||||
"description" : "User not found"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
} ,
|
|
||||||
|
|
||||||
"delete": {
|
|
||||||
"summary": "Delete user",
|
|
||||||
"description":"This can only be done by the logged in user.",
|
|
||||||
"x-swagger-router-controller": "User",
|
|
||||||
"tags": ["User"],
|
|
||||||
"operationId": "deleteUser",
|
|
||||||
"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"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} ,
|
|
||||||
|
|
||||||
"/user": {
|
|
||||||
|
|
||||||
"post": {
|
|
||||||
"summary": "Create user",
|
|
||||||
"description":"This can only be done by the logged in user.",
|
|
||||||
"x-swagger-router-controller": "User",
|
|
||||||
"tags": ["User"],
|
|
||||||
"operationId": "createUser",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"in" : "body",
|
|
||||||
"name" : "body",
|
|
||||||
"description" : "Created user object",
|
|
||||||
"required" : false,
|
|
||||||
"schema" : {
|
|
||||||
"$ref" : "#/definitions/User"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"default": {
|
|
||||||
"description" : "successful operation"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} ,
|
|
||||||
|
|
||||||
"/user/logout": {
|
|
||||||
|
|
||||||
"get": {
|
|
||||||
"summary": "Logs out current logged in user session",
|
|
||||||
"description":"",
|
|
||||||
"x-swagger-router-controller": "User",
|
|
||||||
"tags": ["User"],
|
|
||||||
"operationId": "logoutUser",
|
|
||||||
"responses": {
|
|
||||||
"default": {
|
|
||||||
"description" : "successful operation"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} ,
|
|
||||||
|
|
||||||
"/user/login": {
|
|
||||||
|
|
||||||
"get": {
|
|
||||||
"summary": "Logs user into the system",
|
|
||||||
"description":"",
|
|
||||||
"x-swagger-router-controller": "User",
|
|
||||||
"tags": ["User"],
|
|
||||||
"operationId": "loginUser",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"name" : "username",
|
|
||||||
"in" : "query",
|
|
||||||
"description" : "The user name for login",
|
|
||||||
"required" : false,
|
|
||||||
"type" : "string"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name" : "password",
|
|
||||||
"in" : "query",
|
|
||||||
"description" : "The password for login in clear text",
|
|
||||||
"required" : false,
|
|
||||||
"type" : "string"
|
|
||||||
}
|
|
||||||
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description" : "successful operation",
|
|
||||||
"schema" : {
|
|
||||||
"type" : "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
,
|
|
||||||
"400": {
|
|
||||||
"description" : "Invalid username/password supplied"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} ,
|
|
||||||
|
|
||||||
|
|
||||||
"/pet": {
|
|
||||||
|
|
||||||
"put": {
|
|
||||||
"summary": "Update an existing pet",
|
|
||||||
"description":"",
|
|
||||||
"x-swagger-router-controller": "Pet",
|
|
||||||
"tags": ["Pet"],
|
|
||||||
"operationId": "updatePet",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"in" : "body",
|
|
||||||
"name" : "body",
|
|
||||||
"description" : "Pet object that needs to be added to the store",
|
|
||||||
"required" : false,
|
|
||||||
"schema" : {
|
|
||||||
"$ref" : "#/definitions/Pet"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"400": {
|
|
||||||
"description" : "Invalid ID supplied"
|
|
||||||
}
|
|
||||||
,
|
|
||||||
"404": {
|
|
||||||
"description" : "Pet not found"
|
|
||||||
}
|
|
||||||
,
|
|
||||||
"405": {
|
|
||||||
"description" : "Validation exception"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
} ,
|
|
||||||
|
|
||||||
"post": {
|
|
||||||
"summary": "Add a new pet to the store",
|
|
||||||
"description":"",
|
|
||||||
"x-swagger-router-controller": "Pet",
|
|
||||||
"tags": ["Pet"],
|
|
||||||
"operationId": "addPet",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"in" : "body",
|
|
||||||
"name" : "body",
|
|
||||||
"description" : "Pet object that needs to be added to the store",
|
|
||||||
"required" : false,
|
|
||||||
"schema" : {
|
|
||||||
"$ref" : "#/definitions/Pet"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"405": {
|
|
||||||
"description" : "Invalid input"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} ,
|
|
||||||
|
|
||||||
"/pet/{petId}/uploadImage": {
|
|
||||||
|
|
||||||
"post": {
|
|
||||||
"summary": "uploads an image",
|
|
||||||
"description":"",
|
|
||||||
"x-swagger-router-controller": "Pet",
|
|
||||||
"tags": ["Pet"],
|
|
||||||
"operationId": "uploadFile",
|
|
||||||
"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": {
|
|
||||||
"default": {
|
|
||||||
"description" : "successful operation"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} ,
|
|
||||||
|
|
||||||
"/pet/findByStatus": {
|
|
||||||
|
|
||||||
"get": {
|
|
||||||
"summary": "Finds Pets by status",
|
|
||||||
"description":"Multiple status values can be provided with comma seperated strings",
|
|
||||||
"x-swagger-router-controller": "Pet",
|
|
||||||
"tags": ["Pet"],
|
|
||||||
"operationId": "findPetsByStatus",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"name" : "status",
|
|
||||||
"in" : "query",
|
|
||||||
"description" : "Status values that need to be considered for filter",
|
|
||||||
"required" : false,
|
|
||||||
"type" : "array",
|
|
||||||
"collectionFormat" : "multi",
|
|
||||||
"default" : "available"
|
|
||||||
}
|
|
||||||
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description" : "successful operation",
|
|
||||||
"schema" : {
|
|
||||||
"type" : "array",
|
|
||||||
"items" : {
|
|
||||||
"$ref" : "#/definitions/Pet"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
,
|
|
||||||
"400": {
|
|
||||||
"description" : "Invalid status value"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} ,
|
|
||||||
|
|
||||||
"/pet/findByTags": {
|
|
||||||
|
|
||||||
"get": {
|
|
||||||
"summary": "Finds Pets by tags",
|
|
||||||
"description":"Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.",
|
|
||||||
"x-swagger-router-controller": "Pet",
|
|
||||||
"tags": ["Pet"],
|
|
||||||
"operationId": "findPetsByTags",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"name" : "tags",
|
|
||||||
"in" : "query",
|
|
||||||
"description" : "Tags to filter by",
|
|
||||||
"required" : false,
|
|
||||||
"type" : "array",
|
|
||||||
"collectionFormat" : "multi"
|
|
||||||
}
|
|
||||||
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description" : "successful operation",
|
|
||||||
"schema" : {
|
|
||||||
"type" : "array",
|
|
||||||
"items" : {
|
|
||||||
"$ref" : "#/definitions/Pet"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
,
|
|
||||||
"400": {
|
|
||||||
"description" : "Invalid tag value"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} ,
|
|
||||||
|
|
||||||
"/pet/{petId}": {
|
|
||||||
|
|
||||||
"get": {
|
|
||||||
"summary": "Find pet by ID",
|
|
||||||
"description":"Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions",
|
|
||||||
"x-swagger-router-controller": "Pet",
|
|
||||||
"tags": ["Pet"],
|
|
||||||
"operationId": "getPetById",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"name" : "petId",
|
|
||||||
"in" : "path",
|
|
||||||
"description" : "ID of pet that needs to be fetched",
|
|
||||||
"required" : true,
|
|
||||||
"type" : "integer",
|
|
||||||
"format" : "int64"
|
|
||||||
}
|
|
||||||
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description" : "successful operation",
|
|
||||||
"schema" : {
|
|
||||||
"$ref" : "#/definitions/Pet"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
,
|
|
||||||
"400": {
|
|
||||||
"description" : "Invalid ID supplied"
|
|
||||||
}
|
|
||||||
,
|
|
||||||
"404": {
|
|
||||||
"description" : "Pet not found"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
} ,
|
|
||||||
|
|
||||||
"post": {
|
|
||||||
"summary": "Updates a pet in the store with form data",
|
|
||||||
"description":"",
|
|
||||||
"x-swagger-router-controller": "Pet",
|
|
||||||
"tags": ["Pet"],
|
|
||||||
"operationId": "updatePetWithForm",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"name" : "petId",
|
|
||||||
"in" : "path",
|
|
||||||
"description" : "ID of pet that needs to be updated",
|
|
||||||
"required" : true,
|
|
||||||
"type" : "string"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"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"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
} ,
|
|
||||||
|
|
||||||
"delete": {
|
|
||||||
"summary": "Deletes a pet",
|
|
||||||
"description":"",
|
|
||||||
"x-swagger-router-controller": "Pet",
|
|
||||||
"tags": ["Pet"],
|
|
||||||
"operationId": "deletePet",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"name" : "petId",
|
|
||||||
"in" : "path",
|
|
||||||
"description" : "Pet id to delete",
|
|
||||||
"required" : true,
|
|
||||||
"type" : "integer",
|
|
||||||
"format" : "int64"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name" : "api_key",
|
|
||||||
"in" : "header",
|
|
||||||
"description" : "",
|
|
||||||
"required" : false,
|
|
||||||
"type" : "string"
|
|
||||||
}
|
|
||||||
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"400": {
|
|
||||||
"description" : "Invalid pet value"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} ,
|
|
||||||
|
|
||||||
|
|
||||||
"/store/order/{orderId}": {
|
|
||||||
|
|
||||||
"get": {
|
|
||||||
"summary": "Find purchase order by ID",
|
|
||||||
"description":"For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions",
|
|
||||||
"x-swagger-router-controller": "Store",
|
|
||||||
"tags": ["Store"],
|
|
||||||
"operationId": "getOrderById",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"name" : "orderId",
|
|
||||||
"in" : "path",
|
|
||||||
"description" : "ID of pet that needs to be fetched",
|
|
||||||
"required" : true,
|
|
||||||
"type" : "string"
|
|
||||||
}
|
|
||||||
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description" : "successful operation",
|
|
||||||
"schema" : {
|
|
||||||
"$ref" : "#/definitions/Order"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
,
|
|
||||||
"400": {
|
|
||||||
"description" : "Invalid ID supplied"
|
|
||||||
}
|
|
||||||
,
|
|
||||||
"404": {
|
|
||||||
"description" : "Order not found"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
} ,
|
|
||||||
|
|
||||||
"delete": {
|
|
||||||
"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",
|
|
||||||
"x-swagger-router-controller": "Store",
|
|
||||||
"tags": ["Store"],
|
|
||||||
"operationId": "deleteOrder",
|
|
||||||
"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"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} ,
|
|
||||||
|
|
||||||
"/store/order": {
|
|
||||||
|
|
||||||
"post": {
|
|
||||||
"summary": "Place an order for a pet",
|
|
||||||
"description":"",
|
|
||||||
"x-swagger-router-controller": "Store",
|
|
||||||
"tags": ["Store"],
|
|
||||||
"operationId": "placeOrder",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"in" : "body",
|
|
||||||
"name" : "body",
|
|
||||||
"description" : "order placed for purchasing the pet",
|
|
||||||
"required" : false,
|
|
||||||
"schema" : {
|
|
||||||
"$ref" : "#/definitions/Order"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description" : "successful operation",
|
|
||||||
"schema" : {
|
|
||||||
"$ref" : "#/definitions/Order"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
,
|
|
||||||
"400": {
|
|
||||||
"description" : "Invalid Order"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} ,
|
|
||||||
|
|
||||||
"/store/inventory": {
|
|
||||||
|
|
||||||
"get": {
|
|
||||||
"summary": "Returns pet inventories by status",
|
|
||||||
"description":"Returns a map of status codes to quantities",
|
|
||||||
"x-swagger-router-controller": "Store",
|
|
||||||
"tags": ["Store"],
|
|
||||||
"operationId": "getInventory",
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description" : "successful operation",
|
|
||||||
"schema" : {
|
|
||||||
"type" : "object",
|
|
||||||
"additionalProperties" : {
|
|
||||||
"type" : "integer",
|
|
||||||
"format" : "int32"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}, "definitions": {
|
|
||||||
"User": {
|
|
||||||
"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"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"xml" : {
|
|
||||||
"name" : "User"
|
|
||||||
}
|
|
||||||
},"Category": {
|
|
||||||
"properties" : {
|
|
||||||
"id" : {
|
|
||||||
"type" : "integer",
|
|
||||||
"format" : "int64"
|
|
||||||
},
|
|
||||||
"name" : {
|
|
||||||
"type" : "string"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"xml" : {
|
|
||||||
"name" : "Category"
|
|
||||||
}
|
|
||||||
},"Pet": {
|
|
||||||
"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" ]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"xml" : {
|
|
||||||
"name" : "Pet"
|
|
||||||
}
|
|
||||||
},"Tag": {
|
|
||||||
"properties" : {
|
|
||||||
"id" : {
|
|
||||||
"type" : "integer",
|
|
||||||
"format" : "int64"
|
|
||||||
},
|
|
||||||
"name" : {
|
|
||||||
"type" : "string"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"xml" : {
|
|
||||||
"name" : "Tag"
|
|
||||||
}
|
|
||||||
},"Order": {
|
|
||||||
"properties" : {
|
|
||||||
"id" : {
|
|
||||||
"type" : "integer",
|
|
||||||
"format" : "int64"
|
|
||||||
},
|
|
||||||
"petId" : {
|
|
||||||
"type" : "integer",
|
|
||||||
"format" : "int64"
|
|
||||||
},
|
|
||||||
"quantity" : {
|
|
||||||
"type" : "integer",
|
|
||||||
"format" : "int32"
|
|
||||||
},
|
|
||||||
"shipDate" : {
|
|
||||||
"type" : "string",
|
|
||||||
"format" : "date-time"
|
|
||||||
},
|
|
||||||
"status" : {
|
|
||||||
"type" : "string",
|
|
||||||
"description" : "Order Status",
|
|
||||||
"enum" : [ "placed", "approved", "delivered" ]
|
|
||||||
},
|
|
||||||
"complete" : {
|
|
||||||
"type" : "boolean"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"xml" : {
|
|
||||||
"name" : "Order"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
667
samples/server/petstore/nodejs/api/swagger.yaml
Normal file
667
samples/server/petstore/nodejs/api/swagger.yaml
Normal file
@ -0,0 +1,667 @@
|
|||||||
|
---
|
||||||
|
swagger: "2.0"
|
||||||
|
info:
|
||||||
|
description: "This is a sample server Petstore server. You can find out more about\
|
||||||
|
\ Swagger at <a href=\"http://swagger.io\">http://swagger.io</a> or on irc.freenode.net,\
|
||||||
|
\ #swagger. For this sample, you can use the api key \"special-key\" to test\
|
||||||
|
\ the authorization filters"
|
||||||
|
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"
|
||||||
|
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/json"
|
||||||
|
- "application/xml"
|
||||||
|
parameters:
|
||||||
|
- in: "body"
|
||||||
|
name: "body"
|
||||||
|
description: "Pet object that needs to be added to the store"
|
||||||
|
required: false
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/Pet"
|
||||||
|
responses:
|
||||||
|
405:
|
||||||
|
description: "Invalid input"
|
||||||
|
security:
|
||||||
|
- petstore_auth:
|
||||||
|
- "write:pets"
|
||||||
|
- "read:pets"
|
||||||
|
put:
|
||||||
|
tags:
|
||||||
|
- "pet"
|
||||||
|
summary: "Update an existing pet"
|
||||||
|
description: ""
|
||||||
|
operationId: "updatePet"
|
||||||
|
consumes:
|
||||||
|
- "application/json"
|
||||||
|
- "application/xml"
|
||||||
|
produces:
|
||||||
|
- "application/json"
|
||||||
|
- "application/xml"
|
||||||
|
parameters:
|
||||||
|
- in: "body"
|
||||||
|
name: "body"
|
||||||
|
description: "Pet object that needs to be added to the store"
|
||||||
|
required: false
|
||||||
|
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"
|
||||||
|
/pet/findByStatus:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- "pet"
|
||||||
|
summary: "Finds Pets by status"
|
||||||
|
description: "Multiple status values can be provided with comma seperated strings"
|
||||||
|
operationId: "findPetsByStatus"
|
||||||
|
produces:
|
||||||
|
- "application/json"
|
||||||
|
- "application/xml"
|
||||||
|
parameters:
|
||||||
|
- name: "status"
|
||||||
|
in: "query"
|
||||||
|
description: "Status values that need to be considered for filter"
|
||||||
|
required: false
|
||||||
|
type: "array"
|
||||||
|
items:
|
||||||
|
type: "string"
|
||||||
|
collectionFormat: "multi"
|
||||||
|
default: "available"
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: "successful operation"
|
||||||
|
schema:
|
||||||
|
type: "array"
|
||||||
|
items:
|
||||||
|
$ref: "#/definitions/Pet"
|
||||||
|
400:
|
||||||
|
description: "Invalid status value"
|
||||||
|
security:
|
||||||
|
- petstore_auth:
|
||||||
|
- "write:pets"
|
||||||
|
- "read:pets"
|
||||||
|
/pet/findByTags:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- "pet"
|
||||||
|
summary: "Finds Pets by tags"
|
||||||
|
description: "Muliple tags can be provided with comma seperated strings. Use\
|
||||||
|
\ tag1, tag2, tag3 for testing."
|
||||||
|
operationId: "findPetsByTags"
|
||||||
|
produces:
|
||||||
|
- "application/json"
|
||||||
|
- "application/xml"
|
||||||
|
parameters:
|
||||||
|
- name: "tags"
|
||||||
|
in: "query"
|
||||||
|
description: "Tags to filter by"
|
||||||
|
required: false
|
||||||
|
type: "array"
|
||||||
|
items:
|
||||||
|
type: "string"
|
||||||
|
collectionFormat: "multi"
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: "successful operation"
|
||||||
|
schema:
|
||||||
|
type: "array"
|
||||||
|
items:
|
||||||
|
$ref: "#/definitions/Pet"
|
||||||
|
400:
|
||||||
|
description: "Invalid tag value"
|
||||||
|
security:
|
||||||
|
- petstore_auth:
|
||||||
|
- "write:pets"
|
||||||
|
- "read:pets"
|
||||||
|
/pet/{petId}:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- "pet"
|
||||||
|
summary: "Find pet by ID"
|
||||||
|
description: "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate\
|
||||||
|
\ API error conditions"
|
||||||
|
operationId: "getPetById"
|
||||||
|
produces:
|
||||||
|
- "application/json"
|
||||||
|
- "application/xml"
|
||||||
|
parameters:
|
||||||
|
- name: "petId"
|
||||||
|
in: "path"
|
||||||
|
description: "ID of pet that needs to be fetched"
|
||||||
|
required: true
|
||||||
|
type: "integer"
|
||||||
|
format: "int64"
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: "successful operation"
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/Pet"
|
||||||
|
400:
|
||||||
|
description: "Invalid ID supplied"
|
||||||
|
404:
|
||||||
|
description: "Pet not found"
|
||||||
|
security:
|
||||||
|
- api_key: []
|
||||||
|
- petstore_auth:
|
||||||
|
- "write:pets"
|
||||||
|
- "read:pets"
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- "pet"
|
||||||
|
summary: "Updates a pet in the store with form data"
|
||||||
|
description: ""
|
||||||
|
operationId: "updatePetWithForm"
|
||||||
|
consumes:
|
||||||
|
- "application/x-www-form-urlencoded"
|
||||||
|
produces:
|
||||||
|
- "application/json"
|
||||||
|
- "application/xml"
|
||||||
|
parameters:
|
||||||
|
- name: "petId"
|
||||||
|
in: "path"
|
||||||
|
description: "ID of pet that needs to be updated"
|
||||||
|
required: true
|
||||||
|
type: "string"
|
||||||
|
- 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"
|
||||||
|
delete:
|
||||||
|
tags:
|
||||||
|
- "pet"
|
||||||
|
summary: "Deletes a pet"
|
||||||
|
description: ""
|
||||||
|
operationId: "deletePet"
|
||||||
|
produces:
|
||||||
|
- "application/json"
|
||||||
|
- "application/xml"
|
||||||
|
parameters:
|
||||||
|
- name: "api_key"
|
||||||
|
in: "header"
|
||||||
|
description: ""
|
||||||
|
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"
|
||||||
|
/pet/{petId}/uploadImage:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- "pet"
|
||||||
|
summary: "uploads an image"
|
||||||
|
description: ""
|
||||||
|
operationId: "uploadFile"
|
||||||
|
consumes:
|
||||||
|
- "multipart/form-data"
|
||||||
|
produces:
|
||||||
|
- "application/json"
|
||||||
|
- "application/xml"
|
||||||
|
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:
|
||||||
|
default:
|
||||||
|
description: "successful operation"
|
||||||
|
security:
|
||||||
|
- petstore_auth:
|
||||||
|
- "write:pets"
|
||||||
|
- "read:pets"
|
||||||
|
/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"
|
||||||
|
- "application/xml"
|
||||||
|
parameters: []
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: "successful operation"
|
||||||
|
schema:
|
||||||
|
type: "object"
|
||||||
|
additionalProperties:
|
||||||
|
type: "integer"
|
||||||
|
format: "int32"
|
||||||
|
security:
|
||||||
|
- api_key: []
|
||||||
|
/store/order:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- "store"
|
||||||
|
summary: "Place an order for a pet"
|
||||||
|
description: ""
|
||||||
|
operationId: "placeOrder"
|
||||||
|
produces:
|
||||||
|
- "application/json"
|
||||||
|
- "application/xml"
|
||||||
|
parameters:
|
||||||
|
- in: "body"
|
||||||
|
name: "body"
|
||||||
|
description: "order placed for purchasing the pet"
|
||||||
|
required: false
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/Order"
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: "successful operation"
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/Order"
|
||||||
|
400:
|
||||||
|
description: "Invalid Order"
|
||||||
|
/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/json"
|
||||||
|
- "application/xml"
|
||||||
|
parameters:
|
||||||
|
- name: "orderId"
|
||||||
|
in: "path"
|
||||||
|
description: "ID of pet that needs to be fetched"
|
||||||
|
required: true
|
||||||
|
type: "string"
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: "successful operation"
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/Order"
|
||||||
|
400:
|
||||||
|
description: "Invalid ID supplied"
|
||||||
|
404:
|
||||||
|
description: "Order not found"
|
||||||
|
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/json"
|
||||||
|
- "application/xml"
|
||||||
|
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"
|
||||||
|
/user:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- "user"
|
||||||
|
summary: "Create user"
|
||||||
|
description: "This can only be done by the logged in user."
|
||||||
|
operationId: "createUser"
|
||||||
|
produces:
|
||||||
|
- "application/json"
|
||||||
|
- "application/xml"
|
||||||
|
parameters:
|
||||||
|
- in: "body"
|
||||||
|
name: "body"
|
||||||
|
description: "Created user object"
|
||||||
|
required: false
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/User"
|
||||||
|
responses:
|
||||||
|
default:
|
||||||
|
description: "successful operation"
|
||||||
|
/user/createWithArray:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- "user"
|
||||||
|
summary: "Creates list of users with given input array"
|
||||||
|
description: ""
|
||||||
|
operationId: "createUsersWithArrayInput"
|
||||||
|
produces:
|
||||||
|
- "application/json"
|
||||||
|
- "application/xml"
|
||||||
|
parameters:
|
||||||
|
- in: "body"
|
||||||
|
name: "body"
|
||||||
|
description: "List of user object"
|
||||||
|
required: false
|
||||||
|
schema:
|
||||||
|
type: "array"
|
||||||
|
items:
|
||||||
|
$ref: "#/definitions/User"
|
||||||
|
responses:
|
||||||
|
default:
|
||||||
|
description: "successful operation"
|
||||||
|
/user/createWithList:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- "user"
|
||||||
|
summary: "Creates list of users with given input array"
|
||||||
|
description: ""
|
||||||
|
operationId: "createUsersWithListInput"
|
||||||
|
produces:
|
||||||
|
- "application/json"
|
||||||
|
- "application/xml"
|
||||||
|
parameters:
|
||||||
|
- in: "body"
|
||||||
|
name: "body"
|
||||||
|
description: "List of user object"
|
||||||
|
required: false
|
||||||
|
schema:
|
||||||
|
type: "array"
|
||||||
|
items:
|
||||||
|
$ref: "#/definitions/User"
|
||||||
|
responses:
|
||||||
|
default:
|
||||||
|
description: "successful operation"
|
||||||
|
/user/login:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- "user"
|
||||||
|
summary: "Logs user into the system"
|
||||||
|
description: ""
|
||||||
|
operationId: "loginUser"
|
||||||
|
produces:
|
||||||
|
- "application/json"
|
||||||
|
- "application/xml"
|
||||||
|
parameters:
|
||||||
|
- name: "username"
|
||||||
|
in: "query"
|
||||||
|
description: "The user name for login"
|
||||||
|
required: false
|
||||||
|
type: "string"
|
||||||
|
- name: "password"
|
||||||
|
in: "query"
|
||||||
|
description: "The password for login in clear text"
|
||||||
|
required: false
|
||||||
|
type: "string"
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: "successful operation"
|
||||||
|
schema:
|
||||||
|
type: "string"
|
||||||
|
400:
|
||||||
|
description: "Invalid username/password supplied"
|
||||||
|
/user/logout:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- "user"
|
||||||
|
summary: "Logs out current logged in user session"
|
||||||
|
description: ""
|
||||||
|
operationId: "logoutUser"
|
||||||
|
produces:
|
||||||
|
- "application/json"
|
||||||
|
- "application/xml"
|
||||||
|
parameters: []
|
||||||
|
responses:
|
||||||
|
default:
|
||||||
|
description: "successful operation"
|
||||||
|
/user/{username}:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- "user"
|
||||||
|
summary: "Get user by user name"
|
||||||
|
description: ""
|
||||||
|
operationId: "getUserByName"
|
||||||
|
produces:
|
||||||
|
- "application/json"
|
||||||
|
- "application/xml"
|
||||||
|
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"
|
||||||
|
examples:
|
||||||
|
application/json:
|
||||||
|
id: 1
|
||||||
|
username: "johnp"
|
||||||
|
firstName: "John"
|
||||||
|
lastName: "Public"
|
||||||
|
email: "johnp@swagger.io"
|
||||||
|
password: "-secret-"
|
||||||
|
phone: "0123456789"
|
||||||
|
userStatus: 0
|
||||||
|
400:
|
||||||
|
description: "Invalid username supplied"
|
||||||
|
404:
|
||||||
|
description: "User not found"
|
||||||
|
put:
|
||||||
|
tags:
|
||||||
|
- "user"
|
||||||
|
summary: "Updated user"
|
||||||
|
description: "This can only be done by the logged in user."
|
||||||
|
operationId: "updateUser"
|
||||||
|
produces:
|
||||||
|
- "application/json"
|
||||||
|
- "application/xml"
|
||||||
|
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: false
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/User"
|
||||||
|
responses:
|
||||||
|
400:
|
||||||
|
description: "Invalid user supplied"
|
||||||
|
404:
|
||||||
|
description: "User not found"
|
||||||
|
delete:
|
||||||
|
tags:
|
||||||
|
- "user"
|
||||||
|
summary: "Delete user"
|
||||||
|
description: "This can only be done by the logged in user."
|
||||||
|
operationId: "deleteUser"
|
||||||
|
produces:
|
||||||
|
- "application/json"
|
||||||
|
- "application/xml"
|
||||||
|
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"
|
||||||
|
securityDefinitions:
|
||||||
|
api_key:
|
||||||
|
type: "apiKey"
|
||||||
|
name: "api_key"
|
||||||
|
in: "header"
|
||||||
|
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"
|
||||||
|
definitions:
|
||||||
|
User:
|
||||||
|
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"
|
||||||
|
xml:
|
||||||
|
name: "User"
|
||||||
|
Category:
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: "integer"
|
||||||
|
format: "int64"
|
||||||
|
name:
|
||||||
|
type: "string"
|
||||||
|
xml:
|
||||||
|
name: "Category"
|
||||||
|
Pet:
|
||||||
|
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"
|
||||||
|
xml:
|
||||||
|
name: "Pet"
|
||||||
|
Tag:
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: "integer"
|
||||||
|
format: "int64"
|
||||||
|
name:
|
||||||
|
type: "string"
|
||||||
|
xml:
|
||||||
|
name: "Tag"
|
||||||
|
Order:
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: "integer"
|
||||||
|
format: "int64"
|
||||||
|
petId:
|
||||||
|
type: "integer"
|
||||||
|
format: "int64"
|
||||||
|
quantity:
|
||||||
|
type: "integer"
|
||||||
|
format: "int32"
|
||||||
|
shipDate:
|
||||||
|
type: "string"
|
||||||
|
format: "date-time"
|
||||||
|
status:
|
||||||
|
type: "string"
|
||||||
|
description: "Order Status"
|
||||||
|
enum:
|
||||||
|
- "placed"
|
||||||
|
- "approved"
|
||||||
|
- "delivered"
|
||||||
|
complete:
|
||||||
|
type: "boolean"
|
||||||
|
xml:
|
||||||
|
name: "Order"
|
@ -7,118 +7,33 @@ var Pet = require('./PetService');
|
|||||||
|
|
||||||
|
|
||||||
module.exports.updatePet = function updatePet (req, res, next) {
|
module.exports.updatePet = function updatePet (req, res, next) {
|
||||||
var body = req.swagger.params['body'].value;
|
Pet.updatePet(req.swagger.params, res, next);
|
||||||
|
|
||||||
|
|
||||||
var result = Pet.updatePet(body);
|
|
||||||
|
|
||||||
if(typeof result !== 'undefined') {
|
|
||||||
res.setHeader('Content-Type', 'application/json');
|
|
||||||
res.end(JSON.stringify(result || {}, null, 2));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
res.end();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.addPet = function addPet (req, res, next) {
|
module.exports.addPet = function addPet (req, res, next) {
|
||||||
var body = req.swagger.params['body'].value;
|
Pet.addPet(req.swagger.params, res, next);
|
||||||
|
|
||||||
|
|
||||||
var result = Pet.addPet(body);
|
|
||||||
|
|
||||||
if(typeof result !== 'undefined') {
|
|
||||||
res.setHeader('Content-Type', 'application/json');
|
|
||||||
res.end(JSON.stringify(result || {}, null, 2));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
res.end();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.findPetsByStatus = function findPetsByStatus (req, res, next) {
|
module.exports.findPetsByStatus = function findPetsByStatus (req, res, next) {
|
||||||
var status = req.swagger.params['status'].value;
|
Pet.findPetsByStatus(req.swagger.params, res, next);
|
||||||
|
|
||||||
|
|
||||||
var result = Pet.findPetsByStatus(status);
|
|
||||||
|
|
||||||
if(typeof result !== 'undefined') {
|
|
||||||
res.setHeader('Content-Type', 'application/json');
|
|
||||||
res.end(JSON.stringify(result || {}, null, 2));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
res.end();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.findPetsByTags = function findPetsByTags (req, res, next) {
|
module.exports.findPetsByTags = function findPetsByTags (req, res, next) {
|
||||||
var tags = req.swagger.params['tags'].value;
|
Pet.findPetsByTags(req.swagger.params, res, next);
|
||||||
|
|
||||||
|
|
||||||
var result = Pet.findPetsByTags(tags);
|
|
||||||
|
|
||||||
if(typeof result !== 'undefined') {
|
|
||||||
res.setHeader('Content-Type', 'application/json');
|
|
||||||
res.end(JSON.stringify(result || {}, null, 2));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
res.end();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.getPetById = function getPetById (req, res, next) {
|
module.exports.getPetById = function getPetById (req, res, next) {
|
||||||
var petId = req.swagger.params['petId'].value;
|
Pet.getPetById(req.swagger.params, res, next);
|
||||||
|
|
||||||
|
|
||||||
var result = Pet.getPetById(petId);
|
|
||||||
|
|
||||||
if(typeof result !== 'undefined') {
|
|
||||||
res.setHeader('Content-Type', 'application/json');
|
|
||||||
res.end(JSON.stringify(result || {}, null, 2));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
res.end();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.updatePetWithForm = function updatePetWithForm (req, res, next) {
|
module.exports.updatePetWithForm = function updatePetWithForm (req, res, next) {
|
||||||
var petId = req.swagger.params['petId'].value;
|
Pet.updatePetWithForm(req.swagger.params, res, next);
|
||||||
var name = req.swagger.params['name'].value;
|
|
||||||
var status = req.swagger.params['status'].value;
|
|
||||||
|
|
||||||
|
|
||||||
var result = Pet.updatePetWithForm(petId, name, status);
|
|
||||||
|
|
||||||
if(typeof result !== 'undefined') {
|
|
||||||
res.setHeader('Content-Type', 'application/json');
|
|
||||||
res.end(JSON.stringify(result || {}, null, 2));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
res.end();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.deletePet = function deletePet (req, res, next) {
|
module.exports.deletePet = function deletePet (req, res, next) {
|
||||||
var petId = req.swagger.params['petId'].value;
|
Pet.deletePet(req.swagger.params, res, next);
|
||||||
var apiKey = req.swagger.params['api_key'].value;
|
|
||||||
|
|
||||||
|
|
||||||
var result = Pet.deletePet(petId, apiKey);
|
|
||||||
|
|
||||||
if(typeof result !== 'undefined') {
|
|
||||||
res.setHeader('Content-Type', 'application/json');
|
|
||||||
res.end(JSON.stringify(result || {}, null, 2));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
res.end();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.uploadFile = function uploadFile (req, res, next) {
|
module.exports.uploadFile = function uploadFile (req, res, next) {
|
||||||
var petId = req.swagger.params['petId'].value;
|
Pet.uploadFile(req.swagger.params, res, next);
|
||||||
var additionalMetadata = req.swagger.params['additionalMetadata'].value;
|
|
||||||
var file = req.swagger.params['file'].value;
|
|
||||||
|
|
||||||
|
|
||||||
var result = Pet.uploadFile(petId, additionalMetadata, file);
|
|
||||||
|
|
||||||
if(typeof result !== 'undefined') {
|
|
||||||
res.setHeader('Content-Type', 'application/json');
|
|
||||||
res.end(JSON.stringify(result || {}, null, 2));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
res.end();
|
|
||||||
};
|
};
|
||||||
|
@ -1,22 +1,36 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
exports.updatePet = function(body) {
|
exports.updatePet = function(args, res, next) {
|
||||||
|
/**
|
||||||
|
* parameters expected in the args:
|
||||||
|
* body (Pet)
|
||||||
|
**/
|
||||||
|
|
||||||
var examples = {};
|
var examples = {};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
res.end();
|
||||||
}
|
}
|
||||||
exports.addPet = function(body) {
|
exports.addPet = function(args, res, next) {
|
||||||
|
/**
|
||||||
|
* parameters expected in the args:
|
||||||
|
* body (Pet)
|
||||||
|
**/
|
||||||
|
|
||||||
var examples = {};
|
var examples = {};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
res.end();
|
||||||
}
|
}
|
||||||
exports.findPetsByStatus = function(status) {
|
exports.findPetsByStatus = function(args, res, next) {
|
||||||
|
/**
|
||||||
|
* parameters expected in the args:
|
||||||
|
* status (List)
|
||||||
|
**/
|
||||||
|
|
||||||
var examples = {};
|
var examples = {};
|
||||||
|
|
||||||
examples['application/json'] = [ {
|
examples['application/json'] = [ {
|
||||||
"tags" : [ {
|
"tags" : [ {
|
||||||
@ -35,13 +49,23 @@ exports.findPetsByStatus = function(status) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(Object.keys(examples).length > 0)
|
if(Object.keys(examples).length > 0) {
|
||||||
return examples[Object.keys(examples)[0]];
|
res.setHeader('Content-Type', 'application/json');
|
||||||
|
res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
res.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
exports.findPetsByTags = function(tags) {
|
exports.findPetsByTags = function(args, res, next) {
|
||||||
|
/**
|
||||||
|
* parameters expected in the args:
|
||||||
|
* tags (List)
|
||||||
|
**/
|
||||||
|
|
||||||
var examples = {};
|
var examples = {};
|
||||||
|
|
||||||
examples['application/json'] = [ {
|
examples['application/json'] = [ {
|
||||||
"tags" : [ {
|
"tags" : [ {
|
||||||
@ -60,13 +84,23 @@ exports.findPetsByTags = function(tags) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(Object.keys(examples).length > 0)
|
if(Object.keys(examples).length > 0) {
|
||||||
return examples[Object.keys(examples)[0]];
|
res.setHeader('Content-Type', 'application/json');
|
||||||
|
res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
res.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
exports.getPetById = function(petId) {
|
exports.getPetById = function(args, res, next) {
|
||||||
|
/**
|
||||||
|
* parameters expected in the args:
|
||||||
|
* petId (Long)
|
||||||
|
**/
|
||||||
|
|
||||||
var examples = {};
|
var examples = {};
|
||||||
|
|
||||||
examples['application/json'] = {
|
examples['application/json'] = {
|
||||||
"tags" : [ {
|
"tags" : [ {
|
||||||
@ -85,28 +119,54 @@ exports.getPetById = function(petId) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(Object.keys(examples).length > 0)
|
if(Object.keys(examples).length > 0) {
|
||||||
return examples[Object.keys(examples)[0]];
|
res.setHeader('Content-Type', 'application/json');
|
||||||
|
res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
res.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
exports.updatePetWithForm = function(petId, name, status) {
|
exports.updatePetWithForm = function(args, res, next) {
|
||||||
|
/**
|
||||||
|
* parameters expected in the args:
|
||||||
|
* petId (String)
|
||||||
|
* name (String)
|
||||||
|
* status (String)
|
||||||
|
**/
|
||||||
|
|
||||||
var examples = {};
|
var examples = {};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
res.end();
|
||||||
}
|
}
|
||||||
exports.deletePet = function(petId, apiKey) {
|
exports.deletePet = function(args, res, next) {
|
||||||
|
/**
|
||||||
|
* parameters expected in the args:
|
||||||
|
* petId (Long)
|
||||||
|
* apiKey (String)
|
||||||
|
**/
|
||||||
|
|
||||||
var examples = {};
|
var examples = {};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
res.end();
|
||||||
}
|
}
|
||||||
exports.uploadFile = function(petId, additionalMetadata, file) {
|
exports.uploadFile = function(args, res, next) {
|
||||||
|
/**
|
||||||
|
* parameters expected in the args:
|
||||||
|
* petId (Long)
|
||||||
|
* additionalMetadata (String)
|
||||||
|
* file (file)
|
||||||
|
**/
|
||||||
|
|
||||||
var examples = {};
|
var examples = {};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
res.end();
|
||||||
}
|
}
|
||||||
|
@ -7,56 +7,17 @@ var Store = require('./StoreService');
|
|||||||
|
|
||||||
|
|
||||||
module.exports.getInventory = function getInventory (req, res, next) {
|
module.exports.getInventory = function getInventory (req, res, next) {
|
||||||
|
Store.getInventory(req.swagger.params, res, next);
|
||||||
|
|
||||||
var result = Store.getInventory();
|
|
||||||
|
|
||||||
if(typeof result !== 'undefined') {
|
|
||||||
res.setHeader('Content-Type', 'application/json');
|
|
||||||
res.end(JSON.stringify(result || {}, null, 2));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
res.end();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.placeOrder = function placeOrder (req, res, next) {
|
module.exports.placeOrder = function placeOrder (req, res, next) {
|
||||||
var body = req.swagger.params['body'].value;
|
Store.placeOrder(req.swagger.params, res, next);
|
||||||
|
|
||||||
|
|
||||||
var result = Store.placeOrder(body);
|
|
||||||
|
|
||||||
if(typeof result !== 'undefined') {
|
|
||||||
res.setHeader('Content-Type', 'application/json');
|
|
||||||
res.end(JSON.stringify(result || {}, null, 2));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
res.end();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.getOrderById = function getOrderById (req, res, next) {
|
module.exports.getOrderById = function getOrderById (req, res, next) {
|
||||||
var orderId = req.swagger.params['orderId'].value;
|
Store.getOrderById(req.swagger.params, res, next);
|
||||||
|
|
||||||
|
|
||||||
var result = Store.getOrderById(orderId);
|
|
||||||
|
|
||||||
if(typeof result !== 'undefined') {
|
|
||||||
res.setHeader('Content-Type', 'application/json');
|
|
||||||
res.end(JSON.stringify(result || {}, null, 2));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
res.end();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.deleteOrder = function deleteOrder (req, res, next) {
|
module.exports.deleteOrder = function deleteOrder (req, res, next) {
|
||||||
var orderId = req.swagger.params['orderId'].value;
|
Store.deleteOrder(req.swagger.params, res, next);
|
||||||
|
|
||||||
|
|
||||||
var result = Store.deleteOrder(orderId);
|
|
||||||
|
|
||||||
if(typeof result !== 'undefined') {
|
|
||||||
res.setHeader('Content-Type', 'application/json');
|
|
||||||
res.end(JSON.stringify(result || {}, null, 2));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
res.end();
|
|
||||||
};
|
};
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
exports.getInventory = function() {
|
exports.getInventory = function(args, res, next) {
|
||||||
|
/**
|
||||||
|
* parameters expected in the args:
|
||||||
|
**/
|
||||||
|
|
||||||
var examples = {};
|
var examples = {};
|
||||||
|
|
||||||
examples['application/json'] = {
|
examples['application/json'] = {
|
||||||
"key" : 123
|
"key" : 123
|
||||||
@ -10,13 +13,23 @@ exports.getInventory = function() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(Object.keys(examples).length > 0)
|
if(Object.keys(examples).length > 0) {
|
||||||
return examples[Object.keys(examples)[0]];
|
res.setHeader('Content-Type', 'application/json');
|
||||||
|
res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
res.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
exports.placeOrder = function(body) {
|
exports.placeOrder = function(args, res, next) {
|
||||||
|
/**
|
||||||
|
* parameters expected in the args:
|
||||||
|
* body (Order)
|
||||||
|
**/
|
||||||
|
|
||||||
var examples = {};
|
var examples = {};
|
||||||
|
|
||||||
examples['application/json'] = {
|
examples['application/json'] = {
|
||||||
"id" : 123456789,
|
"id" : 123456789,
|
||||||
@ -24,18 +37,28 @@ exports.placeOrder = function(body) {
|
|||||||
"complete" : true,
|
"complete" : true,
|
||||||
"status" : "aeiou",
|
"status" : "aeiou",
|
||||||
"quantity" : 123,
|
"quantity" : 123,
|
||||||
"shipDate" : "2015-10-20T06:12:23.907+0000"
|
"shipDate" : "2015-11-18T02:43:54.540+0000"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(Object.keys(examples).length > 0)
|
if(Object.keys(examples).length > 0) {
|
||||||
return examples[Object.keys(examples)[0]];
|
res.setHeader('Content-Type', 'application/json');
|
||||||
|
res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
res.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
exports.getOrderById = function(orderId) {
|
exports.getOrderById = function(args, res, next) {
|
||||||
|
/**
|
||||||
|
* parameters expected in the args:
|
||||||
|
* orderId (String)
|
||||||
|
**/
|
||||||
|
|
||||||
var examples = {};
|
var examples = {};
|
||||||
|
|
||||||
examples['application/json'] = {
|
examples['application/json'] = {
|
||||||
"id" : 123456789,
|
"id" : 123456789,
|
||||||
@ -43,19 +66,30 @@ exports.getOrderById = function(orderId) {
|
|||||||
"complete" : true,
|
"complete" : true,
|
||||||
"status" : "aeiou",
|
"status" : "aeiou",
|
||||||
"quantity" : 123,
|
"quantity" : 123,
|
||||||
"shipDate" : "2015-10-20T06:12:23.911+0000"
|
"shipDate" : "2015-11-18T02:43:54.544+0000"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(Object.keys(examples).length > 0)
|
if(Object.keys(examples).length > 0) {
|
||||||
return examples[Object.keys(examples)[0]];
|
res.setHeader('Content-Type', 'application/json');
|
||||||
|
res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
res.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
exports.deleteOrder = function(orderId) {
|
exports.deleteOrder = function(args, res, next) {
|
||||||
|
/**
|
||||||
|
* parameters expected in the args:
|
||||||
|
* orderId (String)
|
||||||
|
**/
|
||||||
|
|
||||||
var examples = {};
|
var examples = {};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
res.end();
|
||||||
}
|
}
|
||||||
|
@ -7,114 +7,33 @@ var User = require('./UserService');
|
|||||||
|
|
||||||
|
|
||||||
module.exports.createUser = function createUser (req, res, next) {
|
module.exports.createUser = function createUser (req, res, next) {
|
||||||
var body = req.swagger.params['body'].value;
|
User.createUser(req.swagger.params, res, next);
|
||||||
|
|
||||||
|
|
||||||
var result = User.createUser(body);
|
|
||||||
|
|
||||||
if(typeof result !== 'undefined') {
|
|
||||||
res.setHeader('Content-Type', 'application/json');
|
|
||||||
res.end(JSON.stringify(result || {}, null, 2));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
res.end();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.createUsersWithArrayInput = function createUsersWithArrayInput (req, res, next) {
|
module.exports.createUsersWithArrayInput = function createUsersWithArrayInput (req, res, next) {
|
||||||
var body = req.swagger.params['body'].value;
|
User.createUsersWithArrayInput(req.swagger.params, res, next);
|
||||||
|
|
||||||
|
|
||||||
var result = User.createUsersWithArrayInput(body);
|
|
||||||
|
|
||||||
if(typeof result !== 'undefined') {
|
|
||||||
res.setHeader('Content-Type', 'application/json');
|
|
||||||
res.end(JSON.stringify(result || {}, null, 2));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
res.end();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.createUsersWithListInput = function createUsersWithListInput (req, res, next) {
|
module.exports.createUsersWithListInput = function createUsersWithListInput (req, res, next) {
|
||||||
var body = req.swagger.params['body'].value;
|
User.createUsersWithListInput(req.swagger.params, res, next);
|
||||||
|
|
||||||
|
|
||||||
var result = User.createUsersWithListInput(body);
|
|
||||||
|
|
||||||
if(typeof result !== 'undefined') {
|
|
||||||
res.setHeader('Content-Type', 'application/json');
|
|
||||||
res.end(JSON.stringify(result || {}, null, 2));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
res.end();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.loginUser = function loginUser (req, res, next) {
|
module.exports.loginUser = function loginUser (req, res, next) {
|
||||||
var username = req.swagger.params['username'].value;
|
User.loginUser(req.swagger.params, res, next);
|
||||||
var password = req.swagger.params['password'].value;
|
|
||||||
|
|
||||||
|
|
||||||
var result = User.loginUser(username, password);
|
|
||||||
|
|
||||||
if(typeof result !== 'undefined') {
|
|
||||||
res.setHeader('Content-Type', 'application/json');
|
|
||||||
res.end(JSON.stringify(result || {}, null, 2));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
res.end();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.logoutUser = function logoutUser (req, res, next) {
|
module.exports.logoutUser = function logoutUser (req, res, next) {
|
||||||
|
User.logoutUser(req.swagger.params, res, next);
|
||||||
|
|
||||||
var result = User.logoutUser();
|
|
||||||
|
|
||||||
if(typeof result !== 'undefined') {
|
|
||||||
res.setHeader('Content-Type', 'application/json');
|
|
||||||
res.end(JSON.stringify(result || {}, null, 2));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
res.end();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.getUserByName = function getUserByName (req, res, next) {
|
module.exports.getUserByName = function getUserByName (req, res, next) {
|
||||||
var username = req.swagger.params['username'].value;
|
User.getUserByName(req.swagger.params, res, next);
|
||||||
|
|
||||||
|
|
||||||
var result = User.getUserByName(username);
|
|
||||||
|
|
||||||
if(typeof result !== 'undefined') {
|
|
||||||
res.setHeader('Content-Type', 'application/json');
|
|
||||||
res.end(JSON.stringify(result || {}, null, 2));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
res.end();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.updateUser = function updateUser (req, res, next) {
|
module.exports.updateUser = function updateUser (req, res, next) {
|
||||||
var username = req.swagger.params['username'].value;
|
User.updateUser(req.swagger.params, res, next);
|
||||||
var body = req.swagger.params['body'].value;
|
|
||||||
|
|
||||||
|
|
||||||
var result = User.updateUser(username, body);
|
|
||||||
|
|
||||||
if(typeof result !== 'undefined') {
|
|
||||||
res.setHeader('Content-Type', 'application/json');
|
|
||||||
res.end(JSON.stringify(result || {}, null, 2));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
res.end();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.deleteUser = function deleteUser (req, res, next) {
|
module.exports.deleteUser = function deleteUser (req, res, next) {
|
||||||
var username = req.swagger.params['username'].value;
|
User.deleteUser(req.swagger.params, res, next);
|
||||||
|
|
||||||
|
|
||||||
var result = User.deleteUser(username);
|
|
||||||
|
|
||||||
if(typeof result !== 'undefined') {
|
|
||||||
res.setHeader('Content-Type', 'application/json');
|
|
||||||
res.end(JSON.stringify(result || {}, null, 2));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
res.end();
|
|
||||||
};
|
};
|
||||||
|
@ -1,48 +1,82 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
exports.createUser = function(body) {
|
exports.createUser = function(args, res, next) {
|
||||||
|
/**
|
||||||
|
* parameters expected in the args:
|
||||||
|
* body (User)
|
||||||
|
**/
|
||||||
|
|
||||||
var examples = {};
|
var examples = {};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
res.end();
|
||||||
}
|
}
|
||||||
exports.createUsersWithArrayInput = function(body) {
|
exports.createUsersWithArrayInput = function(args, res, next) {
|
||||||
|
/**
|
||||||
|
* parameters expected in the args:
|
||||||
|
* body (List)
|
||||||
|
**/
|
||||||
|
|
||||||
var examples = {};
|
var examples = {};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
res.end();
|
||||||
}
|
}
|
||||||
exports.createUsersWithListInput = function(body) {
|
exports.createUsersWithListInput = function(args, res, next) {
|
||||||
|
/**
|
||||||
|
* parameters expected in the args:
|
||||||
|
* body (List)
|
||||||
|
**/
|
||||||
|
|
||||||
var examples = {};
|
var examples = {};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
res.end();
|
||||||
}
|
}
|
||||||
exports.loginUser = function(username, password) {
|
exports.loginUser = function(args, res, next) {
|
||||||
|
/**
|
||||||
|
* parameters expected in the args:
|
||||||
|
* username (String)
|
||||||
|
* password (String)
|
||||||
|
**/
|
||||||
|
|
||||||
var examples = {};
|
var examples = {};
|
||||||
|
|
||||||
examples['application/json'] = "aeiou";
|
examples['application/json'] = "aeiou";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(Object.keys(examples).length > 0)
|
if(Object.keys(examples).length > 0) {
|
||||||
return examples[Object.keys(examples)[0]];
|
res.setHeader('Content-Type', 'application/json');
|
||||||
|
res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
res.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
exports.logoutUser = function() {
|
exports.logoutUser = function(args, res, next) {
|
||||||
|
/**
|
||||||
|
* parameters expected in the args:
|
||||||
|
**/
|
||||||
|
|
||||||
var examples = {};
|
var examples = {};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
res.end();
|
||||||
}
|
}
|
||||||
exports.getUserByName = function(username) {
|
exports.getUserByName = function(args, res, next) {
|
||||||
|
/**
|
||||||
|
* parameters expected in the args:
|
||||||
|
* username (String)
|
||||||
|
**/
|
||||||
|
|
||||||
var examples = {};
|
var examples = {};
|
||||||
|
|
||||||
examples['application/json'] = {
|
examples['application/json'] = {
|
||||||
"id" : 1,
|
"id" : 1,
|
||||||
@ -57,21 +91,38 @@ exports.getUserByName = function(username) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(Object.keys(examples).length > 0)
|
if(Object.keys(examples).length > 0) {
|
||||||
return examples[Object.keys(examples)[0]];
|
res.setHeader('Content-Type', 'application/json');
|
||||||
|
res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
res.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
exports.updateUser = function(username, body) {
|
exports.updateUser = function(args, res, next) {
|
||||||
|
/**
|
||||||
|
* parameters expected in the args:
|
||||||
|
* username (String)
|
||||||
|
* body (User)
|
||||||
|
**/
|
||||||
|
|
||||||
var examples = {};
|
var examples = {};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
res.end();
|
||||||
}
|
}
|
||||||
exports.deleteUser = function(username) {
|
exports.deleteUser = function(args, res, next) {
|
||||||
|
/**
|
||||||
|
* parameters expected in the args:
|
||||||
|
* username (String)
|
||||||
|
**/
|
||||||
|
|
||||||
var examples = {};
|
var examples = {};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
res.end();
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,8 @@
|
|||||||
var app = require('connect')();
|
var app = require('connect')();
|
||||||
var http = require('http');
|
var http = require('http');
|
||||||
var swaggerTools = require('swagger-tools');
|
var swaggerTools = require('swagger-tools');
|
||||||
|
var jsyaml = require('js-yaml');
|
||||||
|
var fs = require('fs');
|
||||||
var serverPort = 8080;
|
var serverPort = 8080;
|
||||||
|
|
||||||
// swaggerRouter configuration
|
// swaggerRouter configuration
|
||||||
@ -14,7 +15,8 @@ var options = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// The Swagger document (require it, build it programmatically, fetch it from a URL, ...)
|
// The Swagger document (require it, build it programmatically, fetch it from a URL, ...)
|
||||||
var swaggerDoc = require('./api/swagger.json');
|
var spec = fs.readFileSync('./api/swagger.yaml', 'utf8');
|
||||||
|
var swaggerDoc = jsyaml.safeLoad(spec);
|
||||||
|
|
||||||
// Initialize the Swagger middleware
|
// Initialize the Swagger middleware
|
||||||
swaggerTools.initializeMiddleware(swaggerDoc, function (middleware) {
|
swaggerTools.initializeMiddleware(swaggerDoc, function (middleware) {
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"connect": "^3.2.0",
|
"connect": "^3.2.0",
|
||||||
"swagger-tools": "0.8.*"
|
"js-yaml": "^3.3.0",
|
||||||
|
"swagger-tools": "0.9.*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user