Merge branch 'develop_2.0' into develop_2.0_python_better_import

Conflicts:
	modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/PythonClientCodegen.java
This commit is contained in:
geekerzp 2015-04-09 09:31:50 +08:00
commit 806c26d54f
28 changed files with 403 additions and 161 deletions

View File

@ -18,7 +18,7 @@ The Swagger Specification has undergone 3 revisions since initial creation in 20
Swagger Codegen Version | Release Date | Swagger Spec compatibility | Notes
----------------------- | ------------ | -------------------------- | -----
1.5.0-M2 | 2015-04-06 | 1.0, 1.1, 1.2, 2.0 | [master](https://github.com/swagger-api/swagger-codegen)
2.1.1-M2-SNAPSHOT | 2015-04-06 | 1.0, 1.1, 1.2, 2.0 | [master](https://github.com/swagger-api/swagger-codegen)
2.0.17 | 2014-08-22 | 1.1, 1.2 | [tag v2.0.17](https://github.com/swagger-api/swagger-codegen/tree/v2.0.17)
1.0.4 | 2012-04-12 | 1.0, 1.1 | [tag v1.0.4](https://github.com/swagger-api/swagger-codegen/tree/swagger-codegen_2.9.1-1.1)

View File

@ -3,7 +3,7 @@
<parent>
<groupId>com.wordnik</groupId>
<artifactId>swagger-codegen-project</artifactId>
<version>1.5.0-M2</version>
<version>2.1.1-M2-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -2,7 +2,7 @@
<parent>
<groupId>com.wordnik</groupId>
<artifactId>swagger-codegen-project</artifactId>
<version>1.5.0-M2</version>
<version>2.1.1-M2-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -10,7 +10,7 @@
<artifactId>swagger-codegen</artifactId>
<packaging>jar</packaging>
<name>swagger-codegen (core library)</name>
<version>1.5.0-M2</version>
<version>2.1.1-M2-SNAPSHOT</version>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<defaultGoal>install</defaultGoal>

View File

@ -114,4 +114,71 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
// 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";
}
}

View File

@ -129,7 +129,7 @@
</repository>
</repositories>
<properties>
<swagger-core-version>1.5.0-M2</swagger-core-version>
<swagger-core-version>2.1.1-M2-SNAPSHOT</swagger-core-version>
<jetty-version>9.2.9.v20150224</jetty-version>
<jersey-version>1.13</jersey-version>
<slf4j-version>1.6.3</slf4j-version>

View File

@ -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');
}
// Make the request
$response = curl_exec($curl);

View File

@ -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 HTTP post (form)
$body = $body ?: $formParams;
// for model (json/xml)
if (isset($body)) {
$httpBody = $body; // $body is the method argument, if present
}
// for HTTP post (form)
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) {

View File

@ -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}}

View File

