Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;

public class ExampleGenerator {
Expand All @@ -47,9 +48,12 @@ public class ExampleGenerator {
private static final String NONE = "none";

protected Map<String, Model> examples;
private Random random;

public ExampleGenerator(Map<String, Model> examples) {
this.examples = examples;
// use a fixed seed to make the "random" numbers reproducible.
this.random = new Random("ExampleGenerator".hashCode());
}

public List<Map<String, String>> generate(Map<String, Object> examples, List<String> mediaTypes, Property property) {
Expand Down Expand Up @@ -187,13 +191,13 @@ private Object resolvePropertyToExample(String mediaType, Property property, Set
private double randomNumber(Double min, Double max) {
if (min != null && max != null) {
double range = max - min;
return Math.random() * range + min;
return random.nextDouble() * range + min;
} else if (min != null) {
return Math.random() + min;
return random.nextDouble() + min;
} else if (max != null) {
return Math.random() * max;
return random.nextDouble() * max;
} else {
return Math.random() * 10;
return random.nextDouble() * 10;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Swagger Codegen Ignore
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen

# 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 Swagger Codgen 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
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ paths:
type: "array"
items:
type: "string"
default: "available"
enum:
- "available"
- "pending"
- "sold"
default: "available"
collectionFormat: "csv"
responses:
200:
Expand Down Expand Up @@ -385,7 +385,6 @@ paths:
description: "ID of the order that needs to be deleted"
required: true
type: "string"
minimum: 1
responses:
400:
description: "Invalid ID supplied"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

var url = require('url');


var Pet = require('./PetService');


module.exports.addPet = function addPet (req, res, next) {
Pet.addPet(req.swagger.params, res, next);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,153 +2,165 @@

exports.addPet = function(args, res, next) {
/**
* parameters expected in the args:
* body (Pet)
**/
// no response value expected for this operation
* 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) {
/**
* parameters expected in the args:
* petId (Long)
* api_key (String)
**/
// no response value expected for this operation
* 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) {
/**
* parameters expected in the args:
* status (List)
**/
var examples = {};
* 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" : 123456789,
"id" : 0,
"category" : {
"name" : "aeiou",
"id" : 123456789
"id" : 6
},
"tags" : [ {
"name" : "aeiou",
"id" : 123456789
"id" : 1
} ],
"status" : "aeiou"
"status" : "available"
} ];
if(Object.keys(examples).length > 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 {
} else {
res.end();
}

}

exports.findPetsByTags = function(args, res, next) {
/**
* parameters expected in the args:
* tags (List)
**/
var examples = {};
* 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" : 123456789,
"id" : 0,
"category" : {
"name" : "aeiou",
"id" : 123456789
"id" : 6
},
"tags" : [ {
"name" : "aeiou",
"id" : 123456789
"id" : 1
} ],
"status" : "aeiou"
"status" : "available"
} ];
if(Object.keys(examples).length > 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 {
} else {
res.end();
}

}

exports.getPetById = function(args, res, next) {
/**
* parameters expected in the args:
* petId (Long)
**/
var examples = {};
* 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" : 123456789,
"id" : 0,
"category" : {
"name" : "aeiou",
"id" : 123456789
"id" : 6
},
"tags" : [ {
"name" : "aeiou",
"id" : 123456789
"id" : 1
} ],
"status" : "aeiou"
"status" : "available"
};
if(Object.keys(examples).length > 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 {
} else {
res.end();
}

}

exports.updatePet = function(args, res, next) {
/**
* parameters expected in the args:
* body (Pet)
**/
// no response value expected for this operation
* 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) {
/**
* parameters expected in the args:
* petId (Long)
* name (String)
* status (String)
**/
// no response value expected for this operation
* 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) {
/**
* parameters expected in the args:
* petId (Long)
* additionalMetadata (String)
* file (File)
**/
var examples = {};
* 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" : 123,
"code" : 0,
"type" : "aeiou",
"message" : "aeiou"
};
if(Object.keys(examples).length > 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 {
} else {
res.end();
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

var url = require('url');


var Store = require('./StoreService');


module.exports.deleteOrder = function deleteOrder (req, res, next) {
Store.deleteOrder(req.swagger.params, res, next);
};
Expand Down
Loading