diff --git a/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/PythonClientCodegen.java b/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/PythonClientCodegen.java
index bc47b4041daf..b28c0ccf7506 100755
--- a/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/PythonClientCodegen.java
+++ b/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/PythonClientCodegen.java
@@ -7,7 +7,9 @@ import java.io.File;
import java.util.*;
public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig {
- String module = "client";
+ protected String module = "SwaggerPetstore";
+ protected String invokerPackage;
+ protected String eggPackage;
public CodegenType getTag() {
return CodegenType.CLIENT;
@@ -23,14 +25,18 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
public PythonClientCodegen() {
super();
+
+ eggPackage = module + "-python";
+ invokerPackage = eggPackage + "/" + module;
+
outputFolder = "generated-code/python";
modelTemplateFiles.put("model.mustache", ".py");
apiTemplateFiles.put("api.mustache", ".py");
templateDir = "python";
-
- apiPackage = module;
- modelPackage = module + ".models";
-
+
+ apiPackage = invokerPackage;
+ modelPackage = invokerPackage + ".models";
+
languageSpecificPrimitives.clear();
languageSpecificPrimitives.add("int");
languageSpecificPrimitives.add("float");
@@ -59,10 +65,13 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
"print", "class", "exec", "in", "raise", "continue", "finally", "is",
"return", "def", "for", "lambda", "try"));
- supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
- supportingFiles.add(new SupportingFile("swagger.mustache", module, "swagger.py"));
- supportingFiles.add(new SupportingFile("__init__.mustache", module, "__init__.py"));
- supportingFiles.add(new SupportingFile("__init__.mustache", modelPackage.replace('.', File.separatorChar), "__init__.py"));
+ additionalProperties.put("module", module);
+
+ supportingFiles.add(new SupportingFile("README.mustache", eggPackage, "README.md"));
+ supportingFiles.add(new SupportingFile("setup.mustache", eggPackage, "setup.py"));
+ supportingFiles.add(new SupportingFile("swagger.mustache", invokerPackage, "swagger.py"));
+ supportingFiles.add(new SupportingFile("__init__package.mustache", invokerPackage, "__init__.py"));
+ supportingFiles.add(new SupportingFile("__init__model.mustache", modelPackage.replace('.', File.separatorChar), "__init__.py"));
}
@Override
@@ -113,5 +122,78 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
public String toDefaultValue(Property p) {
// TODO: Support Python def value
return "null";
- }
+ }
+
+ @Override
+ public String toVarName(String name) {
+ // replace - with _ e.g. created-at => created_at
+ name = name.replaceAll("-", "_");
+
+ // if it's all uppper case, convert to lower case
+ if (name.matches("^[A-Z_]*$"))
+ name = name.toLowerCase();
+
+ // camelize (lower first character) the variable name
+ // petId => pet_id
+ name = underscore(name);
+
+ // for reserved word or word starting with number, append _
+ if(reservedWords.contains(name) || name.matches("^\\d.*"))
+ name = escapeReservedWord(name);
+
+ return name;
+ }
+
+ @Override
+ public String toParamName(String name) {
+ // should be the same as variable name
+ return toVarName(name);
+ }
+
+ @Override
+ public String toModelName(String name) {
+ // model name cannot use reserved keyword, e.g. return
+ if(reservedWords.contains(name))
+ throw new RuntimeException(name + " (reserved word) cannot be used as a model name");
+
+ // camelize the model name
+ // phone_number => PhoneNumber
+ return camelize(name);
+ }
+
+ @Override
+ public String toModelFilename(String name) {
+ // model name cannot use reserved keyword, e.g. return
+ if(reservedWords.contains(name))
+ throw new RuntimeException(name + " (reserved word) cannot be used as a model name");
+
+ // underscore the model file name
+ // PhoneNumber.rb => phone_number.rb
+ return underscore(name);
+ }
+
+ @Override
+ public String toApiFilename(String name) {
+ // replace - with _ e.g. created-at => created_at
+ name = name.replaceAll("-", "_");
+
+ // e.g. PhoneNumberApi.rb => phone_number_api.rb
+ return underscore(name) + "_api";
+ }
+
+ @Override
+ public String toApiName(String name) {
+ if(name.length() == 0)
+ return "DefaultApi";
+ // e.g. phone_number_api => PhoneNumberApi
+ return camelize(name) + "Api";
+ }
+
+ @Override
+ public String toApiVarName(String name) {
+ if(name.length() == 0)
+ return "default_api";
+ return underscore(name) + "_api";
+ }
+
}
diff --git a/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/RubyClientCodegen.java b/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/RubyClientCodegen.java
index f2f0f00df873..5decf61d2c0f 100644
--- a/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/RubyClientCodegen.java
+++ b/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/RubyClientCodegen.java
@@ -64,6 +64,8 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
typeMapping.put("List", "array");
typeMapping.put("map", "map");
+ supportingFiles.add(new SupportingFile("swagger-client.gemspec.mustache", "", "swagger-client.gemspec"));
+ supportingFiles.add(new SupportingFile("swagger-client.mustache", "", "lib/swagger-client.rb"));
supportingFiles.add(new SupportingFile("swagger.mustache", "", "lib/swagger.rb"));
supportingFiles.add(new SupportingFile("monkey.mustache", "", "lib/monkey.rb"));
supportingFiles.add(new SupportingFile("swagger/request.mustache", "", "lib/swagger/request.rb"));
diff --git a/modules/swagger-codegen/src/main/resources/csharp/api.mustache b/modules/swagger-codegen/src/main/resources/csharp/api.mustache
index 1ae2921849d6..084caf97b9b5 100644
--- a/modules/swagger-codegen/src/main/resources/csharp/api.mustache
+++ b/modules/swagger-codegen/src/main/resources/csharp/api.mustache
@@ -40,7 +40,7 @@ namespace {{package}} {
///
public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}} {{nickname}} ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {
// create path and map variables
- var path = "{{path}}".Replace("{format}","json"){{#pathParams}}.Replace("{" + "{{baseName}}" + "}", apiInvoker.escapeString({{{paramName}}}.ToString())){{/pathParams}};
+ var path = "{{path}}".Replace("{format}","json"){{#pathParams}}.Replace("{" + "{{baseName}}" + "}", apiInvoker.ParameterToString({{{paramName}}})){{/pathParams}};
// query params
var queryParams = new Dictionary();
@@ -55,20 +55,18 @@ namespace {{package}} {
{{/requiredParamCount}}
{{#queryParams}}if ({{paramName}} != null){
- string paramStr = ({{paramName}} is DateTime) ? ((DateTime)(object){{paramName}}).ToString("u") : Convert.ToString({{paramName}});
- queryParams.Add("{{baseName}}", paramStr);
+ queryParams.Add("{{baseName}}", apiInvoker.ParameterToString({{paramName}}));
}
{{/queryParams}}
- {{#headerParams}}headerParams.Add("{{baseName}}", {{paramName}});
+ {{#headerParams}}headerParams.Add("{{baseName}}", apiInvoker.ParameterToString({{paramName}}));
{{/headerParams}}
{{#formParams}}if ({{paramName}} != null){
if({{paramName}} is byte[]) {
formParams.Add("{{baseName}}", {{paramName}});
} else {
- string paramStr = ({{paramName}} is DateTime) ? ((DateTime)(object){{paramName}}).ToString("u") : Convert.ToString({{paramName}});
- formParams.Add("{{baseName}}", paramStr);
+ formParams.Add("{{baseName}}", apiInvoker.ParameterToString({{paramName}}));
}
}
{{/formParams}}
diff --git a/modules/swagger-codegen/src/main/resources/csharp/apiInvoker.mustache b/modules/swagger-codegen/src/main/resources/csharp/apiInvoker.mustache
index f7c76ee2c569..4e7f1b6997bb 100644
--- a/modules/swagger-codegen/src/main/resources/csharp/apiInvoker.mustache
+++ b/modules/swagger-codegen/src/main/resources/csharp/apiInvoker.mustache
@@ -15,14 +15,41 @@
return _instance;
}
+ ///
+ /// Add default header
+ ///
+ /// Header field name
+ /// Header field value
+ ///
public void addDefaultHeader(string key, string value) {
defaultHeaderMap.Add(key, value);
}
+ ///
+ /// escape string (url-encoded)
+ ///
+ /// String to be escaped
+ /// Escaped string
public string escapeString(string str) {
return str;
}
+ ///
+ /// if parameter is DateTime, output in ISO8601 format, otherwise just return the string
+ ///
+ /// The parameter (header, path, query, form)
+ /// Formatted string
+ public string ParameterToString(object obj)
+ {
+ return (obj is DateTime) ? ((DateTime)obj).ToString ("u") : Convert.ToString (obj);
+ }
+
+ ///
+ /// Deserialize the JSON string into a proper object
+ ///
+ /// JSON string
+ /// Object type
+ /// Object representation of the JSON string
public static object deserialize(string json, Type type) {
try
{
@@ -99,6 +126,7 @@
case "GET":
break;
case "POST":
+ case "PATCH":
case "PUT":
case "DELETE":
using (Stream requestStream = client.GetRequestStream())
diff --git a/modules/swagger-codegen/src/main/resources/objc/SWGApiClient.m b/modules/swagger-codegen/src/main/resources/objc/SWGApiClient.m
index 5b7fd03417d9..6942a21c738a 100644
--- a/modules/swagger-codegen/src/main/resources/objc/SWGApiClient.m
+++ b/modules/swagger-codegen/src/main/resources/objc/SWGApiClient.m
@@ -314,7 +314,7 @@ static bool loggingEnabled = true;
NSString * urlString = [[NSURL URLWithString:path relativeToURL:self.baseURL] absoluteString];
// request with multipart form
- if(file != nil) {
+ if([requestContentType isEqualToString:@"multipart/form-data"]) {
request = [self.requestSerializer multipartFormRequestWithMethod: @"POST"
URLString: urlString
parameters: nil
@@ -325,15 +325,17 @@ static bool loggingEnabled = true;
[formData appendPartWithFormData: data name: key];
}
- [formData appendPartWithFileData: [file data]
- name: [file paramName]
- fileName: [file name]
- mimeType: [file mimeType]];
+ if (file) {
+ [formData appendPartWithFileData: [file data]
+ name: [file paramName]
+ fileName: [file name]
+ mimeType: [file mimeType]];
+ }
}
error:nil];
}
- // request with form parameters
+ // request with form parameters or json
else {
NSString* pathWithQueryParams = [self pathWithQueryParamsToString:path queryParams:queryParams];
NSString* urlString = [[NSURL URLWithString:pathWithQueryParams relativeToURL:self.baseURL] absoluteString];
@@ -470,7 +472,7 @@ static bool loggingEnabled = true;
NSString * urlString = [[NSURL URLWithString:path relativeToURL:self.baseURL] absoluteString];
// request with multipart form
- if(file != nil) {
+ if([requestContentType isEqualToString:@"multipart/form-data"]) {
request = [self.requestSerializer multipartFormRequestWithMethod: @"POST"
URLString: urlString
parameters: nil
@@ -481,15 +483,17 @@ static bool loggingEnabled = true;
[formData appendPartWithFormData: data name: key];
}
- [formData appendPartWithFileData: [file data]
- name: [file paramName]
- fileName: [file name]
- mimeType: [file mimeType]];
+ if (file) {
+ [formData appendPartWithFileData: [file data]
+ name: [file paramName]
+ fileName: [file name]
+ mimeType: [file mimeType]];
+ }
}
error:nil];
}
- // request with form parameters
+ // request with form parameters or json
else {
NSString* pathWithQueryParams = [self pathWithQueryParamsToString:path queryParams:queryParams];
NSString* urlString = [[NSURL URLWithString:pathWithQueryParams relativeToURL:self.baseURL] absoluteString];
@@ -576,3 +580,11 @@ static bool loggingEnabled = true;
}
@end
+
+
+
+
+
+
+
+
diff --git a/modules/swagger-codegen/src/main/resources/php/APIClient.mustache b/modules/swagger-codegen/src/main/resources/php/APIClient.mustache
index 4e60cf6d338b..3af1fcbad345 100644
--- a/modules/swagger-codegen/src/main/resources/php/APIClient.mustache
+++ b/modules/swagger-codegen/src/main/resources/php/APIClient.mustache
@@ -25,6 +25,16 @@ class APIClient {
public static $PUT = "PUT";
public static $DELETE = "DELETE";
+ /*
+ * @var string timeout (second) of the HTTP request, by default set to 0, no timeout
+ */
+ protected $curl_timeout = 0;
+
+ /*
+ * @var string user agent of the HTTP request, set to "PHP-Swagger" by default
+ */
+ protected $user_agent = "PHP-Swagger";
+
/**
* @param string $host the address of the API server
* @param string $headerName a header to pass on requests
@@ -54,7 +64,7 @@ class APIClient {
if (!is_numeric($seconds)) {
throw new Exception('Timeout variable must be numeric.');
}
- $this->curl_timout = $seconds;
+ $this->curl_timeout = $seconds;
}
/**
@@ -84,15 +94,16 @@ class APIClient {
$headers[] = $this->headerName . ": " . $this->headerValue;
}
- if (strpos($headers['Content-Type'], "multipart/form-data") < 0 and (is_object($postData) or is_array($postData))) {
+ if ((isset($headers['Content-Type']) and strpos($headers['Content-Type'], "multipart/form-data") < 0) and (is_object($postData) or is_array($postData))) {
$postData = json_encode($this->sanitizeForSerialization($postData));
}
$url = $this->host . $resourcePath;
$curl = curl_init();
- if ($this->curl_timout) {
- curl_setopt($curl, CURLOPT_TIMEOUT, $this->curl_timout);
+ // set timeout, if needed
+ if ($this->curl_timeout != 0) {
+ curl_setopt($curl, CURLOPT_TIMEOUT, $this->curl_timeout);
}
// return the result on success, rather than just TRUE
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
@@ -120,11 +131,7 @@ class APIClient {
curl_setopt($curl, CURLOPT_URL, $url);
// Set user agent
- if ($this->user_agent) {
- curl_setopt($curl, CURLOPT_USERAGENT, $this->user_agent);
- } else { // use PHP-Swagger as the default user agent
- curl_setopt($curl, CURLOPT_USERAGENT, 'PHP-Swagger');
- }
+ curl_setopt($curl, CURLOPT_USERAGENT, $this->user_agent);
// Make the request
$response = curl_exec($curl);
diff --git a/modules/swagger-codegen/src/main/resources/php/api.mustache b/modules/swagger-codegen/src/main/resources/php/api.mustache
index ca1bf24438d2..6acb2e87433f 100644
--- a/modules/swagger-codegen/src/main/resources/php/api.mustache
+++ b/modules/swagger-codegen/src/main/resources/php/api.mustache
@@ -44,6 +44,7 @@ class {{classname}} {
$resourcePath = "{{path}}";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "{{httpMethod}}";
+ $httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
@@ -77,16 +78,19 @@ class {{classname}} {
$body = ${{paramName}};
}{{/bodyParams}}
+ // for model (json/xml)
+ if (isset($body)) {
+ $httpBody = $body; // $body is the method argument, if present
+ }
+
// for HTTP post (form)
- $body = $body ?: $formParams;
-
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
- $body = http_build_query($body);
+ $httpBody = http_build_query($formParams);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
- $queryParams, $body,
+ $queryParams, $httpBody,
$headerParams);
{{#returnType}}if(! $response) {
diff --git a/modules/swagger-codegen/src/main/resources/python/README.mustache b/modules/swagger-codegen/src/main/resources/python/README.mustache
index cf1f7142bc06..3b69aba0f82d 100644
--- a/modules/swagger-codegen/src/main/resources/python/README.mustache
+++ b/modules/swagger-codegen/src/main/resources/python/README.mustache
@@ -1,25 +1,42 @@
-# Swagger Generated Python client
+## Requirements.
+Python 2.7 and later.
+## Setuptools
+You can install the bindings via [Setuptools](http://pypi.python.org/pypi/setuptools).
-Usage example, based on the swagger petstore:
+```sh
+python setup.py install
+```
+
+Or you can install from Github via pip:
+
+```sh
+pip install git+https://github.com/geekerzp/SwaggerPetstore-python.git
+```
+
+To use the bindings, import the pacakge:
```python
-# include the client module
-from client import *
-
-# build a client connection. In this example, we are passing the hostname as arg0, and
-# sending a header with name `api_key` and value `special-key` on each call to the api.
-
-client = swagger.ApiClient('http://petstore.swagger.io/v2', 'api_key', 'special-key')
-
-# create the PetApi class with the client we just created
-petApi = PetApi.PetApi(client)
-
-# call the API and fetch a pet, with petId=3
-pet = petApi.getPetById(petId=3)
-
-# write it into pretty JSON
-json = client.sanitizeForSerialization(pet)
-print json
-{'category': {'category': None, 'status': None, 'name': 'string', 'tags': None, 'photoUrls': None, 'id': 0L}, 'status': {'category': None, 'status': None, 'name': None, 'tags': None, 'photoUrls': None, 'id': None}, 'name': 'foogly', 'tags': [{'id': 0L, 'name': 'string'}], 'photoUrls': ['string'], 'id': 3L}
+import SwaggerPetstore
```
+
+## Manual Installation
+If you do not wish to use setuptools, you can download the latest release.
+Then, to use the bindings, import the package:
+
+```python
+import path.to.SwaggerPetstore-python.SwaggerPetstore
+```
+
+## Getting Started
+
+TODO
+
+## Documentation
+
+TODO
+
+## Tests
+
+TODO
+
diff --git a/modules/swagger-codegen/src/main/resources/python/__init__.mustache b/modules/swagger-codegen/src/main/resources/python/__init__model.mustache
similarity index 100%
rename from modules/swagger-codegen/src/main/resources/python/__init__.mustache
rename to modules/swagger-codegen/src/main/resources/python/__init__model.mustache
diff --git a/modules/swagger-codegen/src/main/resources/python/__init__package.mustache b/modules/swagger-codegen/src/main/resources/python/__init__package.mustache
new file mode 100644
index 000000000000..e88c5f01ee23
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/python/__init__package.mustache
@@ -0,0 +1,22 @@
+#!/usr/bin/env python
+"""Add all of the modules in the current directory to __all__"""
+import os
+
+# import models into package
+{{#models}}{{#model}}
+from .models.{{classVarName}} import {{classname}}
+{{/model}}{{/models}}
+
+# import apis into package
+{{#apiInfo}}{{#apis}}
+from .{{classVarName}} import {{classname}}
+{{/apis}}{{/apiInfo}}
+
+# import ApiClient
+from .swagger import ApiClient
+
+__all__ = []
+
+for module in os.listdir(os.path.dirname(__file__)):
+ if module != '__init__.py' and module[-3:] == '.py':
+ __all__.append(module[:-3])
diff --git a/modules/swagger-codegen/src/main/resources/python/api.mustache b/modules/swagger-codegen/src/main/resources/python/api.mustache
index a5eca0346a02..658a37f5faa3 100644
--- a/modules/swagger-codegen/src/main/resources/python/api.mustache
+++ b/modules/swagger-codegen/src/main/resources/python/api.mustache
@@ -1,4 +1,6 @@
#!/usr/bin/env python
+# coding: utf-8
+
"""
{{classname}}.py
Copyright 2015 Reverb Technologies, Inc.
@@ -68,12 +70,12 @@ class {{classname}}(object):
{{#queryParams}}
if ('{{paramName}}' in params):
- queryParams['{{paramName}}'] = self.apiClient.toPathValue(params['{{paramName}}'])
+ queryParams['{{baseName}}'] = self.apiClient.toPathValue(params['{{paramName}}'])
{{/queryParams}}
{{#headerParams}}
if ('{{paramName}}' in params):
- headerParams['{{paramName}}'] = params['{{paramName}}']
+ headerParams['{{baseName}}'] = params['{{paramName}}']
{{/headerParams}}
{{#pathParams}}
@@ -86,7 +88,7 @@ class {{classname}}(object):
{{#formParams}}
if ('{{paramName}}' in params):
- {{#notFile}}formParams['{{paramName}}'] = params['{{paramName}}']{{/notFile}}{{#isFile}}files['{{paramName}}'] = params['{{paramName}}']{{/isFile}}
+ {{#notFile}}formParams['{{baseName}}'] = params['{{paramName}}']{{/notFile}}{{#isFile}}files['{{baseName}}'] = params['{{paramName}}']{{/isFile}}
{{/formParams}}
{{#bodyParam}}
diff --git a/modules/swagger-codegen/src/main/resources/python/model.mustache b/modules/swagger-codegen/src/main/resources/python/model.mustache
index ff81820ca33d..e46c63df6374 100644
--- a/modules/swagger-codegen/src/main/resources/python/model.mustache
+++ b/modules/swagger-codegen/src/main/resources/python/model.mustache
@@ -1,4 +1,6 @@
#!/usr/bin/env python
+# coding: utf-8
+
"""
Copyright 2015 Reverb Technologies, Inc.
@@ -39,7 +41,7 @@ class {{classname}}(object):
{{#vars}}
'{{name}}': '{{baseName}}'{{#hasMore}},{{/hasMore}}
{{/vars}}
- }
+ }
{{#vars}}
{{#description}}#{{description}}
diff --git a/modules/swagger-codegen/src/main/resources/python/setup.mustache b/modules/swagger-codegen/src/main/resources/python/setup.mustache
new file mode 100644
index 000000000000..d10da4c68d04
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/python/setup.mustache
@@ -0,0 +1,32 @@
+import sys
+from setuptools import setup, find_packages
+
+{{#apiInfo}}{{#apis}}{{^hasMore}}
+
+# To install the library, open a Terminal shell, then run this
+# file by typing:
+#
+# python setup.py install
+#
+# You need to have the setuptools module installed.
+# Try reading the setuptools documentation:
+# http://pypi.python.org/pypi/setuptools
+
+REQUIRES = []
+
+setup(
+ name="{{module}}",
+ version="{{version}}",
+ description="{{appName}}",
+ author_email="{{infoEmail}}",
+ url="{{infoUrl}}",
+ keywords=["Swagger", "{{appName}}"],
+ install_requires=REQUIRES,
+ packages=find_packages(),
+ include_package_data=True,
+ long_description="""\
+ {{appDescription}}
+ """
+)
+
+{{/hasMore}}{{/apis}}{{/apiInfo}}
diff --git a/modules/swagger-codegen/src/main/resources/python/swagger.mustache b/modules/swagger-codegen/src/main/resources/python/swagger.mustache
index d5e54666e011..018e92536c21 100644
--- a/modules/swagger-codegen/src/main/resources/python/swagger.mustache
+++ b/modules/swagger-codegen/src/main/resources/python/swagger.mustache
@@ -1,4 +1,6 @@
#!/usr/bin/env python
+# coding: utf-8
+
"""Swagger generic API client. This client handles the client-
server communication, and is invariant across implementations. Specifics of
the methods and models for each application are generated from the Swagger
diff --git a/samples/client/petstore/ruby/swagger.gemspec b/modules/swagger-codegen/src/main/resources/ruby/swagger-client.gemspec.mustache
similarity index 90%
rename from samples/client/petstore/ruby/swagger.gemspec
rename to modules/swagger-codegen/src/main/resources/ruby/swagger-client.gemspec.mustache
index 61bab334b3b6..c002e581b8b6 100644
--- a/samples/client/petstore/ruby/swagger.gemspec
+++ b/modules/swagger-codegen/src/main/resources/ruby/swagger-client.gemspec.mustache
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
require "swagger/version"
Gem::Specification.new do |s|
- s.name = "swagger"
+ s.name = "{{artifactId}}"
s.version = Swagger::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ["Zeke Sikelianos", "Tony Tam"]
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
s.summary = %q{A ruby wrapper for the swagger APIs}
s.description = %q{This gem maps to a swagger API}
- s.rubyforge_project = "swagger"
+ s.rubyforge_project = "{{artifactId}}"
s.add_dependency 'typhoeus', '>=0.2.1'
s.add_dependency 'addressable', '>=2.2.4'
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
s.add_development_dependency 'rspec', '>=2.5.0'
s.add_development_dependency 'vcr', '>=1.5.1'
s.add_development_dependency 'webmock', '>=1.6.2'
- s.add_development_dependency 'autotest'
+ s.add_development_dependency 'autotest'
s.add_development_dependency 'autotest-rails-pure'
s.add_development_dependency 'autotest-growl'
s.add_development_dependency 'autotest-fsevent'
diff --git a/modules/swagger-codegen/src/main/resources/ruby/swagger-client.mustache b/modules/swagger-codegen/src/main/resources/ruby/swagger-client.mustache
new file mode 100644
index 000000000000..b13f83b1dbcf
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/ruby/swagger-client.mustache
@@ -0,0 +1,5 @@
+require 'monkey'
+require 'swagger'
+
+Dir[File.join(File.dirname(__FILE__), "../lib/*.rb")].each {|file| require file if file !~ /swagger-client\.rb\z/ }
+Dir[File.join(File.dirname(__FILE__), "../models/*.rb")].each {|file| require file }
diff --git a/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/PetApi.cs b/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/PetApi.cs
index 36bb469686ae..3750f302faa9 100644
--- a/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/PetApi.cs
+++ b/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/PetApi.cs
@@ -144,8 +144,7 @@ namespace io.swagger.Api {
if (Status != null){
- string paramStr = (Status is DateTime) ? ((DateTime)(object)Status).ToString("u") : Convert.ToString(Status);
- queryParams.Add("status", paramStr);
+ queryParams.Add("status", apiInvoker.ParameterToString(Status));
}
@@ -201,8 +200,7 @@ namespace io.swagger.Api {
if (Tags != null){
- string paramStr = (Tags is DateTime) ? ((DateTime)(object)Tags).ToString("u") : Convert.ToString(Tags);
- queryParams.Add("tags", paramStr);
+ queryParams.Add("tags", apiInvoker.ParameterToString(Tags));
}
@@ -248,7 +246,7 @@ namespace io.swagger.Api {
///
public Pet getPetById (long? PetId) {
// create path and map variables
- var path = "/pet/{petId}".Replace("{format}","json").Replace("{" + "petId" + "}", apiInvoker.escapeString(PetId.ToString()));
+ var path = "/pet/{petId}".Replace("{format}","json").Replace("{" + "petId" + "}", apiInvoker.ParameterToString(PetId));
// query params
var queryParams = new Dictionary();
@@ -303,7 +301,7 @@ namespace io.swagger.Api {
///
public void updatePetWithForm (string PetId, string Name, string Status) {
// create path and map variables
- var path = "/pet/{petId}".Replace("{format}","json").Replace("{" + "petId" + "}", apiInvoker.escapeString(PetId.ToString()));
+ var path = "/pet/{petId}".Replace("{format}","json").Replace("{" + "petId" + "}", apiInvoker.ParameterToString(PetId));
// query params
var queryParams = new Dictionary();
@@ -320,16 +318,14 @@ namespace io.swagger.Api {
if(Name is byte[]) {
formParams.Add("name", Name);
} else {
- string paramStr = (Name is DateTime) ? ((DateTime)(object)Name).ToString("u") : Convert.ToString(Name);
- formParams.Add("name", paramStr);
+ formParams.Add("name", apiInvoker.ParameterToString(Name));
}
}
if (Status != null){
if(Status is byte[]) {
formParams.Add("status", Status);
} else {
- string paramStr = (Status is DateTime) ? ((DateTime)(object)Status).ToString("u") : Convert.ToString(Status);
- formParams.Add("status", paramStr);
+ formParams.Add("status", apiInvoker.ParameterToString(Status));
}
}
@@ -368,7 +364,7 @@ namespace io.swagger.Api {
///
public void deletePet (string ApiKey, long? PetId) {
// create path and map variables
- var path = "/pet/{petId}".Replace("{format}","json").Replace("{" + "petId" + "}", apiInvoker.escapeString(PetId.ToString()));
+ var path = "/pet/{petId}".Replace("{format}","json").Replace("{" + "petId" + "}", apiInvoker.ParameterToString(PetId));
// query params
var queryParams = new Dictionary();
@@ -379,7 +375,7 @@ namespace io.swagger.Api {
- headerParams.Add("api_key", ApiKey);
+ headerParams.Add("api_key", apiInvoker.ParameterToString(ApiKey));
@@ -419,7 +415,7 @@ namespace io.swagger.Api {
///
public void uploadFile (long? PetId, string AdditionalMetadata, byte[] File) {
// create path and map variables
- var path = "/pet/{petId}/uploadImage".Replace("{format}","json").Replace("{" + "petId" + "}", apiInvoker.escapeString(PetId.ToString()));
+ var path = "/pet/{petId}/uploadImage".Replace("{format}","json").Replace("{" + "petId" + "}", apiInvoker.ParameterToString(PetId));
// query params
var queryParams = new Dictionary();
@@ -436,16 +432,14 @@ namespace io.swagger.Api {
if(AdditionalMetadata is byte[]) {
formParams.Add("additionalMetadata", AdditionalMetadata);
} else {
- string paramStr = (AdditionalMetadata is DateTime) ? ((DateTime)(object)AdditionalMetadata).ToString("u") : Convert.ToString(AdditionalMetadata);
- formParams.Add("additionalMetadata", paramStr);
+ formParams.Add("additionalMetadata", apiInvoker.ParameterToString(AdditionalMetadata));
}
}
if (File != null){
if(File is byte[]) {
formParams.Add("file", File);
} else {
- string paramStr = (File is DateTime) ? ((DateTime)(object)File).ToString("u") : Convert.ToString(File);
- formParams.Add("file", paramStr);
+ formParams.Add("file", apiInvoker.ParameterToString(File));
}
}
diff --git a/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/StoreApi.cs b/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/StoreApi.cs
index 04c5ed0dc901..6ab79f879768 100644
--- a/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/StoreApi.cs
+++ b/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/StoreApi.cs
@@ -143,7 +143,7 @@ namespace io.swagger.Api {
///
public Order getOrderById (string OrderId) {
// create path and map variables
- var path = "/store/order/{orderId}".Replace("{format}","json").Replace("{" + "orderId" + "}", apiInvoker.escapeString(OrderId.ToString()));
+ var path = "/store/order/{orderId}".Replace("{format}","json").Replace("{" + "orderId" + "}", apiInvoker.ParameterToString(OrderId));
// query params
var queryParams = new Dictionary();
@@ -196,7 +196,7 @@ namespace io.swagger.Api {
///
public void deleteOrder (string OrderId) {
// create path and map variables
- var path = "/store/order/{orderId}".Replace("{format}","json").Replace("{" + "orderId" + "}", apiInvoker.escapeString(OrderId.ToString()));
+ var path = "/store/order/{orderId}".Replace("{format}","json").Replace("{" + "orderId" + "}", apiInvoker.ParameterToString(OrderId));
// query params
var queryParams = new Dictionary();
diff --git a/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/UserApi.cs b/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/UserApi.cs
index 4f13598da25f..c262cbd38cb0 100644
--- a/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/UserApi.cs
+++ b/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/UserApi.cs
@@ -193,12 +193,10 @@ namespace io.swagger.Api {
if (Username != null){
- string paramStr = (Username is DateTime) ? ((DateTime)(object)Username).ToString("u") : Convert.ToString(Username);
- queryParams.Add("username", paramStr);
+ queryParams.Add("username", apiInvoker.ParameterToString(Username));
}
if (Password != null){
- string paramStr = (Password is DateTime) ? ((DateTime)(object)Password).ToString("u") : Convert.ToString(Password);
- queryParams.Add("password", paramStr);
+ queryParams.Add("password", apiInvoker.ParameterToString(Password));
}
@@ -291,7 +289,7 @@ namespace io.swagger.Api {
///
public User getUserByName (string Username) {
// create path and map variables
- var path = "/user/{username}".Replace("{format}","json").Replace("{" + "username" + "}", apiInvoker.escapeString(Username.ToString()));
+ var path = "/user/{username}".Replace("{format}","json").Replace("{" + "username" + "}", apiInvoker.ParameterToString(Username));
// query params
var queryParams = new Dictionary();
@@ -345,7 +343,7 @@ namespace io.swagger.Api {
///
public void updateUser (string Username, User Body) {
// create path and map variables
- var path = "/user/{username}".Replace("{format}","json").Replace("{" + "username" + "}", apiInvoker.escapeString(Username.ToString()));
+ var path = "/user/{username}".Replace("{format}","json").Replace("{" + "username" + "}", apiInvoker.ParameterToString(Username));
// query params
var queryParams = new Dictionary();
@@ -393,7 +391,7 @@ namespace io.swagger.Api {
///
public void deleteUser (string Username) {
// create path and map variables
- var path = "/user/{username}".Replace("{format}","json").Replace("{" + "username" + "}", apiInvoker.escapeString(Username.ToString()));
+ var path = "/user/{username}".Replace("{format}","json").Replace("{" + "username" + "}", apiInvoker.ParameterToString(Username));
// query params
var queryParams = new Dictionary();
diff --git a/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/ApiInvoker.cs b/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/ApiInvoker.cs
index 736b51b81f9b..c14d1af7d6ca 100644
--- a/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/ApiInvoker.cs
+++ b/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/ApiInvoker.cs
@@ -23,6 +23,16 @@
return str;
}
+ ///
+ /// if parameter is DateTime, output in ISO8601 format, otherwise just return the string
+ ///
+ /// The parameter (header, path, query, form)
+ ///
+ public string ParameterToString(object obj)
+ {
+ return (obj is DateTime) ? ((DateTime)obj).ToString ("u") : Convert.ToString (obj);
+ }
+
public static object deserialize(string json, Type type) {
try
{
diff --git a/samples/client/petstore/php/SwaggerPetstore-php/lib/APIClient.php b/samples/client/petstore/php/SwaggerPetstore-php/lib/APIClient.php
index 1f72299756f3..f5a1ec18a33d 100644
--- a/samples/client/petstore/php/SwaggerPetstore-php/lib/APIClient.php
+++ b/samples/client/petstore/php/SwaggerPetstore-php/lib/APIClient.php
@@ -25,6 +25,16 @@ class APIClient {
public static $PUT = "PUT";
public static $DELETE = "DELETE";
+ /*
+ * @var string timeout (second) of the HTTP request, by default set to 0, no timeout
+ */
+ protected $curl_timeout = 0;
+
+ /*
+ * @var string user agent of the HTTP request, set to "PHP-Swagger" by default
+ */
+ protected $user_agent = "PHP-Swagger";
+
/**
* @param string $host the address of the API server
* @param string $headerName a header to pass on requests
@@ -54,7 +64,7 @@ class APIClient {
if (!is_numeric($seconds)) {
throw new Exception('Timeout variable must be numeric.');
}
- $this->curl_timout = $seconds;
+ $this->curl_timeout = $seconds;
}
/**
@@ -84,15 +94,16 @@ class APIClient {
$headers[] = $this->headerName . ": " . $this->headerValue;
}
- if (strpos($headers['Content-Type'], "multipart/form-data") < 0 and (is_object($postData) or is_array($postData))) {
+ if ((isset($headers['Content-Type']) and strpos($headers['Content-Type'], "multipart/form-data") < 0) and (is_object($postData) or is_array($postData))) {
$postData = json_encode($this->sanitizeForSerialization($postData));
}
$url = $this->host . $resourcePath;
$curl = curl_init();
- if ($this->curl_timout) {
- curl_setopt($curl, CURLOPT_TIMEOUT, $this->curl_timout);
+ // set timeout, if needed
+ if ($this->curl_timeout != 0) {
+ curl_setopt($curl, CURLOPT_TIMEOUT, $this->curl_timeout);
}
// return the result on success, rather than just TRUE
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
@@ -120,11 +131,7 @@ class APIClient {
curl_setopt($curl, CURLOPT_URL, $url);
// Set user agent
- if ($this->user_agent) {
- curl_setopt($curl, CURLOPT_USERAGENT, $this->user_agent);
- } else { // use PHP-Swagger as the default user agent
- curl_setopt($curl, CURLOPT_USERAGENT, 'PHP-Swagger');
- }
+ curl_setopt($curl, CURLOPT_USERAGENT, $this->user_agent);
// Make the request
$response = curl_exec($curl);
diff --git a/samples/client/petstore/php/SwaggerPetstore-php/lib/PetApi.php b/samples/client/petstore/php/SwaggerPetstore-php/lib/PetApi.php
index 7a885b45b822..1b31db8915df 100644
--- a/samples/client/petstore/php/SwaggerPetstore-php/lib/PetApi.php
+++ b/samples/client/petstore/php/SwaggerPetstore-php/lib/PetApi.php
@@ -43,6 +43,7 @@ class PetApi {
$resourcePath = "/pet";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "PUT";
+ $httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
@@ -63,16 +64,19 @@ class PetApi {
$body = $body;
}
+ // for model (json/xml)
+ if (isset($body)) {
+ $httpBody = $body; // $body is the method argument, if present
+ }
+
// for HTTP post (form)
- $body = $body ?: $formParams;
-
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
- $body = http_build_query($body);
+ $httpBody = http_build_query($formParams);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
- $queryParams, $body,
+ $queryParams, $httpBody,
$headerParams);
@@ -92,6 +96,7 @@ class PetApi {
$resourcePath = "/pet";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "POST";
+ $httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
@@ -112,16 +117,19 @@ class PetApi {
$body = $body;
}
+ // for model (json/xml)
+ if (isset($body)) {
+ $httpBody = $body; // $body is the method argument, if present
+ }
+
// for HTTP post (form)
- $body = $body ?: $formParams;
-
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
- $body = http_build_query($body);
+ $httpBody = http_build_query($formParams);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
- $queryParams, $body,
+ $queryParams, $httpBody,
$headerParams);
@@ -141,6 +149,7 @@ class PetApi {
$resourcePath = "/pet/findByStatus";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "GET";
+ $httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
@@ -160,16 +169,19 @@ class PetApi {
+ // for model (json/xml)
+ if (isset($body)) {
+ $httpBody = $body; // $body is the method argument, if present
+ }
+
// for HTTP post (form)
- $body = $body ?: $formParams;
-
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
- $body = http_build_query($body);
+ $httpBody = http_build_query($formParams);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
- $queryParams, $body,
+ $queryParams, $httpBody,
$headerParams);
if(! $response) {
@@ -195,6 +207,7 @@ class PetApi {
$resourcePath = "/pet/findByTags";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "GET";
+ $httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
@@ -214,16 +227,19 @@ class PetApi {
+ // for model (json/xml)
+ if (isset($body)) {
+ $httpBody = $body; // $body is the method argument, if present
+ }
+
// for HTTP post (form)
- $body = $body ?: $formParams;
-
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
- $body = http_build_query($body);
+ $httpBody = http_build_query($formParams);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
- $queryParams, $body,
+ $queryParams, $httpBody,
$headerParams);
if(! $response) {
@@ -249,6 +265,7 @@ class PetApi {
$resourcePath = "/pet/{petId}";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "GET";
+ $httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
@@ -269,16 +286,19 @@ class PetApi {
+ // for model (json/xml)
+ if (isset($body)) {
+ $httpBody = $body; // $body is the method argument, if present
+ }
+
// for HTTP post (form)
- $body = $body ?: $formParams;
-
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
- $body = http_build_query($body);
+ $httpBody = http_build_query($formParams);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
- $queryParams, $body,
+ $queryParams, $httpBody,
$headerParams);
if(! $response) {
@@ -306,6 +326,7 @@ class PetApi {
$resourcePath = "/pet/{petId}";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "POST";
+ $httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
@@ -332,16 +353,19 @@ class PetApi {
}
+ // for model (json/xml)
+ if (isset($body)) {
+ $httpBody = $body; // $body is the method argument, if present
+ }
+
// for HTTP post (form)
- $body = $body ?: $formParams;
-
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
- $body = http_build_query($body);
+ $httpBody = http_build_query($formParams);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
- $queryParams, $body,
+ $queryParams, $httpBody,
$headerParams);
@@ -362,6 +386,7 @@ class PetApi {
$resourcePath = "/pet/{petId}";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "DELETE";
+ $httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
@@ -385,16 +410,19 @@ class PetApi {
+ // for model (json/xml)
+ if (isset($body)) {
+ $httpBody = $body; // $body is the method argument, if present
+ }
+
// for HTTP post (form)
- $body = $body ?: $formParams;
-
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
- $body = http_build_query($body);
+ $httpBody = http_build_query($formParams);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
- $queryParams, $body,
+ $queryParams, $httpBody,
$headerParams);
@@ -416,6 +444,7 @@ class PetApi {
$resourcePath = "/pet/{petId}/uploadImage";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "POST";
+ $httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
@@ -442,16 +471,19 @@ class PetApi {
}
+ // for model (json/xml)
+ if (isset($body)) {
+ $httpBody = $body; // $body is the method argument, if present
+ }
+
// for HTTP post (form)
- $body = $body ?: $formParams;
-
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
- $body = http_build_query($body);
+ $httpBody = http_build_query($formParams);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
- $queryParams, $body,
+ $queryParams, $httpBody,
$headerParams);
diff --git a/samples/client/petstore/php/SwaggerPetstore-php/lib/StoreApi.php b/samples/client/petstore/php/SwaggerPetstore-php/lib/StoreApi.php
index 90fb0f4d4f8b..83a3f0520fad 100644
--- a/samples/client/petstore/php/SwaggerPetstore-php/lib/StoreApi.php
+++ b/samples/client/petstore/php/SwaggerPetstore-php/lib/StoreApi.php
@@ -42,6 +42,7 @@ class StoreApi {
$resourcePath = "/store/inventory";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "GET";
+ $httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
@@ -58,16 +59,19 @@ class StoreApi {
+ // for model (json/xml)
+ if (isset($body)) {
+ $httpBody = $body; // $body is the method argument, if present
+ }
+
// for HTTP post (form)
- $body = $body ?: $formParams;
-
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
- $body = http_build_query($body);
+ $httpBody = http_build_query($formParams);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
- $queryParams, $body,
+ $queryParams, $httpBody,
$headerParams);
if(! $response) {
@@ -93,6 +97,7 @@ class StoreApi {
$resourcePath = "/store/order";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "POST";
+ $httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
@@ -113,16 +118,19 @@ class StoreApi {
$body = $body;
}
+ // for model (json/xml)
+ if (isset($body)) {
+ $httpBody = $body; // $body is the method argument, if present
+ }
+
// for HTTP post (form)
- $body = $body ?: $formParams;
-
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
- $body = http_build_query($body);
+ $httpBody = http_build_query($formParams);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
- $queryParams, $body,
+ $queryParams, $httpBody,
$headerParams);
if(! $response) {
@@ -148,6 +156,7 @@ class StoreApi {
$resourcePath = "/store/order/{orderId}";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "GET";
+ $httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
@@ -168,16 +177,19 @@ class StoreApi {
+ // for model (json/xml)
+ if (isset($body)) {
+ $httpBody = $body; // $body is the method argument, if present
+ }
+
// for HTTP post (form)
- $body = $body ?: $formParams;
-
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
- $body = http_build_query($body);
+ $httpBody = http_build_query($formParams);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
- $queryParams, $body,
+ $queryParams, $httpBody,
$headerParams);
if(! $response) {
@@ -203,6 +215,7 @@ class StoreApi {
$resourcePath = "/store/order/{orderId}";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "DELETE";
+ $httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
@@ -223,16 +236,19 @@ class StoreApi {
+ // for model (json/xml)
+ if (isset($body)) {
+ $httpBody = $body; // $body is the method argument, if present
+ }
+
// for HTTP post (form)
- $body = $body ?: $formParams;
-
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
- $body = http_build_query($body);
+ $httpBody = http_build_query($formParams);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
- $queryParams, $body,
+ $queryParams, $httpBody,
$headerParams);
diff --git a/samples/client/petstore/php/SwaggerPetstore-php/lib/UserApi.php b/samples/client/petstore/php/SwaggerPetstore-php/lib/UserApi.php
index f6952074f7b8..d55b430d7a11 100644
--- a/samples/client/petstore/php/SwaggerPetstore-php/lib/UserApi.php
+++ b/samples/client/petstore/php/SwaggerPetstore-php/lib/UserApi.php
@@ -43,6 +43,7 @@ class UserApi {
$resourcePath = "/user";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "POST";
+ $httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
@@ -63,16 +64,19 @@ class UserApi {
$body = $body;
}
+ // for model (json/xml)
+ if (isset($body)) {
+ $httpBody = $body; // $body is the method argument, if present
+ }
+
// for HTTP post (form)
- $body = $body ?: $formParams;
-
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
- $body = http_build_query($body);
+ $httpBody = http_build_query($formParams);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
- $queryParams, $body,
+ $queryParams, $httpBody,
$headerParams);
@@ -92,6 +96,7 @@ class UserApi {
$resourcePath = "/user/createWithArray";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "POST";
+ $httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
@@ -112,16 +117,19 @@ class UserApi {
$body = $body;
}
+ // for model (json/xml)
+ if (isset($body)) {
+ $httpBody = $body; // $body is the method argument, if present
+ }
+
// for HTTP post (form)
- $body = $body ?: $formParams;
-
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
- $body = http_build_query($body);
+ $httpBody = http_build_query($formParams);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
- $queryParams, $body,
+ $queryParams, $httpBody,
$headerParams);
@@ -141,6 +149,7 @@ class UserApi {
$resourcePath = "/user/createWithList";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "POST";
+ $httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
@@ -161,16 +170,19 @@ class UserApi {
$body = $body;
}
+ // for model (json/xml)
+ if (isset($body)) {
+ $httpBody = $body; // $body is the method argument, if present
+ }
+
// for HTTP post (form)
- $body = $body ?: $formParams;
-
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
- $body = http_build_query($body);
+ $httpBody = http_build_query($formParams);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
- $queryParams, $body,
+ $queryParams, $httpBody,
$headerParams);
@@ -191,6 +203,7 @@ class UserApi {
$resourcePath = "/user/login";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "GET";
+ $httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
@@ -213,16 +226,19 @@ class UserApi {
+ // for model (json/xml)
+ if (isset($body)) {
+ $httpBody = $body; // $body is the method argument, if present
+ }
+
// for HTTP post (form)
- $body = $body ?: $formParams;
-
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
- $body = http_build_query($body);
+ $httpBody = http_build_query($formParams);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
- $queryParams, $body,
+ $queryParams, $httpBody,
$headerParams);
if(! $response) {
@@ -247,6 +263,7 @@ class UserApi {
$resourcePath = "/user/logout";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "GET";
+ $httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
@@ -263,16 +280,19 @@ class UserApi {
+ // for model (json/xml)
+ if (isset($body)) {
+ $httpBody = $body; // $body is the method argument, if present
+ }
+
// for HTTP post (form)
- $body = $body ?: $formParams;
-
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
- $body = http_build_query($body);
+ $httpBody = http_build_query($formParams);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
- $queryParams, $body,
+ $queryParams, $httpBody,
$headerParams);
@@ -292,6 +312,7 @@ class UserApi {
$resourcePath = "/user/{username}";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "GET";
+ $httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
@@ -312,16 +333,19 @@ class UserApi {
+ // for model (json/xml)
+ if (isset($body)) {
+ $httpBody = $body; // $body is the method argument, if present
+ }
+
// for HTTP post (form)
- $body = $body ?: $formParams;
-
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
- $body = http_build_query($body);
+ $httpBody = http_build_query($formParams);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
- $queryParams, $body,
+ $queryParams, $httpBody,
$headerParams);
if(! $response) {
@@ -348,6 +372,7 @@ class UserApi {
$resourcePath = "/user/{username}";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "PUT";
+ $httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
@@ -372,16 +397,19 @@ class UserApi {
$body = $body;
}
+ // for model (json/xml)
+ if (isset($body)) {
+ $httpBody = $body; // $body is the method argument, if present
+ }
+
// for HTTP post (form)
- $body = $body ?: $formParams;
-
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
- $body = http_build_query($body);
+ $httpBody = http_build_query($formParams);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
- $queryParams, $body,
+ $queryParams, $httpBody,
$headerParams);
@@ -401,6 +429,7 @@ class UserApi {
$resourcePath = "/user/{username}";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "DELETE";
+ $httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
@@ -421,16 +450,19 @@ class UserApi {
+ // for model (json/xml)
+ if (isset($body)) {
+ $httpBody = $body; // $body is the method argument, if present
+ }
+
// for HTTP post (form)
- $body = $body ?: $formParams;
-
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
- $body = http_build_query($body);
+ $httpBody = http_build_query($formParams);
}
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
- $queryParams, $body,
+ $queryParams, $httpBody,
$headerParams);
diff --git a/samples/client/petstore/php/SwaggerPetstore-php/lib/models/Category.php b/samples/client/petstore/php/SwaggerPetstore-php/lib/models/Category.php
index 2bd2410268c6..101222b4503a 100644
--- a/samples/client/petstore/php/SwaggerPetstore-php/lib/models/Category.php
+++ b/samples/client/petstore/php/SwaggerPetstore-php/lib/models/Category.php
@@ -16,7 +16,7 @@
*/
/**
- * testing category description
+ *
*
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
*
diff --git a/samples/client/petstore/python/README.md b/samples/client/petstore/python/README.md
deleted file mode 100644
index cf1f7142bc06..000000000000
--- a/samples/client/petstore/python/README.md
+++ /dev/null
@@ -1,25 +0,0 @@
-# Swagger Generated Python client
-
-
-Usage example, based on the swagger petstore:
-
-```python
-# include the client module
-from client import *
-
-# build a client connection. In this example, we are passing the hostname as arg0, and
-# sending a header with name `api_key` and value `special-key` on each call to the api.
-
-client = swagger.ApiClient('http://petstore.swagger.io/v2', 'api_key', 'special-key')
-
-# create the PetApi class with the client we just created
-petApi = PetApi.PetApi(client)
-
-# call the API and fetch a pet, with petId=3
-pet = petApi.getPetById(petId=3)
-
-# write it into pretty JSON
-json = client.sanitizeForSerialization(pet)
-print json
-{'category': {'category': None, 'status': None, 'name': 'string', 'tags': None, 'photoUrls': None, 'id': 0L}, 'status': {'category': None, 'status': None, 'name': None, 'tags': None, 'photoUrls': None, 'id': None}, 'name': 'foogly', 'tags': [{'id': 0L, 'name': 'string'}], 'photoUrls': ['string'], 'id': 3L}
-```
diff --git a/samples/client/petstore/python/SwaggerPetstore-python/README.md b/samples/client/petstore/python/SwaggerPetstore-python/README.md
new file mode 100644
index 000000000000..3b69aba0f82d
--- /dev/null
+++ b/samples/client/petstore/python/SwaggerPetstore-python/README.md
@@ -0,0 +1,42 @@
+## Requirements.
+Python 2.7 and later.
+
+## Setuptools
+You can install the bindings via [Setuptools](http://pypi.python.org/pypi/setuptools).
+
+```sh
+python setup.py install
+```
+
+Or you can install from Github via pip:
+
+```sh
+pip install git+https://github.com/geekerzp/SwaggerPetstore-python.git
+```
+
+To use the bindings, import the pacakge:
+
+```python
+import SwaggerPetstore
+```
+
+## Manual Installation
+If you do not wish to use setuptools, you can download the latest release.
+Then, to use the bindings, import the package:
+
+```python
+import path.to.SwaggerPetstore-python.SwaggerPetstore
+```
+
+## Getting Started
+
+TODO
+
+## Documentation
+
+TODO
+
+## Tests
+
+TODO
+
diff --git a/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/__init__.py b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/__init__.py
new file mode 100644
index 000000000000..30d634bc4b38
--- /dev/null
+++ b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/__init__.py
@@ -0,0 +1,34 @@
+#!/usr/bin/env python
+"""Add all of the modules in the current directory to __all__"""
+import os
+
+# import models into package
+
+from .models.user import User
+
+from .models.category import Category
+
+from .models.pet import Pet
+
+from .models.tag import Tag
+
+from .models.order import Order
+
+
+# import apis into package
+
+from .user_api import UserApi
+
+from .pet_api import PetApi
+
+from .store_api import StoreApi
+
+
+# import ApiClient
+from .swagger import ApiClient
+
+__all__ = []
+
+for module in os.listdir(os.path.dirname(__file__)):
+ if module != '__init__.py' and module[-3:] == '.py':
+ __all__.append(module[:-3])
diff --git a/samples/client/petstore/python/client/__init__.py b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/models/__init__.py
similarity index 100%
rename from samples/client/petstore/python/client/__init__.py
rename to samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/models/__init__.py
diff --git a/samples/client/petstore/python/client/models/Category.py b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/models/category.py
similarity index 98%
rename from samples/client/petstore/python/client/models/Category.py
rename to samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/models/category.py
index 3d64348d1d0c..7b41a32a7d75 100644
--- a/samples/client/petstore/python/client/models/Category.py
+++ b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/models/category.py
@@ -1,4 +1,6 @@
#!/usr/bin/env python
+# coding: utf-8
+
"""
Copyright 2015 Reverb Technologies, Inc.
@@ -41,7 +43,7 @@ class Category(object):
'name': 'name'
- }
+ }
diff --git a/samples/client/petstore/python/client/models/Order.py b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/models/order.py
similarity index 88%
rename from samples/client/petstore/python/client/models/Order.py
rename to samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/models/order.py
index 244fa872cbd8..84780db3780e 100644
--- a/samples/client/petstore/python/client/models/Order.py
+++ b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/models/order.py
@@ -1,4 +1,6 @@
#!/usr/bin/env python
+# coding: utf-8
+
"""
Copyright 2015 Reverb Technologies, Inc.
@@ -31,13 +33,13 @@ class Order(object):
'id': 'long',
- 'petId': 'long',
+ 'pet_id': 'long',
'quantity': 'int',
- 'shipDate': 'DateTime',
+ 'ship_date': 'DateTime',
'status': 'str',
@@ -51,30 +53,30 @@ class Order(object):
'id': 'id',
- 'petId': 'petId',
+ 'pet_id': 'petId',
'quantity': 'quantity',
- 'shipDate': 'shipDate',
+ 'ship_date': 'shipDate',
'status': 'status',
'complete': 'complete'
- }
+ }
self.id = None # long
- self.petId = None # long
+ self.pet_id = None # long
self.quantity = None # int
- self.shipDate = None # DateTime
+ self.ship_date = None # DateTime
#Order Status
diff --git a/samples/client/petstore/python/client/models/Pet.py b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/models/pet.py
similarity index 93%
rename from samples/client/petstore/python/client/models/Pet.py
rename to samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/models/pet.py
index 4c4ee116c095..1415d6f85350 100644
--- a/samples/client/petstore/python/client/models/Pet.py
+++ b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/models/pet.py
@@ -1,4 +1,6 @@
#!/usr/bin/env python
+# coding: utf-8
+
"""
Copyright 2015 Reverb Technologies, Inc.
@@ -37,7 +39,7 @@ class Pet(object):
'name': 'str',
- 'photoUrls': 'list[str]',
+ 'photo_urls': 'list[str]',
'tags': 'list[Tag]',
@@ -55,13 +57,13 @@ class Pet(object):
'name': 'name',
- 'photoUrls': 'photoUrls',
+ 'photo_urls': 'photoUrls',
'tags': 'tags',
'status': 'status'
- }
+ }
@@ -74,7 +76,7 @@ class Pet(object):
self.name = None # str
- self.photoUrls = None # list[str]
+ self.photo_urls = None # list[str]
self.tags = None # list[Tag]
diff --git a/samples/client/petstore/python/client/models/Tag.py b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/models/tag.py
similarity index 98%
rename from samples/client/petstore/python/client/models/Tag.py
rename to samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/models/tag.py
index 5d4411799e6b..a6ed30834225 100644
--- a/samples/client/petstore/python/client/models/Tag.py
+++ b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/models/tag.py
@@ -1,4 +1,6 @@
#!/usr/bin/env python
+# coding: utf-8
+
"""
Copyright 2015 Reverb Technologies, Inc.
@@ -41,7 +43,7 @@ class Tag(object):
'name': 'name'
- }
+ }
diff --git a/samples/client/petstore/python/client/models/User.py b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/models/user.py
similarity index 85%
rename from samples/client/petstore/python/client/models/User.py
rename to samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/models/user.py
index f735aed00824..8559b331203d 100644
--- a/samples/client/petstore/python/client/models/User.py
+++ b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/models/user.py
@@ -1,4 +1,6 @@
#!/usr/bin/env python
+# coding: utf-8
+
"""
Copyright 2015 Reverb Technologies, Inc.
@@ -34,10 +36,10 @@ class User(object):
'username': 'str',
- 'firstName': 'str',
+ 'first_name': 'str',
- 'lastName': 'str',
+ 'last_name': 'str',
'email': 'str',
@@ -49,7 +51,7 @@ class User(object):
'phone': 'str',
- 'userStatus': 'int'
+ 'user_status': 'int'
}
@@ -59,9 +61,9 @@ class User(object):
'username': 'username',
- 'firstName': 'firstName',
+ 'first_name': 'firstName',
- 'lastName': 'lastName',
+ 'last_name': 'lastName',
'email': 'email',
@@ -69,9 +71,9 @@ class User(object):
'phone': 'phone',
- 'userStatus': 'userStatus'
+ 'user_status': 'userStatus'
- }
+ }
@@ -81,10 +83,10 @@ class User(object):
self.username = None # str
- self.firstName = None # str
+ self.first_name = None # str
- self.lastName = None # str
+ self.last_name = None # str
self.email = None # str
@@ -97,5 +99,5 @@ class User(object):
#User Status
- self.userStatus = None # int
+ self.user_status = None # int
diff --git a/samples/client/petstore/python/client/PetApi.py b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/pet_api.py
similarity index 94%
rename from samples/client/petstore/python/client/PetApi.py
rename to samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/pet_api.py
index 729431a81101..d0a85e4a6976 100644
--- a/samples/client/petstore/python/client/PetApi.py
+++ b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/pet_api.py
@@ -1,4 +1,6 @@
#!/usr/bin/env python
+# coding: utf-8
+
"""
PetApi.py
Copyright 2015 Reverb Technologies, Inc.
@@ -272,14 +274,14 @@ class PetApi(object):
Args:
- petId, long: ID of pet that needs to be fetched (required)
+ pet_id, long: ID of pet that needs to be fetched (required)
Returns: Pet
"""
- allParams = ['petId']
+ allParams = ['pet_id']
params = locals()
for (key, val) in params['kwargs'].iteritems():
@@ -306,8 +308,8 @@ class PetApi(object):
- if ('petId' in params):
- replacement = str(self.apiClient.toPathValue(params['petId']))
+ if ('pet_id' in params):
+ replacement = str(self.apiClient.toPathValue(params['pet_id']))
replacement = urllib.quote(replacement)
resourcePath = resourcePath.replace('{' + 'petId' + '}',
replacement)
@@ -337,7 +339,7 @@ class PetApi(object):
Args:
- petId, str: ID of pet that needs to be updated (required)
+ pet_id, str: ID of pet that needs to be updated (required)
name, str: Updated name of the pet (required)
@@ -350,7 +352,7 @@ class PetApi(object):
Returns:
"""
- allParams = ['petId', 'name', 'status']
+ allParams = ['pet_id', 'name', 'status']
params = locals()
for (key, val) in params['kwargs'].iteritems():
@@ -377,8 +379,8 @@ class PetApi(object):
- if ('petId' in params):
- replacement = str(self.apiClient.toPathValue(params['petId']))
+ if ('pet_id' in params):
+ replacement = str(self.apiClient.toPathValue(params['pet_id']))
replacement = urllib.quote(replacement)
resourcePath = resourcePath.replace('{' + 'petId' + '}',
replacement)
@@ -411,14 +413,14 @@ class PetApi(object):
api_key, str: (required)
- petId, long: Pet id to delete (required)
+ pet_id, long: Pet id to delete (required)
Returns:
"""
- allParams = ['api_key', 'petId']
+ allParams = ['api_key', 'pet_id']
params = locals()
for (key, val) in params['kwargs'].iteritems():
@@ -448,8 +450,8 @@ class PetApi(object):
- if ('petId' in params):
- replacement = str(self.apiClient.toPathValue(params['petId']))
+ if ('pet_id' in params):
+ replacement = str(self.apiClient.toPathValue(params['pet_id']))
replacement = urllib.quote(replacement)
resourcePath = resourcePath.replace('{' + 'petId' + '}',
replacement)
@@ -473,10 +475,10 @@ class PetApi(object):
Args:
- petId, long: ID of pet to update (required)
+ pet_id, long: ID of pet to update (required)
- additionalMetadata, str: Additional data to pass to server (required)
+ additional_metadata, str: Additional data to pass to server (required)
file, file: file to upload (required)
@@ -486,7 +488,7 @@ class PetApi(object):
Returns:
"""
- allParams = ['petId', 'additionalMetadata', 'file']
+ allParams = ['pet_id', 'additional_metadata', 'file']
params = locals()
for (key, val) in params['kwargs'].iteritems():
@@ -513,16 +515,16 @@ class PetApi(object):
- if ('petId' in params):
- replacement = str(self.apiClient.toPathValue(params['petId']))
+ if ('pet_id' in params):
+ replacement = str(self.apiClient.toPathValue(params['pet_id']))
replacement = urllib.quote(replacement)
resourcePath = resourcePath.replace('{' + 'petId' + '}',
replacement)
- if ('additionalMetadata' in params):
- formParams['additionalMetadata'] = params['additionalMetadata']
+ if ('additional_metadata' in params):
+ formParams['additionalMetadata'] = params['additional_metadata']
if ('file' in params):
files['file'] = params['file']
diff --git a/samples/client/petstore/python/client/StoreApi.py b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/store_api.py
similarity index 95%
rename from samples/client/petstore/python/client/StoreApi.py
rename to samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/store_api.py
index 5f7a1b37d7a3..a7befb9762c6 100644
--- a/samples/client/petstore/python/client/StoreApi.py
+++ b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/store_api.py
@@ -1,4 +1,6 @@
#!/usr/bin/env python
+# coding: utf-8
+
"""
StoreApi.py
Copyright 2015 Reverb Technologies, Inc.
@@ -154,14 +156,14 @@ class StoreApi(object):
Args:
- orderId, str: ID of pet that needs to be fetched (required)
+ order_id, str: ID of pet that needs to be fetched (required)
Returns: Order
"""
- allParams = ['orderId']
+ allParams = ['order_id']
params = locals()
for (key, val) in params['kwargs'].iteritems():
@@ -188,8 +190,8 @@ class StoreApi(object):
- if ('orderId' in params):
- replacement = str(self.apiClient.toPathValue(params['orderId']))
+ if ('order_id' in params):
+ replacement = str(self.apiClient.toPathValue(params['order_id']))
replacement = urllib.quote(replacement)
resourcePath = resourcePath.replace('{' + 'orderId' + '}',
replacement)
@@ -219,14 +221,14 @@ class StoreApi(object):
Args:
- orderId, str: ID of the order that needs to be deleted (required)
+ order_id, str: ID of the order that needs to be deleted (required)
Returns:
"""
- allParams = ['orderId']
+ allParams = ['order_id']
params = locals()
for (key, val) in params['kwargs'].iteritems():
@@ -253,8 +255,8 @@ class StoreApi(object):
- if ('orderId' in params):
- replacement = str(self.apiClient.toPathValue(params['orderId']))
+ if ('order_id' in params):
+ replacement = str(self.apiClient.toPathValue(params['order_id']))
replacement = urllib.quote(replacement)
resourcePath = resourcePath.replace('{' + 'orderId' + '}',
replacement)
diff --git a/samples/client/petstore/python/client/swagger.py b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/swagger.py
similarity index 99%
rename from samples/client/petstore/python/client/swagger.py
rename to samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/swagger.py
index d5e54666e011..018e92536c21 100644
--- a/samples/client/petstore/python/client/swagger.py
+++ b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/swagger.py
@@ -1,4 +1,6 @@
#!/usr/bin/env python
+# coding: utf-8
+
"""Swagger generic API client. This client handles the client-
server communication, and is invariant across implementations. Specifics of
the methods and models for each application are generated from the Swagger
diff --git a/samples/client/petstore/python/client/UserApi.py b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/user_api.py
similarity index 99%
rename from samples/client/petstore/python/client/UserApi.py
rename to samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/user_api.py
index 5b54b57f5b06..432df9bb1205 100644
--- a/samples/client/petstore/python/client/UserApi.py
+++ b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/user_api.py
@@ -1,4 +1,6 @@
#!/usr/bin/env python
+# coding: utf-8
+
"""
UserApi.py
Copyright 2015 Reverb Technologies, Inc.
diff --git a/samples/client/petstore/python/SwaggerPetstore-python/setup.py b/samples/client/petstore/python/SwaggerPetstore-python/setup.py
new file mode 100644
index 000000000000..14d6a73b3b14
--- /dev/null
+++ b/samples/client/petstore/python/SwaggerPetstore-python/setup.py
@@ -0,0 +1,32 @@
+import sys
+from setuptools import setup, find_packages
+
+
+
+# To install the library, open a Terminal shell, then run this
+# file by typing:
+#
+# python setup.py install
+#
+# You need to have the setuptools module installed.
+# Try reading the setuptools documentation:
+# http://pypi.python.org/pypi/setuptools
+
+REQUIRES = []
+
+setup(
+ name="SwaggerPetstore",
+ version="1.0.0",
+ description="Swagger Petstore",
+ author_email="apiteam@wordnik.com",
+ url="",
+ keywords=["Swagger", "Swagger Petstore"],
+ install_requires=REQUIRES,
+ packages=find_packages(),
+ include_package_data=True,
+ long_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
+ """
+)
+
+
diff --git a/samples/client/petstore/python/client/models/__init__.py b/samples/client/petstore/python/client/models/__init__.py
deleted file mode 100644
index 728aacbb9ab6..000000000000
--- a/samples/client/petstore/python/client/models/__init__.py
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/usr/bin/env python
-"""Add all of the modules in the current directory to __all__"""
-import os
-
-__all__ = []
-
-for module in os.listdir(os.path.dirname(__file__)):
- if module != '__init__.py' and module[-3:] == '.py':
- __all__.append(module[:-3])
diff --git a/samples/client/petstore/ruby/Gemfile.lock b/samples/client/petstore/ruby/Gemfile.lock
index 2fb537855008..232facf4677c 100644
--- a/samples/client/petstore/ruby/Gemfile.lock
+++ b/samples/client/petstore/ruby/Gemfile.lock
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
- swagger (4.06.08)
+ swagger-client (4.06.08)
addressable (>= 2.2.4)
json (>= 1.4.6)
typhoeus (>= 0.2.1)
@@ -56,6 +56,6 @@ DEPENDENCIES
autotest-growl
autotest-rails-pure
rspec (>= 2.5.0)
- swagger!
+ swagger-client!
vcr (>= 1.5.1)
webmock (>= 1.6.2)
diff --git a/samples/client/petstore/ruby/README.md b/samples/client/petstore/ruby/README.md
new file mode 100644
index 000000000000..29a7ce844ce6
--- /dev/null
+++ b/samples/client/petstore/ruby/README.md
@@ -0,0 +1,57 @@
+## Installation
+
+### Build a gem
+
+You can build the generated client into a gem:
+
+```shell
+gem build swagger-client.gemspec
+```
+
+Then you can either install the gem:
+
+```shell
+gem install ./swagger-client-4.06.08.gem
+```
+
+or publish the gem to a gem server like [RubyGems](https://rubygems.org/).
+
+Finally add this to your Gemfile:
+
+ gem 'swagger-client', '~> 4.06.08'
+
+### Host as a git repository
+
+You can also choose to host the generated client as a git repository, e.g. on github:
+https://github.com/xhh/swagger-petstore-ruby
+
+Then you can reference it in Gemfile:
+
+ gem 'swagger-client', :git => 'https://github.com/xhh/swagger-petstore-ruby.git'
+
+### Use without installation
+
+You can also use the client directly like this:
+
+```shell
+ruby -Ilib script.rb
+```
+
+## Configuration
+
+```ruby
+require 'swagger-client'
+
+Swagger.configure do |config|
+ config.api_key = 'special-key'
+ config.host = 'petstore.swagger.io'
+ config.base_path = '/v2'
+end
+```
+
+## Getting Started
+
+```ruby
+pet = PetApi.getPetById(5)
+puts pet.to_body
+```
diff --git a/samples/client/petstore/ruby/lib/swagger-client.rb b/samples/client/petstore/ruby/lib/swagger-client.rb
new file mode 100644
index 000000000000..b13f83b1dbcf
--- /dev/null
+++ b/samples/client/petstore/ruby/lib/swagger-client.rb
@@ -0,0 +1,5 @@
+require 'monkey'
+require 'swagger'
+
+Dir[File.join(File.dirname(__FILE__), "../lib/*.rb")].each {|file| require file if file !~ /swagger-client\.rb\z/ }
+Dir[File.join(File.dirname(__FILE__), "../models/*.rb")].each {|file| require file }
diff --git a/samples/client/petstore/ruby/spec/pet_spec.rb b/samples/client/petstore/ruby/spec/pet_spec.rb
index 2a715f8b8eb7..0ea0a5dcd32b 100644
--- a/samples/client/petstore/ruby/spec/pet_spec.rb
+++ b/samples/client/petstore/ruby/spec/pet_spec.rb
@@ -12,8 +12,9 @@ describe "Pet" do
describe "pet methods" do
it "should fetch a pet object" do
pet = PetApi.getPetById(5)
+ pet.should be_a(Pet)
pet.id.should == 5
- pet.name.should == "Dog 2"
+ pet.name.should == "panda"
end
it "should find pets by status" do
@@ -22,7 +23,7 @@ describe "Pet" do
end
it "should not find a pet with invalid status" do
- pets = PetApi.findPetsByStatus('dead')
+ pets = PetApi.findPetsByStatus('invalid-status')
pets.length.should == 0
end
diff --git a/samples/client/petstore/ruby/spec/spec_helper.rb b/samples/client/petstore/ruby/spec/spec_helper.rb
index dbdcdeda5792..f5ea626e9b8d 100644
--- a/samples/client/petstore/ruby/spec/spec_helper.rb
+++ b/samples/client/petstore/ruby/spec/spec_helper.rb
@@ -1,17 +1,12 @@
require 'rubygems'
require 'bundler/setup'
-require 'monkey'
-require 'swagger'
+require 'swagger-client'
require 'vcr'
require 'typhoeus'
require 'json'
require 'yaml'
require 'rspec'
-Dir[File.join(File.dirname(__FILE__), "../lib/*.rb")].each {|file| require file }
-Dir[File.join(File.dirname(__FILE__), "../models/*.rb")].each {|file| require file }
-Dir[File.join(File.dirname(__FILE__), "../resources/*.rb")].each {|file| require file }
-
RSpec.configure do |config|
# some (optional) config here
config.expect_with :rspec do |c|
diff --git a/samples/client/petstore/ruby/swagger-client.gemspec b/samples/client/petstore/ruby/swagger-client.gemspec
new file mode 100644
index 000000000000..bbff5f95f6bc
--- /dev/null
+++ b/samples/client/petstore/ruby/swagger-client.gemspec
@@ -0,0 +1,33 @@
+# -*- encoding: utf-8 -*-
+$:.push File.expand_path("../lib", __FILE__)
+require "swagger/version"
+
+Gem::Specification.new do |s|
+ s.name = "swagger-client"
+ s.version = Swagger::VERSION
+ s.platform = Gem::Platform::RUBY
+ s.authors = ["Zeke Sikelianos", "Tony Tam"]
+ s.email = ["zeke@wordnik.com", "tony@wordnik.com"]
+ s.homepage = "http://developer.wordnik.com"
+ s.summary = %q{A ruby wrapper for the swagger APIs}
+ s.description = %q{This gem maps to a swagger API}
+
+ s.rubyforge_project = "swagger-client"
+
+ s.add_dependency 'typhoeus', '>=0.2.1'
+ s.add_dependency 'addressable', '>=2.2.4'
+ s.add_dependency 'json', '>=1.4.6'
+
+ s.add_development_dependency 'rspec', '>=2.5.0'
+ s.add_development_dependency 'vcr', '>=1.5.1'
+ s.add_development_dependency 'webmock', '>=1.6.2'
+ s.add_development_dependency 'autotest'
+ s.add_development_dependency 'autotest-rails-pure'
+ s.add_development_dependency 'autotest-growl'
+ s.add_development_dependency 'autotest-fsevent'
+
+ s.files = `find *`.split("\n").uniq.sort.select{|f| !f.empty? }
+ s.test_files = `find spec/*`.split("\n")
+ s.executables = []
+ s.require_paths = ["lib"]
+end