@ -1,4 +1,6 @@
#!/usr/bin/env python
# coding: utf-8
"""
Copyright 2015 Reverb Technologies, Inc.

View File

@ -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

View File

@ -3,14 +3,14 @@
<parent>
<groupId>com.wordnik</groupId>
<artifactId>swagger-codegen-project</artifactId>
<version>1.5.0-M2</version>
<version>2.1.1-M2-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
<groupId>com.wordnik</groupId>
<artifactId>swagger-generator</artifactId>
<packaging>war</packaging>
<name>swagger-generator</name>
<version>1.5.0-M2</version>
<version>2.1.1-M2-SNAPSHOT</version>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<plugins>

View File

@ -9,7 +9,7 @@
<artifactId>swagger-codegen-project</artifactId>
<packaging>pom</packaging>
<name>swagger-codegen-project</name>
<version>1.5.0-M2</version>
<version>2.1.1-M2-SNAPSHOT</version>
<url>https://github.com/swagger-api/swagger-codegen</url>
<scm>
<connection>scm:git:git@github.com:swagger-api/swagger-codegen.git</connection>

View File

@ -0,0 +1,52 @@
## Requirements
PHP 5.3.3 and later.
## Composer
You can install the bindings via [Composer](http://getcomposer.org/). Add this to your `composer.json`:
{
"repositories": [
{
"type": "git",
"url": "https://github.com/wing328/SwaggerPetstore-php.git"
}
],
"require": {
"SwaggerPetstore/SwaggerPetstore-php": "*@dev"
}
}
Then install via:
composer install
To use the bindings, use Composer's [autoload](https://getcomposer.org/doc/00-intro.md#autoloading):
require_once('vendor/autoload.php');
## Manual Installation
If you do not wish to use Composer, you can download the latest release. Then, to use the bindings, include the `SwaggerPetstore.php` file.
require_once('/path/to/SwaggerPetstore-php/SwaggerPetstore.php');
## Getting Started
php test.php
## Documentation
TODO
## Tests
In order to run tests first install [PHPUnit](http://packagist.org/packages/phpunit/phpunit) via [Composer](http://getcomposer.org/):
composer update
To run the test suite:
./vendor/bin/phpunit tests

View File

@ -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');
}
// Make the request
$response = curl_exec($curl);

View File

@ -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 HTTP post (form)
$body = $body ?: $formParams;
// for model (json/xml)
if (isset($body)) {
$httpBody = $body; // $body is the method argument, if present
}
// for HTTP post (form)
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 HTTP post (form)
$body = $body ?: $formParams;
// for model (json/xml)
if (isset($body)) {
$httpBody = $body; // $body is the method argument, if present
}
// for HTTP post (form)
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 HTTP post (form)
$body = $body ?: $formParams;
// for model (json/xml)
if (isset($body)) {
$httpBody = $body; // $body is the method argument, if present
}
// for HTTP post (form)
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 HTTP post (form)
$body = $body ?: $formParams;
// for model (json/xml)
if (isset($body)) {
$httpBody = $body; // $body is the method argument, if present
}
// for HTTP post (form)
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 HTTP post (form)
$body = $body ?: $formParams;
// for model (json/xml)
if (isset($body)) {
$httpBody = $body; // $body is the method argument, if present
}
// for HTTP post (form)
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 HTTP post (form)
$body = $body ?: $formParams;
// for model (json/xml)
if (isset($body)) {
$httpBody = $body; // $body is the method argument, if present
}
// for HTTP post (form)
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 HTTP post (form)
$body = $body ?: $formParams;
// for model (json/xml)
if (isset($body)) {
$httpBody = $body; // $body is the method argument, if present
}
// for HTTP post (form)
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 HTTP post (form)
$body = $body ?: $formParams;
// for model (json/xml)
if (isset($body)) {
$httpBody = $body; // $body is the method argument, if present
}
// for HTTP post (form)
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);

View File

@ -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 HTTP post (form)
$body = $body ?: $formParams;
// for model (json/xml)
if (isset($body)) {
$httpBody = $body; // $body is the method argument, if present
}
// for HTTP post (form)
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 HTTP post (form)
$body = $body ?: $formParams;
// for model (json/xml)
if (isset($body)) {
$httpBody = $body; // $body is the method argument, if present
}
// for HTTP post (form)
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 HTTP post (form)
$body = $body ?: $formParams;
// for model (json/xml)
if (isset($body)) {
$httpBody = $body; // $body is the method argument, if present
}
// for HTTP post (form)
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 HTTP post (form)
$body = $body ?: $formParams;
// for model (json/xml)
if (isset($body)) {
$httpBody = $body; // $body is the method argument, if present
}
// for HTTP post (form)
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);

View File

@ -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 HTTP post (form)
$body = $body ?: $formParams;
// for model (json/xml)
if (isset($body)) {
$httpBody = $body; // $body is the method argument, if present
}
// for HTTP post (form)
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 HTTP post (form)
$body = $body ?: $formParams;
// for model (json/xml)
if (isset($body)) {
$httpBody = $body; // $body is the method argument, if present
}
// for HTTP post (form)
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 HTTP post (form)
$body = $body ?: $formParams;
// for model (json/xml)
if (isset($body)) {
$httpBody = $body; // $body is the method argument, if present
}
// for HTTP post (form)
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 HTTP post (form)
$body = $body ?: $formParams;
// for model (json/xml)
if (isset($body)) {
$httpBody = $body; // $body is the method argument, if present
}
// for HTTP post (form)
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 HTTP post (form)
$body = $body ?: $formParams;
// for model (json/xml)
if (isset($body)) {
$httpBody = $body; // $body is the method argument, if present
}
// for HTTP post (form)
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 HTTP post (form)
$body = $body ?: $formParams;
// for model (json/xml)
if (isset($body)) {
$httpBody = $body; // $body is the method argument, if present
}
// for HTTP post (form)
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 HTTP post (form)
$body = $body ?: $formParams;
// for model (json/xml)
if (isset($body)) {
$httpBody = $body; // $body is the method argument, if present
}
// for HTTP post (form)
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 HTTP post (form)
$body = $body ?: $formParams;
// for model (json/xml)
if (isset($body)) {
$httpBody = $body; // $body is the method argument, if present
}
// for HTTP post (form)
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);

View File

@ -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.
*

View File

@ -0,0 +1,19 @@
<?php
require_once('SwaggerPetstore.php');
class PetApiTest extends \PHPUnit_Framework_TestCase
{
public function testGetPetById()
{
// initialize the API client
$api_client = new SwaggerPetstore\APIClient('http://petstore.swagger.io/v2');
$petId = 5; // ID of pet that needs to be fetched
$pet_api = new SwaggerPetstore\PetAPI($api_client);
// return Pet (model)
$response = $pet_api->getPetById($petId);
$this->assertSame($response->id, $petId);
}
}
?>

View File

@ -31,13 +31,13 @@ class Order(object):
'id': 'long',
'petId': 'long',
'pet_id': 'long',
'quantity': 'int',
'shipDate': 'DateTime',
'ship_date': 'DateTime',
'status': 'str',
@ -51,11 +51,11 @@ class Order(object):
'id': 'id',
'petId': 'petId',
'pet_id': 'petId',
'quantity': 'quantity',
'shipDate': 'shipDate',
'ship_date': 'shipDate',
'status': 'status',
@ -68,13 +68,13 @@ class Order(object):
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

View File

@ -37,7 +37,7 @@ class Pet(object):
'name': 'str',
'photoUrls': 'list[str]',
'photo_urls': 'list[str]',
'tags': 'list[Tag]',
@ -55,7 +55,7 @@ class Pet(object):
'name': 'name',
'photoUrls': 'photoUrls',
'photo_urls': 'photoUrls',
'tags': 'tags',
@ -74,7 +74,7 @@ class Pet(object):
self.name = None # str
self.photoUrls = None # list[str]
self.photo_urls = None # list[str]
self.tags = None # list[Tag]

View File

@ -34,10 +34,10 @@ class User(object):
'username': 'str',
'firstName': 'str',
'first_name': 'str',
'lastName': 'str',
'last_name': 'str',
'email': 'str',
@ -49,7 +49,7 @@ class User(object):
'phone': 'str',
'userStatus': 'int'
'user_status': 'int'
}
@ -59,9 +59,9 @@ class User(object):
'username': 'username',
'firstName': 'firstName',
'first_name': 'firstName',
'lastName': 'lastName',
'last_name': 'lastName',
'email': 'email',
@ -69,7 +69,7 @@ class User(object):
'phone': 'phone',
'userStatus': 'userStatus'
'user_status': 'userStatus'
}
@ -81,10 +81,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 +97,5 @@ class User(object):
#User Status
self.userStatus = None # int
self.user_status = None # int

View File

@ -272,14 +272,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 +306,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 +337,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 +350,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 +377,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 +411,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 +448,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 +473,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 +486,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 +513,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']

View File

@ -154,14 +154,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 +188,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 +219,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 +253,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)

View File

@ -129,7 +129,7 @@
</repository>
</repositories>
<properties>
<swagger-core-version>1.5.0-M2</swagger-core-version>
<swagger-core-version>2.1.1-M2-SNAPSHOT</swagger-core-version>
<jetty-version>9.2.9.v20150224</jetty-version>
<jersey-version>1.13</jersey-version>
<slf4j-version>1.6.3</slf4j-version>