[python] Add packageUrl option, replacing infoUrl in setup.py (#4101)

* [python] Add packageUrl option, replacing infoUrl in setup.py .

* [python] Regenerate Python petstore sample.

* [python] Regenerate Python petstore security test sample.
This commit is contained in:
Cliffano Subagio
2016-11-01 21:21:53 +11:00
committed by wing328
parent 0c1b1aa749
commit 5c53513a30
16 changed files with 221 additions and 169 deletions

View File

@@ -21,8 +21,11 @@ import java.util.Map;
import org.apache.commons.lang3.StringUtils;
public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig {
public static final String PACKAGE_URL = "packageUrl";
protected String packageName;
protected String packageVersion;
protected String packageUrl;
protected String apiDocPath = "docs/";
protected String modelDocPath = "docs/";
@@ -112,6 +115,7 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
.defaultValue("swagger_client"));
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_VERSION, "python package version.")
.defaultValue("1.0.0"));
cliOptions.add(new CliOption(PACKAGE_URL, "python package URL."));
cliOptions.add(CliOption.newBoolean(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG,
CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG_DESC).defaultValue(Boolean.TRUE.toString()));
cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, "hides the timestamp when files were generated")
@@ -156,6 +160,10 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
additionalProperties.put("apiDocPath", apiDocPath);
additionalProperties.put("modelDocPath", modelDocPath);
if (additionalProperties.containsKey(PACKAGE_URL)) {
setPackageUrl((String) additionalProperties.get(PACKAGE_URL));
}
String swaggerFolder = packageName;
modelPackage = swaggerFolder + File.separatorChar + "models";
@@ -480,6 +488,10 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
this.packageVersion = packageVersion;
}
public void setPackageUrl(String packageUrl) {
this.packageUrl = packageUrl;
}
/**
* Generate Python package name from String `packageName`
*

View File

@@ -22,7 +22,7 @@ setup(
version=VERSION,
description="{{appName}}",
author_email="{{infoEmail}}",
url="{{infoUrl}}",
url="{{packageUrl}}",
keywords=["Swagger", "{{appName}}"],
install_requires=REQUIRES,
packages=find_packages(),

View File

@@ -1,6 +1,7 @@
package io.swagger.codegen.options;
import io.swagger.codegen.CodegenConstants;
import io.swagger.codegen.languages.PythonClientCodegen;
import com.google.common.collect.ImmutableMap;
@@ -9,6 +10,7 @@ import java.util.Map;
public class PythonClientOptionsProvider implements OptionsProvider {
public static final String PACKAGE_NAME_VALUE = "swagger_client_python";
public static final String PACKAGE_VERSION_VALUE = "1.0.0-SNAPSHOT";
public static final String PACKAGE_URL_VALUE = "";
@Override
public String getLanguage() {
@@ -18,7 +20,8 @@ public class PythonClientOptionsProvider implements OptionsProvider {
@Override
public Map<String, String> createOptions() {
ImmutableMap.Builder<String, String> builder = new ImmutableMap.Builder<String, String>();
return builder.put(CodegenConstants.PACKAGE_NAME, PACKAGE_NAME_VALUE)
return builder.put(PythonClientCodegen.PACKAGE_URL, PACKAGE_URL_VALUE)
.put(CodegenConstants.PACKAGE_NAME, PACKAGE_NAME_VALUE)
.put(CodegenConstants.PACKAGE_VERSION, PACKAGE_VERSION_VALUE)
.put(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, "true")
.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, "true")

View File

@@ -30,6 +30,8 @@ public class PythonClientOptionsTest extends AbstractOptionsTest {
times = 1;
clientCodegen.setPackageVersion(PythonClientOptionsProvider.PACKAGE_VERSION_VALUE);
times = 1;
clientCodegen.setPackageUrl(PythonClientOptionsProvider.PACKAGE_URL_VALUE);
times = 1;
}};
}
}

View File

@@ -1,11 +1,10 @@
# petstore_api
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =end
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =end --
This Python package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
- API version: 1.0.0 */ &#39; \&quot; &#x3D;end
- API version: 1.0.0 */ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r
- Package version: 1.0.0
- Build date: 2016-06-28T16:59:35.203+08:00
- Build package: class io.swagger.codegen.languages.PythonClientCodegen
## Requirements.
@@ -46,29 +45,30 @@ import petstore_api
Please follow the [installation procedure](#installation--usage) and then run the following:
```python
from __future__ import print_function
import time
import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# create an instance of the API class
api_instance = petstore_api.FakeApi
test_code_inject____end = 'test_code_inject____end_example' # str | To test code injection */ ' \" =end (optional)
api_instance = petstore_api.FakeApi()
test_code_inject____end____rn_n_r = 'test_code_inject____end____rn_n_r_example' # str | To test code injection */ ' \" =end -- \\r\\n \\n \\r (optional)
try:
# To test code injection */ ' \" =end
api_instance.test_code_inject____end(test_code_inject____end=test_code_inject____end)
# To test code injection */ ' \" =end -- \\r\\n \\n \\r
api_instance.test_code_inject____end__rn_n_r(test_code_inject____end____rn_n_r=test_code_inject____end____rn_n_r)
except ApiException as e:
print "Exception when calling FakeApi->test_code_inject____end: %s\n" % e
print("Exception when calling FakeApi->test_code_inject____end__rn_n_r: %s\n" % e)
```
## Documentation for API Endpoints
All URIs are relative to *https://petstore.swagger.io */ &#39; &quot; &#x3D;end/v2 */ &#39; &quot; &#x3D;end*
All URIs are relative to *https://petstore.swagger.io */ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r/v2 */ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*FakeApi* | [**test_code_inject____end**](docs/FakeApi.md#test_code_inject____end) | **PUT** /fake | To test code injection */ &#39; \&quot; &#x3D;end
*FakeApi* | [**test_code_inject____end__rn_n_r**](docs/FakeApi.md#test_code_inject____end__rn_n_r) | **PUT** /fake | To test code injection */ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r
## Documentation For Models
@@ -82,7 +82,7 @@ Class | Method | HTTP request | Description
## api_key
- **Type**: API key
- **API key parameter name**: api_key */ ' " =end
- **API key parameter name**: api_key */ ' " =end -- \r\n \n \r
- **Location**: HTTP header
## petstore_auth
@@ -91,11 +91,11 @@ Class | Method | HTTP request | Description
- **Flow**: implicit
- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog
- **Scopes**:
- **write:pets**: modify pets in your account */ ' " =end
- **read:pets**: read your pets */ ' " =end
- **write:pets**: modify pets in your account */ ' \" =end -- \\r\\n \\n \\r
- **read:pets**: read your pets */ ' \" =end -- \\r\\n \\n \\r
## Author
apiteam@swagger.io */ &#39; \&quot; &#x3D;end
apiteam@swagger.io */ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r

View File

@@ -1,19 +1,20 @@
# petstore_api.FakeApi
All URIs are relative to *https://petstore.swagger.io */ &#39; &quot; &#x3D;end/v2 */ &#39; &quot; &#x3D;end*
All URIs are relative to *https://petstore.swagger.io */ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r/v2 */ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r*
Method | HTTP request | Description
------------- | ------------- | -------------
[**test_code_inject____end**](FakeApi.md#test_code_inject____end) | **PUT** /fake | To test code injection */ &#39; \&quot; &#x3D;end
[**test_code_inject____end__rn_n_r**](FakeApi.md#test_code_inject____end__rn_n_r) | **PUT** /fake | To test code injection */ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r
# **test_code_inject____end**
> test_code_inject____end(test_code_inject____end=test_code_inject____end)
# **test_code_inject____end__rn_n_r**
> test_code_inject____end__rn_n_r(test_code_inject____end____rn_n_r=test_code_inject____end____rn_n_r)
To test code injection */ ' \" =end
To test code injection */ ' \" =end -- \\r\\n \\n \\r
### Example
```python
from __future__ import print_statement
import time
import petstore_api
from petstore_api.rest import ApiException
@@ -21,20 +22,20 @@ from pprint import pprint
# create an instance of the API class
api_instance = petstore_api.FakeApi()
test_code_inject____end = 'test_code_inject____end_example' # str | To test code injection */ ' \" =end (optional)
test_code_inject____end____rn_n_r = 'test_code_inject____end____rn_n_r_example' # str | To test code injection */ ' \" =end -- \\r\\n \\n \\r (optional)
try:
# To test code injection */ ' \" =end
api_instance.test_code_inject____end(test_code_inject____end=test_code_inject____end)
# To test code injection */ ' \" =end -- \\r\\n \\n \\r
api_instance.test_code_inject____end__rn_n_r(test_code_inject____end____rn_n_r=test_code_inject____end____rn_n_r)
except ApiException as e:
print "Exception when calling FakeApi->test_code_inject____end: %s\n" % e
print("Exception when calling FakeApi->test_code_inject____end__rn_n_r: %s\n" % e)
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**test_code_inject____end** | **str**| To test code injection */ &#39; \&quot; &#x3D;end | [optional]
**test_code_inject____end____rn_n_r** | **str**| To test code injection */ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r | [optional]
### Return type
@@ -46,8 +47,8 @@ No authorization required
### HTTP request headers
- **Content-Type**: application/json, */ " =end
- **Accept**: application/json, */ " =end
- **Content-Type**: application/json, */ \" =end --
- **Accept**: application/json, */ \" =end --
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

View File

@@ -3,7 +3,7 @@
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**_return** | **int** | property description */ &#39; \&quot; &#x3D;end | [optional]
**_return** | **int** | property description */ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -1,12 +1,12 @@
# coding: utf-8
"""
Swagger Petstore */ ' \" =end
Swagger Petstore */ ' \" =end -- \\r\\n \\n \\r
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =end
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =end --
OpenAPI spec version: 1.0.0 */ ' \" =end
Contact: apiteam@swagger.io */ ' \" =end
OpenAPI spec version: 1.0.0 */ ' \" =end -- \\r\\n \\n \\r
Contact: apiteam@swagger.io */ ' \" =end -- \\r\\n \\n \\r
Generated by: https://github.com/swagger-api/swagger-codegen.git
Licensed under the Apache License, Version 2.0 (the "License");

View File

@@ -19,17 +19,15 @@ Copyright 2016 SmartBear Software
"""
from __future__ import absolute_import
from . import models
from .rest import RESTClientObject
from .rest import ApiException
import os
import re
import sys
import urllib
import json
import mimetypes
import random
import tempfile
import threading
@@ -37,14 +35,8 @@ from datetime import datetime
from datetime import date
# python 2 and python 3 compatibility library
from six import iteritems
try:
# for python3
from urllib.parse import quote
except ImportError:
# for python2
from urllib import quote
from six import PY3, integer_types, iteritems, text_type
from six.moves.urllib.parse import quote
from .configuration import Configuration
@@ -103,34 +95,40 @@ class ApiClient(object):
def __call_api(self, resource_path, method,
path_params=None, query_params=None, header_params=None,
body=None, post_params=None, files=None,
response_type=None, auth_settings=None, callback=None, _return_http_data_only=None):
response_type=None, auth_settings=None, callback=None,
_return_http_data_only=None, collection_formats=None):
# headers parameters
# header parameters
header_params = header_params or {}
header_params.update(self.default_headers)
if self.cookie:
header_params['Cookie'] = self.cookie
if header_params:
header_params = self.sanitize_for_serialization(header_params)
header_params = dict(self.parameters_to_tuples(header_params,
collection_formats))
# path parameters
if path_params:
path_params = self.sanitize_for_serialization(path_params)
for k, v in iteritems(path_params):
replacement = quote(str(self.to_path_value(v)))
resource_path = resource_path.\
replace('{' + k + '}', replacement)
path_params = self.parameters_to_tuples(path_params,
collection_formats)
for k, v in path_params:
resource_path = resource_path.replace(
'{%s}' % k, quote(str(v)))
# query parameters
if query_params:
query_params = self.sanitize_for_serialization(query_params)
query_params = {k: self.to_path_value(v)
for k, v in iteritems(query_params)}
query_params = self.parameters_to_tuples(query_params,
collection_formats)
# post parameters
if post_params or files:
post_params = self.prepare_post_parameters(post_params, files)
post_params = self.sanitize_for_serialization(post_params)
post_params = self.parameters_to_tuples(post_params,
collection_formats)
# auth setting
self.update_params_for_auth(header_params, query_params, auth_settings)
@@ -159,31 +157,16 @@ class ApiClient(object):
if callback:
callback(deserialized_data) if _return_http_data_only else callback((deserialized_data, response_data.status, response_data.getheaders()))
elif _return_http_data_only:
return ( deserialized_data );
return (deserialized_data)
else:
return (deserialized_data, response_data.status, response_data.getheaders())
def to_path_value(self, obj):
"""
Takes value and turn it into a string suitable for inclusion in
the path, by url-encoding.
:param obj: object or string value.
:return string: quoted value.
"""
if type(obj) == list:
return ','.join(obj)
else:
return str(obj)
def sanitize_for_serialization(self, obj):
"""
Builds a JSON POST object.
If obj is None, return None.
If obj is str, int, float, bool, return directly.
If obj is str, int, long, float, bool, return directly.
If obj is datetime.datetime, datetime.date
convert to string in iso8601 format.
If obj is list, sanitize each element in the list.
@@ -193,9 +176,7 @@ class ApiClient(object):
:param obj: The data to serialize.
:return: The serialized form of data.
"""
types = (str, int, float, bool, tuple)
if sys.version_info < (3, 0):
types = types + (unicode,)
types = (str, float, bool, bytes) + tuple(integer_types) + (text_type,)
if isinstance(obj, type(None)):
return None
elif isinstance(obj, types):
@@ -203,6 +184,9 @@ class ApiClient(object):
elif isinstance(obj, list):
return [self.sanitize_for_serialization(sub_obj)
for sub_obj in obj]
elif isinstance(obj, tuple):
return tuple(self.sanitize_for_serialization(sub_obj)
for sub_obj in obj)
elif isinstance(obj, (datetime, date)):
return obj.isoformat()
else:
@@ -227,7 +211,7 @@ class ApiClient(object):
:param response: RESTResponse object to be deserialized.
:param response_type: class literal for
deserialzied object, or string of class name.
deserialized object, or string of class name.
:return: deserialized object.
"""
@@ -272,11 +256,13 @@ class ApiClient(object):
if klass in ['int', 'float', 'str', 'bool',
"date", 'datetime', "object"]:
klass = eval(klass)
elif klass == 'long':
klass = int if PY3 else long
# for model types
else:
klass = eval('models.' + klass)
if klass in [int, float, str, bool]:
if klass in integer_types or klass in (float, str, bool):
return self.__deserialize_primitive(data, klass)
elif klass == object:
return self.__deserialize_object(data)
@@ -290,7 +276,8 @@ class ApiClient(object):
def call_api(self, resource_path, method,
path_params=None, query_params=None, header_params=None,
body=None, post_params=None, files=None,
response_type=None, auth_settings=None, callback=None, _return_http_data_only=None):
response_type=None, auth_settings=None, callback=None,
_return_http_data_only=None, collection_formats=None):
"""
Makes the HTTP request (synchronous) and return the deserialized data.
To make an async request, define a function for callback.
@@ -312,6 +299,8 @@ class ApiClient(object):
If provide this parameter,
the request will be called asynchronously.
:param _return_http_data_only: response data without head status code and headers
:param collection_formats: dict of collection formats for path, query,
header, and post parameters.
:return:
If provide parameter callback,
the request will be called asynchronously.
@@ -323,7 +312,8 @@ class ApiClient(object):
return self.__call_api(resource_path, method,
path_params, query_params, header_params,
body, post_params, files,
response_type, auth_settings, callback, _return_http_data_only)
response_type, auth_settings, callback,
_return_http_data_only, collection_formats)
else:
thread = threading.Thread(target=self.__call_api,
args=(resource_path, method,
@@ -331,7 +321,8 @@ class ApiClient(object):
header_params, body,
post_params, files,
response_type, auth_settings,
callback,_return_http_data_only))
callback, _return_http_data_only,
collection_formats))
thread.start()
return thread
@@ -379,10 +370,41 @@ class ApiClient(object):
body=body)
else:
raise ValueError(
"http method must be `GET`, `HEAD`,"
"http method must be `GET`, `HEAD`, `OPTIONS`,"
" `POST`, `PATCH`, `PUT` or `DELETE`."
)
def parameters_to_tuples(self, params, collection_formats):
"""
Get parameters as list of tuples, formatting collections.
:param params: Parameters as dict or list of two-tuples
:param dict collection_formats: Parameter collection formats
:return: Parameters as list of tuples, collections formatted
"""
new_params = []
if collection_formats is None:
collection_formats = {}
for k, v in iteritems(params) if isinstance(params, dict) else params:
if k in collection_formats:
collection_format = collection_formats[k]
if collection_format == 'multi':
new_params.extend((k, value) for value in v)
else:
if collection_format == 'ssv':
delimiter = ' '
elif collection_format == 'tsv':
delimiter = '\t'
elif collection_format == 'pipes':
delimiter = '|'
else: # csv is the default
delimiter = ','
new_params.append(
(k, delimiter.join(str(value) for value in v)))
else:
new_params.append((k, v))
return new_params
def prepare_post_parameters(self, post_params=None, files=None):
"""
Builds form parameters.
@@ -450,7 +472,7 @@ class ApiClient(object):
Updates header and query params based on authentication setting.
:param headers: Header parameters dict to be updated.
:param querys: Query parameters dict to be updated.
:param querys: Query parameters tuple list to be updated.
:param auth_settings: Authentication setting identifiers list.
"""
config = Configuration()
@@ -466,7 +488,7 @@ class ApiClient(object):
elif auth_setting['in'] == 'header':
headers[auth_setting['key']] = auth_setting['value']
elif auth_setting['in'] == 'query':
querys[auth_setting['key']] = auth_setting['value']
querys.append((auth_setting['key'], auth_setting['value']))
else:
raise ValueError(
'Authentication token must be in `query` or `header`'
@@ -505,7 +527,7 @@ class ApiClient(object):
:param data: str.
:param klass: class literal.
:return: int, float, str, bool.
:return: int, long, float, str, bool.
"""
try:
value = klass(data)
@@ -573,6 +595,9 @@ class ApiClient(object):
"""
instance = klass()
if not instance.swagger_types:
return data
for attr, attr_type in iteritems(instance.swagger_types):
if data is not None \
and instance.attribute_map[attr] in data\

View File

@@ -1,12 +1,12 @@
# coding: utf-8
"""
Swagger Petstore */ ' \" =end
Swagger Petstore */ ' \" =end -- \\r\\n \\n \\r
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =end
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =end --
OpenAPI spec version: 1.0.0 */ ' \" =end
Contact: apiteam@swagger.io */ ' \" =end
OpenAPI spec version: 1.0.0 */ ' \" =end -- \\r\\n \\n \\r
Contact: apiteam@swagger.io */ ' \" =end -- \\r\\n \\n \\r
Generated by: https://github.com/swagger-api/swagger-codegen.git
Licensed under the Apache License, Version 2.0 (the "License");
@@ -51,9 +51,9 @@ class FakeApi(object):
config.api_client = ApiClient()
self.api_client = config.api_client
def test_code_inject____end(self, **kwargs):
def test_code_inject____end__rn_n_r(self, **kwargs):
"""
To test code injection */ ' \" =end
To test code injection */ ' \" =end -- \\r\\n \\n \\r
This method makes a synchronous HTTP request by default. To make an
@@ -62,25 +62,25 @@ class FakeApi(object):
>>> def callback_function(response):
>>> pprint(response)
>>>
>>> thread = api.test_code_inject____end(callback=callback_function)
>>> thread = api.test_code_inject____end__rn_n_r(callback=callback_function)
:param callback function: The callback function
for asynchronous request. (optional)
:param str test_code_inject____end: To test code injection */ ' \" =end
:param str test_code_inject____end____rn_n_r: To test code injection */ ' \" =end -- \\r\\n \\n \\r
:return: None
If the method is called asynchronously,
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('callback'):
return self.test_code_inject____end_with_http_info(**kwargs)
return self.test_code_inject____end__rn_n_r_with_http_info(**kwargs)
else:
(data) = self.test_code_inject____end_with_http_info(**kwargs)
(data) = self.test_code_inject____end__rn_n_r_with_http_info(**kwargs)
return data
def test_code_inject____end_with_http_info(self, **kwargs):
def test_code_inject____end__rn_n_r_with_http_info(self, **kwargs):
"""
To test code injection */ ' \" =end
To test code injection */ ' \" =end -- \\r\\n \\n \\r
This method makes a synchronous HTTP request by default. To make an
@@ -89,17 +89,17 @@ class FakeApi(object):
>>> def callback_function(response):
>>> pprint(response)
>>>
>>> thread = api.test_code_inject____end_with_http_info(callback=callback_function)
>>> thread = api.test_code_inject____end__rn_n_r_with_http_info(callback=callback_function)
:param callback function: The callback function
for asynchronous request. (optional)
:param str test_code_inject____end: To test code injection */ ' \" =end
:param str test_code_inject____end____rn_n_r: To test code injection */ ' \" =end -- \\r\\n \\n \\r
:return: None
If the method is called asynchronously,
returns the request thread.
"""
all_params = ['test_code_inject____end']
all_params = ['test_code_inject____end____rn_n_r']
all_params.append('callback')
all_params.append('_return_http_data_only')
@@ -108,11 +108,14 @@ class FakeApi(object):
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
" to method test_code_inject____end" % key
" to method test_code_inject____end__rn_n_r" % key
)
params[key] = val
del params['kwargs']
collection_formats = {}
resource_path = '/fake'.replace('{format}', 'json')
path_params = {}
@@ -122,20 +125,20 @@ class FakeApi(object):
form_params = []
local_var_files = {}
if 'test_code_inject____end' in params:
form_params.append(('test code inject */ &#39; &quot; &#x3D;end', params['test_code_inject____end']))
if 'test_code_inject____end____rn_n_r' in params:
form_params.append(('test code inject */ &#39; &quot; &#x3D;end -- \r\n \n \r', params['test_code_inject____end____rn_n_r']))
body_params = None
# HTTP header `Accept`
header_params['Accept'] = self.api_client.\
select_header_accept(['application/json', '*/ " =end'])
select_header_accept(['application/json', '*/ \" =end -- '])
if not header_params['Accept']:
del header_params['Accept']
# HTTP header `Content-Type`
header_params['Content-Type'] = self.api_client.\
select_header_content_type(['application/json', '*/ " =end'])
select_header_content_type(['application/json', '*/ \" =end -- '])
# Authentication setting
auth_settings = []
@@ -150,4 +153,5 @@ class FakeApi(object):
response_type=None,
auth_settings=auth_settings,
callback=params.get('callback'),
_return_http_data_only=params.get('_return_http_data_only'))
_return_http_data_only=params.get('_return_http_data_only'),
collection_formats=collection_formats)

View File

@@ -1,12 +1,12 @@
# coding: utf-8
"""
Swagger Petstore */ ' \" =end
Swagger Petstore */ ' \" =end -- \\r\\n \\n \\r
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =end
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =end --
OpenAPI spec version: 1.0.0 */ ' \" =end
Contact: apiteam@swagger.io */ ' \" =end
OpenAPI spec version: 1.0.0 */ ' \" =end -- \\r\\n \\n \\r
Contact: apiteam@swagger.io */ ' \" =end -- \\r\\n \\n \\r
Generated by: https://github.com/swagger-api/swagger-codegen.git
Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,19 +23,14 @@
"""
from __future__ import absolute_import
import base64
import urllib3
try:
import httplib
except ImportError:
# for python3
import http.client as httplib
import urllib3
import sys
import logging
from six import iteritems
from six.moves import http_client as httplib
def singleton(cls, *args, **kw):
@@ -61,7 +56,7 @@ class Configuration(object):
Constructor
"""
# Default Base url
self.host = "https://petstore.swagger.io */ &#39; &quot; &#x3D;end/v2 */ &#39; &quot; &#x3D;end"
self.host = "https://petstore.swagger.io */ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r/v2 */ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r"
# Default api client
self.api_client = None
# Temp file folder for downloading files
@@ -225,8 +220,8 @@ class Configuration(object):
{
'type': 'api_key',
'in': 'header',
'key': 'api_key */ &#39; &quot; &#x3D;end',
'value': self.get_api_key_with_prefix('api_key */ &#39; &quot; &#x3D;end')
'key': 'api_key */ &#39; &quot; &#x3D;end -- \r\n \n \r',
'value': self.get_api_key_with_prefix('api_key */ &#39; &quot; &#x3D;end -- \r\n \n \r')
},
'petstore_auth':
@@ -248,6 +243,6 @@ class Configuration(object):
return "Python SDK Debug Report:\n"\
"OS: {env}\n"\
"Python Version: {pyversion}\n"\
"Version of the API: 1.0.0 */ &#39; \&quot; &#x3D;end\n"\
"Version of the API: 1.0.0 */ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r\n"\
"SDK Package Version: 1.0.0".\
format(env=sys.platform, pyversion=sys.version)

View File

@@ -1,12 +1,12 @@
# coding: utf-8
"""
Swagger Petstore */ ' \" =end
Swagger Petstore */ ' \" =end -- \\r\\n \\n \\r
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =end
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =end --
OpenAPI spec version: 1.0.0 */ ' \" =end
Contact: apiteam@swagger.io */ ' \" =end
OpenAPI spec version: 1.0.0 */ ' \" =end -- \\r\\n \\n \\r
Contact: apiteam@swagger.io */ ' \" =end -- \\r\\n \\n \\r
Generated by: https://github.com/swagger-api/swagger-codegen.git
Licensed under the Apache License, Version 2.0 (the "License");

View File

@@ -1,12 +1,12 @@
# coding: utf-8
"""
Swagger Petstore */ ' \" =end
Swagger Petstore */ ' \" =end -- \\r\\n \\n \\r
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =end
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =end --
OpenAPI spec version: 1.0.0 */ ' \" =end
Contact: apiteam@swagger.io */ ' \" =end
OpenAPI spec version: 1.0.0 */ ' \" =end -- \\r\\n \\n \\r
Contact: apiteam@swagger.io */ ' \" =end -- \\r\\n \\n \\r
Generated by: https://github.com/swagger-api/swagger-codegen.git
Licensed under the Apache License, Version 2.0 (the "License");
@@ -51,11 +51,12 @@ class ModelReturn(object):
self.__return = _return
@property
def _return(self):
"""
Gets the _return of this ModelReturn.
property description */ ' \" =end
property description */ ' \" =end -- \\r\\n \\n \\r
:return: The _return of this ModelReturn.
:rtype: int
@@ -66,7 +67,7 @@ class ModelReturn(object):
def _return(self, _return):
"""
Sets the _return of this ModelReturn.
property description */ ' \" =end
property description */ ' \" =end -- \\r\\n \\n \\r
:param _return: The _return of this ModelReturn.
:type: int

View File

@@ -1,12 +1,12 @@
# coding: utf-8
"""
Swagger Petstore */ ' \" =end
Swagger Petstore */ ' \" =end -- \\r\\n \\n \\r
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =end
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =end --
OpenAPI spec version: 1.0.0 */ ' \" =end
Contact: apiteam@swagger.io */ ' \" =end
OpenAPI spec version: 1.0.0 */ ' \" =end -- \\r\\n \\n \\r
Contact: apiteam@swagger.io */ ' \" =end -- \\r\\n \\n \\r
Generated by: https://github.com/swagger-api/swagger-codegen.git
Licensed under the Apache License, Version 2.0 (the "License");
@@ -24,15 +24,16 @@
from __future__ import absolute_import
import sys
import io
import json
import ssl
import certifi
import logging
import re
# python 2 and python 3 compatibility library
from six import iteritems
from six import PY3
from six.moves.urllib.parse import urlencode
from .configuration import Configuration
@@ -41,13 +42,6 @@ try:
except ImportError:
raise ImportError('Swagger python client requires urllib3.')
try:
# for python3
from urllib.parse import urlencode
except ImportError:
# for python2
from urllib import urlencode
logger = logging.getLogger(__name__)
@@ -119,7 +113,7 @@ class RESTClientObject(object):
:param headers: http request headers
:param body: request json body, for `application/json`
:param post_params: request post parameters,
`application/x-www-form-urlencode`
`application/x-www-form-urlencoded`
and `multipart/form-data`
"""
method = method.upper()
@@ -141,19 +135,19 @@ class RESTClientObject(object):
if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']:
if query_params:
url += '?' + urlencode(query_params)
if headers['Content-Type'] == 'application/json':
if re.search('json', headers['Content-Type'], re.IGNORECASE):
request_body = None
if body:
request_body = json.dumps(body)
r = self.pool_manager.request(method, url,
body=request_body,
headers=headers)
if headers['Content-Type'] == 'application/x-www-form-urlencoded':
elif headers['Content-Type'] == 'application/x-www-form-urlencoded':
r = self.pool_manager.request(method, url,
fields=post_params,
encode_multipart=False,
headers=headers)
if headers['Content-Type'] == 'multipart/form-data':
elif headers['Content-Type'] == 'multipart/form-data':
# must del headers['Content-Type'], or the correct Content-Type
# which generated by urllib3 will be overwritten.
del headers['Content-Type']
@@ -161,6 +155,19 @@ class RESTClientObject(object):
fields=post_params,
encode_multipart=True,
headers=headers)
# Pass a `string` parameter directly in the body to support
# other content types than Json when `body` argument is provided
# in serialized form
elif isinstance(body, str):
request_body = body
r = self.pool_manager.request(method, url,
body=request_body,
headers=headers)
else:
# Cannot generate the request from given parameters
msg = """Cannot prepare a request message for provided arguments.
Please check that your arguments match declared content type."""
raise ApiException(status=0, reason=msg)
# For `GET`, `HEAD`
else:
r = self.pool_manager.request(method, url,
@@ -174,7 +181,7 @@ class RESTClientObject(object):
# In the python 3, the response.data is bytes.
# we need to decode it to string.
if sys.version_info > (3,):
if PY3:
r.data = r.data.decode('utf8')
# log response body

View File

@@ -1,12 +1,12 @@
# coding: utf-8
"""
Swagger Petstore */ ' \" =end
Swagger Petstore */ ' \" =end -- \\r\\n \\n \\r
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =end
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =end --
OpenAPI spec version: 1.0.0 */ ' \" =end
Contact: apiteam@swagger.io */ ' \" =end
OpenAPI spec version: 1.0.0 */ ' \" =end -- \\r\\n \\n \\r
Contact: apiteam@swagger.io */ ' \" =end -- \\r\\n \\n \\r
Generated by: https://github.com/swagger-api/swagger-codegen.git
Licensed under the Apache License, Version 2.0 (the "License");
@@ -40,14 +40,15 @@ REQUIRES = ["urllib3 >= 1.15", "six >= 1.10", "certifi", "python-dateutil"]
setup(
name=NAME,
version=VERSION,
description="Swagger Petstore */ &#39; \&quot; &#x3D;end",
author_email="apiteam@swagger.io */ &#39; \&quot; &#x3D;end",
description="Swagger Petstore */ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r",
author_email="apiteam@swagger.io */ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r",
url="",
keywords=["Swagger", "Swagger Petstore */ &#39; \&quot; &#x3D;end"],
keywords=["Swagger", "Swagger Petstore */ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r"],
install_requires=REQUIRES,
packages=find_packages(),
include_package_data=True,
long_description="""\
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \&quot; \\ */ &#39; \&quot; &#x3D;end
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \&quot; \\ */ &#39; \&quot; &#x3D;end --
"""
)

View File

@@ -51,3 +51,4 @@ setup(
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \&quot; \\
"""
)