forked from loafle/openapi-generator-original
better code injection handling for python
This commit is contained in:
31
bin/security/python-petstore.sh
Executable file
31
bin/security/python-petstore.sh
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn clean package
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/python -i modules/swagger-codegen/src/test/resources/2_0/petstore-security-test.yaml -l python -o samples/client/petstore-security-test/python -DpackageName=petstore_api"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
@@ -590,5 +590,16 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
p.example = example;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeQuotationMark(String input) {
|
||||
// remove ' to avoid code injection
|
||||
return input.replace("'", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeUnsafeCharacters(String input) {
|
||||
// remove multiline comment
|
||||
return input.replace("'''", "");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
64
samples/client/petstore-security-test/python/.gitignore
vendored
Normal file
64
samples/client/petstore-security-test/python/.gitignore
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
env/
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*,cover
|
||||
.hypothesis/
|
||||
venv/
|
||||
.python-version
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
target/
|
||||
|
||||
#Ipython Notebook
|
||||
.ipynb_checkpoints
|
||||
@@ -0,0 +1,23 @@
|
||||
# Swagger Codegen Ignore
|
||||
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
|
||||
|
||||
# Use this file to prevent files from being overwritten by the generator.
|
||||
# The patterns follow closely to .gitignore or .dockerignore.
|
||||
|
||||
# As an example, the C# client generator defines ApiClient.cs.
|
||||
# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line:
|
||||
#ApiClient.cs
|
||||
|
||||
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
||||
#foo/*/qux
|
||||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
||||
|
||||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
||||
#foo/**/qux
|
||||
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
||||
|
||||
# You can also negate patterns with an exclamation (!).
|
||||
# For example, you can ignore all files in a docs folder with the file extension .md:
|
||||
#docs/*.md
|
||||
# Then explicitly reverse the ignore rule for a single file:
|
||||
#!docs/README.md
|
||||
14
samples/client/petstore-security-test/python/.travis.yml
Normal file
14
samples/client/petstore-security-test/python/.travis.yml
Normal file
@@ -0,0 +1,14 @@
|
||||
# ref: https://docs.travis-ci.com/user/languages/python
|
||||
language: python
|
||||
python:
|
||||
- "2.7"
|
||||
- "3.2"
|
||||
- "3.3"
|
||||
- "3.4"
|
||||
- "3.5"
|
||||
#- "3.5-dev" # 3.5 development branch
|
||||
#- "nightly" # points to the latest development branch e.g. 3.6-dev
|
||||
# command to install dependencies
|
||||
install: "pip install -r requirements.txt"
|
||||
# command to run tests
|
||||
script: nosetests
|
||||
201
samples/client/petstore-security-test/python/LICENSE
Normal file
201
samples/client/petstore-security-test/python/LICENSE
Normal file
@@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright {yyyy} {name of copyright owner}
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
101
samples/client/petstore-security-test/python/README.md
Normal file
101
samples/client/petstore-security-test/python/README.md
Normal file
@@ -0,0 +1,101 @@
|
||||
# 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 Python package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
|
||||
|
||||
- API version: 1.0.0 */ ' \" =end
|
||||
- Package version: 1.0.0
|
||||
- Build date: 2016-06-28T16:59:35.203+08:00
|
||||
- Build package: class io.swagger.codegen.languages.PythonClientCodegen
|
||||
|
||||
## Requirements.
|
||||
|
||||
Python 2.7 and 3.4+
|
||||
|
||||
## Installation & Usage
|
||||
### pip install
|
||||
|
||||
If the python package is hosted on Github, you can install directly from Github
|
||||
|
||||
```sh
|
||||
pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git
|
||||
```
|
||||
(you may need to run `pip` with root permission: `sudo pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git`)
|
||||
|
||||
Then import the package:
|
||||
```python
|
||||
import petstore_api
|
||||
```
|
||||
|
||||
### Setuptools
|
||||
|
||||
Install via [Setuptools](http://pypi.python.org/pypi/setuptools).
|
||||
|
||||
```sh
|
||||
python setup.py install --user
|
||||
```
|
||||
(or `sudo python setup.py install` to install the package for all users)
|
||||
|
||||
Then import the package:
|
||||
```python
|
||||
import petstore_api
|
||||
```
|
||||
|
||||
## Getting Started
|
||||
|
||||
Please follow the [installation procedure](#installation--usage) and then run the following:
|
||||
|
||||
```python
|
||||
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)
|
||||
|
||||
try:
|
||||
# To test code injection */ ' \" =end
|
||||
api_instance.test_code_inject____end(test_code_inject____end=test_code_inject____end)
|
||||
except ApiException as e:
|
||||
print "Exception when calling FakeApi->test_code_inject____end: %s\n" % e
|
||||
|
||||
```
|
||||
|
||||
## Documentation for API Endpoints
|
||||
|
||||
All URIs are relative to *https://petstore.swagger.io */ ' " =end/v2 */ ' " =end*
|
||||
|
||||
Class | Method | HTTP request | Description
|
||||
------------ | ------------- | ------------- | -------------
|
||||
*FakeApi* | [**test_code_inject____end**](docs/FakeApi.md#test_code_inject____end) | **PUT** /fake | To test code injection */ ' \" =end
|
||||
|
||||
|
||||
## Documentation For Models
|
||||
|
||||
- [ModelReturn](docs/ModelReturn.md)
|
||||
|
||||
|
||||
## Documentation For Authorization
|
||||
|
||||
|
||||
## api_key
|
||||
|
||||
- **Type**: API key
|
||||
- **API key parameter name**: api_key */ ' " =end
|
||||
- **Location**: HTTP header
|
||||
|
||||
## petstore_auth
|
||||
|
||||
- **Type**: OAuth
|
||||
- **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
|
||||
|
||||
|
||||
## Author
|
||||
|
||||
apiteam@swagger.io */ ' \" =end
|
||||
|
||||
53
samples/client/petstore-security-test/python/docs/FakeApi.md
Normal file
53
samples/client/petstore-security-test/python/docs/FakeApi.md
Normal file
@@ -0,0 +1,53 @@
|
||||
# petstore_api.FakeApi
|
||||
|
||||
All URIs are relative to *https://petstore.swagger.io */ ' " =end/v2 */ ' " =end*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**test_code_inject____end**](FakeApi.md#test_code_inject____end) | **PUT** /fake | To test code injection */ ' \" =end
|
||||
|
||||
|
||||
# **test_code_inject____end**
|
||||
> test_code_inject____end(test_code_inject____end=test_code_inject____end)
|
||||
|
||||
To test code injection */ ' \" =end
|
||||
|
||||
### Example
|
||||
```python
|
||||
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)
|
||||
|
||||
try:
|
||||
# To test code injection */ ' \" =end
|
||||
api_instance.test_code_inject____end(test_code_inject____end=test_code_inject____end)
|
||||
except ApiException as e:
|
||||
print "Exception when calling FakeApi->test_code_inject____end: %s\n" % e
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**test_code_inject____end** | **str**| To test code injection */ ' \" =end | [optional]
|
||||
|
||||
### Return type
|
||||
|
||||
void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **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)
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
# ModelReturn
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**_return** | **int** | property description */ ' \" =end | [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)
|
||||
|
||||
|
||||
52
samples/client/petstore-security-test/python/git_push.sh
Normal file
52
samples/client/petstore-security-test/python/git_push.sh
Normal file
@@ -0,0 +1,52 @@
|
||||
#!/bin/sh
|
||||
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
||||
#
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update"
|
||||
|
||||
git_user_id=$1
|
||||
git_repo_id=$2
|
||||
release_note=$3
|
||||
|
||||
if [ "$git_user_id" = "" ]; then
|
||||
git_user_id="GIT_USER_ID"
|
||||
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
|
||||
fi
|
||||
|
||||
if [ "$git_repo_id" = "" ]; then
|
||||
git_repo_id="GIT_REPO_ID"
|
||||
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
|
||||
fi
|
||||
|
||||
if [ "$release_note" = "" ]; then
|
||||
release_note="Minor update"
|
||||
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
|
||||
fi
|
||||
|
||||
# Initialize the local directory as a Git repository
|
||||
git init
|
||||
|
||||
# Adds the files in the local repository and stages them for commit.
|
||||
git add .
|
||||
|
||||
# Commits the tracked changes and prepares them to be pushed to a remote repository.
|
||||
git commit -m "$release_note"
|
||||
|
||||
# Sets the new remote
|
||||
git_remote=`git remote`
|
||||
if [ "$git_remote" = "" ]; then # git remote not defined
|
||||
|
||||
if [ "$GIT_TOKEN" = "" ]; then
|
||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment."
|
||||
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
|
||||
else
|
||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
git pull origin master
|
||||
|
||||
# Pushes (Forces) the changes in the local repository up to the remote repository
|
||||
echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
|
||||
git push origin master 2>&1 | grep -v 'To https'
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
Swagger Petstore */ ' \" =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
|
||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
# import models into sdk package
|
||||
from .models.model_return import ModelReturn
|
||||
|
||||
# import apis into sdk package
|
||||
from .apis.fake_api import FakeApi
|
||||
|
||||
# import ApiClient
|
||||
from .api_client import ApiClient
|
||||
|
||||
from .configuration import Configuration
|
||||
|
||||
configuration = Configuration()
|
||||
@@ -0,0 +1,583 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
Copyright 2016 SmartBear Software
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
ref: https://github.com/swagger-api/swagger-codegen
|
||||
"""
|
||||
|
||||
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
|
||||
|
||||
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 .configuration import Configuration
|
||||
|
||||
|
||||
class ApiClient(object):
|
||||
"""
|
||||
Generic API client for Swagger client library builds.
|
||||
|
||||
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
|
||||
templates.
|
||||
|
||||
NOTE: This class is auto generated by the swagger code generator program.
|
||||
Ref: https://github.com/swagger-api/swagger-codegen
|
||||
Do not edit the class manually.
|
||||
|
||||
:param host: The base path for the server to call.
|
||||
:param header_name: a header to pass when making calls to the API.
|
||||
:param header_value: a header value to pass when making calls to the API.
|
||||
"""
|
||||
def __init__(self, host=None, header_name=None, header_value=None, cookie=None):
|
||||
|
||||
"""
|
||||
Constructor of the class.
|
||||
"""
|
||||
self.rest_client = RESTClientObject()
|
||||
self.default_headers = {}
|
||||
if header_name is not None:
|
||||
self.default_headers[header_name] = header_value
|
||||
if host is None:
|
||||
self.host = Configuration().host
|
||||
else:
|
||||
self.host = host
|
||||
self.cookie = cookie
|
||||
# Set default User-Agent.
|
||||
self.user_agent = 'Swagger-Codegen/1.0.0/python'
|
||||
|
||||
@property
|
||||
def user_agent(self):
|
||||
"""
|
||||
Gets user agent.
|
||||
"""
|
||||
return self.default_headers['User-Agent']
|
||||
|
||||
@user_agent.setter
|
||||
def user_agent(self, value):
|
||||
"""
|
||||
Sets user agent.
|
||||
"""
|
||||
self.default_headers['User-Agent'] = value
|
||||
|
||||
def set_default_header(self, header_name, header_value):
|
||||
self.default_headers[header_name] = header_value
|
||||
|
||||
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):
|
||||
|
||||
# headers 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)
|
||||
|
||||
# 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)
|
||||
|
||||
# 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)}
|
||||
|
||||
# post parameters
|
||||
if post_params or files:
|
||||
post_params = self.prepare_post_parameters(post_params, files)
|
||||
post_params = self.sanitize_for_serialization(post_params)
|
||||
|
||||
# auth setting
|
||||
self.update_params_for_auth(header_params, query_params, auth_settings)
|
||||
|
||||
# body
|
||||
if body:
|
||||
body = self.sanitize_for_serialization(body)
|
||||
|
||||
# request url
|
||||
url = self.host + resource_path
|
||||
|
||||
# perform request and return response
|
||||
response_data = self.request(method, url,
|
||||
query_params=query_params,
|
||||
headers=header_params,
|
||||
post_params=post_params, body=body)
|
||||
|
||||
self.last_response = response_data
|
||||
|
||||
# deserialize response data
|
||||
if response_type:
|
||||
deserialized_data = self.deserialize(response_data, response_type)
|
||||
else:
|
||||
deserialized_data = None
|
||||
|
||||
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 );
|
||||
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 datetime.datetime, datetime.date
|
||||
convert to string in iso8601 format.
|
||||
If obj is list, sanitize each element in the list.
|
||||
If obj is dict, return the dict.
|
||||
If obj is swagger model, return the properties dict.
|
||||
|
||||
: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,)
|
||||
if isinstance(obj, type(None)):
|
||||
return None
|
||||
elif isinstance(obj, types):
|
||||
return obj
|
||||
elif isinstance(obj, list):
|
||||
return [self.sanitize_for_serialization(sub_obj)
|
||||
for sub_obj in obj]
|
||||
elif isinstance(obj, (datetime, date)):
|
||||
return obj.isoformat()
|
||||
else:
|
||||
if isinstance(obj, dict):
|
||||
obj_dict = obj
|
||||
else:
|
||||
# Convert model obj to dict except
|
||||
# attributes `swagger_types`, `attribute_map`
|
||||
# and attributes which value is not None.
|
||||
# Convert attribute name to json key in
|
||||
# model definition for request.
|
||||
obj_dict = {obj.attribute_map[attr]: getattr(obj, attr)
|
||||
for attr, _ in iteritems(obj.swagger_types)
|
||||
if getattr(obj, attr) is not None}
|
||||
|
||||
return {key: self.sanitize_for_serialization(val)
|
||||
for key, val in iteritems(obj_dict)}
|
||||
|
||||
def deserialize(self, response, response_type):
|
||||
"""
|
||||
Deserializes response into an object.
|
||||
|
||||
:param response: RESTResponse object to be deserialized.
|
||||
:param response_type: class literal for
|
||||
deserialzied object, or string of class name.
|
||||
|
||||
:return: deserialized object.
|
||||
"""
|
||||
# handle file downloading
|
||||
# save response body into a tmp file and return the instance
|
||||
if "file" == response_type:
|
||||
return self.__deserialize_file(response)
|
||||
|
||||
# fetch data from response object
|
||||
try:
|
||||
data = json.loads(response.data)
|
||||
except ValueError:
|
||||
data = response.data
|
||||
|
||||
return self.__deserialize(data, response_type)
|
||||
|
||||
def __deserialize(self, data, klass):
|
||||
"""
|
||||
Deserializes dict, list, str into an object.
|
||||
|
||||
:param data: dict, list or str.
|
||||
:param klass: class literal, or string of class name.
|
||||
|
||||
:return: object.
|
||||
"""
|
||||
if data is None:
|
||||
return None
|
||||
|
||||
if type(klass) == str:
|
||||
if klass.startswith('list['):
|
||||
sub_kls = re.match('list\[(.*)\]', klass).group(1)
|
||||
return [self.__deserialize(sub_data, sub_kls)
|
||||
for sub_data in data]
|
||||
|
||||
if klass.startswith('dict('):
|
||||
sub_kls = re.match('dict\(([^,]*), (.*)\)', klass).group(2)
|
||||
return {k: self.__deserialize(v, sub_kls)
|
||||
for k, v in iteritems(data)}
|
||||
|
||||
# convert str to class
|
||||
# for native types
|
||||
if klass in ['int', 'float', 'str', 'bool',
|
||||
"date", 'datetime', "object"]:
|
||||
klass = eval(klass)
|
||||
# for model types
|
||||
else:
|
||||
klass = eval('models.' + klass)
|
||||
|
||||
if klass in [int, float, str, bool]:
|
||||
return self.__deserialize_primitive(data, klass)
|
||||
elif klass == object:
|
||||
return self.__deserialize_object(data)
|
||||
elif klass == date:
|
||||
return self.__deserialize_date(data)
|
||||
elif klass == datetime:
|
||||
return self.__deserialize_datatime(data)
|
||||
else:
|
||||
return self.__deserialize_model(data, klass)
|
||||
|
||||
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):
|
||||
"""
|
||||
Makes the HTTP request (synchronous) and return the deserialized data.
|
||||
To make an async request, define a function for callback.
|
||||
|
||||
:param resource_path: Path to method endpoint.
|
||||
:param method: Method to call.
|
||||
:param path_params: Path parameters in the url.
|
||||
:param query_params: Query parameters in the url.
|
||||
:param header_params: Header parameters to be
|
||||
placed in the request header.
|
||||
:param body: Request body.
|
||||
:param post_params dict: Request post form parameters,
|
||||
for `application/x-www-form-urlencoded`, `multipart/form-data`.
|
||||
:param auth_settings list: Auth Settings names for the request.
|
||||
:param response: Response data type.
|
||||
:param files dict: key -> filename, value -> filepath,
|
||||
for `multipart/form-data`.
|
||||
:param callback function: Callback function for asynchronous request.
|
||||
If provide this parameter,
|
||||
the request will be called asynchronously.
|
||||
:param _return_http_data_only: response data without head status code and headers
|
||||
:return:
|
||||
If provide parameter callback,
|
||||
the request will be called asynchronously.
|
||||
The method will return the request thread.
|
||||
If parameter callback is None,
|
||||
then the method will return the response directly.
|
||||
"""
|
||||
if callback is None:
|
||||
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)
|
||||
else:
|
||||
thread = threading.Thread(target=self.__call_api,
|
||||
args=(resource_path, method,
|
||||
path_params, query_params,
|
||||
header_params, body,
|
||||
post_params, files,
|
||||
response_type, auth_settings,
|
||||
callback,_return_http_data_only))
|
||||
thread.start()
|
||||
return thread
|
||||
|
||||
def request(self, method, url, query_params=None, headers=None,
|
||||
post_params=None, body=None):
|
||||
"""
|
||||
Makes the HTTP request using RESTClient.
|
||||
"""
|
||||
if method == "GET":
|
||||
return self.rest_client.GET(url,
|
||||
query_params=query_params,
|
||||
headers=headers)
|
||||
elif method == "HEAD":
|
||||
return self.rest_client.HEAD(url,
|
||||
query_params=query_params,
|
||||
headers=headers)
|
||||
elif method == "OPTIONS":
|
||||
return self.rest_client.OPTIONS(url,
|
||||
query_params=query_params,
|
||||
headers=headers,
|
||||
post_params=post_params,
|
||||
body=body)
|
||||
elif method == "POST":
|
||||
return self.rest_client.POST(url,
|
||||
query_params=query_params,
|
||||
headers=headers,
|
||||
post_params=post_params,
|
||||
body=body)
|
||||
elif method == "PUT":
|
||||
return self.rest_client.PUT(url,
|
||||
query_params=query_params,
|
||||
headers=headers,
|
||||
post_params=post_params,
|
||||
body=body)
|
||||
elif method == "PATCH":
|
||||
return self.rest_client.PATCH(url,
|
||||
query_params=query_params,
|
||||
headers=headers,
|
||||
post_params=post_params,
|
||||
body=body)
|
||||
elif method == "DELETE":
|
||||
return self.rest_client.DELETE(url,
|
||||
query_params=query_params,
|
||||
headers=headers,
|
||||
body=body)
|
||||
else:
|
||||
raise ValueError(
|
||||
"http method must be `GET`, `HEAD`,"
|
||||
" `POST`, `PATCH`, `PUT` or `DELETE`."
|
||||
)
|
||||
|
||||
def prepare_post_parameters(self, post_params=None, files=None):
|
||||
"""
|
||||
Builds form parameters.
|
||||
|
||||
:param post_params: Normal form parameters.
|
||||
:param files: File parameters.
|
||||
:return: Form parameters with files.
|
||||
"""
|
||||
params = []
|
||||
|
||||
if post_params:
|
||||
params = post_params
|
||||
|
||||
if files:
|
||||
for k, v in iteritems(files):
|
||||
if not v:
|
||||
continue
|
||||
file_names = v if type(v) is list else [v]
|
||||
for n in file_names:
|
||||
with open(n, 'rb') as f:
|
||||
filename = os.path.basename(f.name)
|
||||
filedata = f.read()
|
||||
mimetype = mimetypes.\
|
||||
guess_type(filename)[0] or 'application/octet-stream'
|
||||
params.append(tuple([k, tuple([filename, filedata, mimetype])]))
|
||||
|
||||
return params
|
||||
|
||||
def select_header_accept(self, accepts):
|
||||
"""
|
||||
Returns `Accept` based on an array of accepts provided.
|
||||
|
||||
:param accepts: List of headers.
|
||||
:return: Accept (e.g. application/json).
|
||||
"""
|
||||
if not accepts:
|
||||
return
|
||||
|
||||
accepts = list(map(lambda x: x.lower(), accepts))
|
||||
|
||||
if 'application/json' in accepts:
|
||||
return 'application/json'
|
||||
else:
|
||||
return ', '.join(accepts)
|
||||
|
||||
def select_header_content_type(self, content_types):
|
||||
"""
|
||||
Returns `Content-Type` based on an array of content_types provided.
|
||||
|
||||
:param content_types: List of content-types.
|
||||
:return: Content-Type (e.g. application/json).
|
||||
"""
|
||||
if not content_types:
|
||||
return 'application/json'
|
||||
|
||||
content_types = list(map(lambda x: x.lower(), content_types))
|
||||
|
||||
if 'application/json' in content_types:
|
||||
return 'application/json'
|
||||
else:
|
||||
return content_types[0]
|
||||
|
||||
def update_params_for_auth(self, headers, querys, auth_settings):
|
||||
"""
|
||||
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 auth_settings: Authentication setting identifiers list.
|
||||
"""
|
||||
config = Configuration()
|
||||
|
||||
if not auth_settings:
|
||||
return
|
||||
|
||||
for auth in auth_settings:
|
||||
auth_setting = config.auth_settings().get(auth)
|
||||
if auth_setting:
|
||||
if not auth_setting['value']:
|
||||
continue
|
||||
elif auth_setting['in'] == 'header':
|
||||
headers[auth_setting['key']] = auth_setting['value']
|
||||
elif auth_setting['in'] == 'query':
|
||||
querys[auth_setting['key']] = auth_setting['value']
|
||||
else:
|
||||
raise ValueError(
|
||||
'Authentication token must be in `query` or `header`'
|
||||
)
|
||||
|
||||
def __deserialize_file(self, response):
|
||||
"""
|
||||
Saves response body into a file in a temporary folder,
|
||||
using the filename from the `Content-Disposition` header if provided.
|
||||
|
||||
:param response: RESTResponse.
|
||||
:return: file path.
|
||||
"""
|
||||
config = Configuration()
|
||||
|
||||
fd, path = tempfile.mkstemp(dir=config.temp_folder_path)
|
||||
os.close(fd)
|
||||
os.remove(path)
|
||||
|
||||
content_disposition = response.getheader("Content-Disposition")
|
||||
if content_disposition:
|
||||
filename = re.\
|
||||
search(r'filename=[\'"]?([^\'"\s]+)[\'"]?', content_disposition).\
|
||||
group(1)
|
||||
path = os.path.join(os.path.dirname(path), filename)
|
||||
|
||||
with open(path, "w") as f:
|
||||
f.write(response.data)
|
||||
|
||||
return path
|
||||
|
||||
def __deserialize_primitive(self, data, klass):
|
||||
"""
|
||||
Deserializes string to primitive type.
|
||||
|
||||
:param data: str.
|
||||
:param klass: class literal.
|
||||
|
||||
:return: int, float, str, bool.
|
||||
"""
|
||||
try:
|
||||
value = klass(data)
|
||||
except UnicodeEncodeError:
|
||||
value = unicode(data)
|
||||
except TypeError:
|
||||
value = data
|
||||
return value
|
||||
|
||||
def __deserialize_object(self, value):
|
||||
"""
|
||||
Return a original value.
|
||||
|
||||
:return: object.
|
||||
"""
|
||||
return value
|
||||
|
||||
def __deserialize_date(self, string):
|
||||
"""
|
||||
Deserializes string to date.
|
||||
|
||||
:param string: str.
|
||||
:return: date.
|
||||
"""
|
||||
try:
|
||||
from dateutil.parser import parse
|
||||
return parse(string).date()
|
||||
except ImportError:
|
||||
return string
|
||||
except ValueError:
|
||||
raise ApiException(
|
||||
status=0,
|
||||
reason="Failed to parse `{0}` into a date object"
|
||||
.format(string)
|
||||
)
|
||||
|
||||
def __deserialize_datatime(self, string):
|
||||
"""
|
||||
Deserializes string to datetime.
|
||||
|
||||
The string should be in iso8601 datetime format.
|
||||
|
||||
:param string: str.
|
||||
:return: datetime.
|
||||
"""
|
||||
try:
|
||||
from dateutil.parser import parse
|
||||
return parse(string)
|
||||
except ImportError:
|
||||
return string
|
||||
except ValueError:
|
||||
raise ApiException(
|
||||
status=0,
|
||||
reason="Failed to parse `{0}` into a datetime object".
|
||||
format(string)
|
||||
)
|
||||
|
||||
def __deserialize_model(self, data, klass):
|
||||
"""
|
||||
Deserializes list or dict to model.
|
||||
|
||||
:param data: dict, list.
|
||||
:param klass: class literal.
|
||||
:return: model object.
|
||||
"""
|
||||
instance = klass()
|
||||
|
||||
for attr, attr_type in iteritems(instance.swagger_types):
|
||||
if data is not None \
|
||||
and instance.attribute_map[attr] in data\
|
||||
and isinstance(data, (list, dict)):
|
||||
value = data[instance.attribute_map[attr]]
|
||||
setattr(instance, attr, self.__deserialize(value, attr_type))
|
||||
|
||||
return instance
|
||||
@@ -0,0 +1,4 @@
|
||||
from __future__ import absolute_import
|
||||
|
||||
# import apis into api package
|
||||
from .fake_api import FakeApi
|
||||
@@ -0,0 +1,153 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
Swagger Petstore */ ' \" =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
|
||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import sys
|
||||
import os
|
||||
import re
|
||||
|
||||
# python 2 and python 3 compatibility library
|
||||
from six import iteritems
|
||||
|
||||
from ..configuration import Configuration
|
||||
from ..api_client import ApiClient
|
||||
|
||||
|
||||
class FakeApi(object):
|
||||
"""
|
||||
NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually.
|
||||
Ref: https://github.com/swagger-api/swagger-codegen
|
||||
"""
|
||||
|
||||
def __init__(self, api_client=None):
|
||||
config = Configuration()
|
||||
if api_client:
|
||||
self.api_client = api_client
|
||||
else:
|
||||
if not config.api_client:
|
||||
config.api_client = ApiClient()
|
||||
self.api_client = config.api_client
|
||||
|
||||
def test_code_inject____end(self, **kwargs):
|
||||
"""
|
||||
To test code injection */ ' \" =end
|
||||
|
||||
|
||||
This method makes a synchronous HTTP request by default. To make an
|
||||
asynchronous HTTP request, please define a `callback` function
|
||||
to be invoked when receiving the response.
|
||||
>>> def callback_function(response):
|
||||
>>> pprint(response)
|
||||
>>>
|
||||
>>> thread = api.test_code_inject____end(callback=callback_function)
|
||||
|
||||
:param callback function: The callback function
|
||||
for asynchronous request. (optional)
|
||||
:param str test_code_inject____end: To test code injection */ ' \" =end
|
||||
: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)
|
||||
else:
|
||||
(data) = self.test_code_inject____end_with_http_info(**kwargs)
|
||||
return data
|
||||
|
||||
def test_code_inject____end_with_http_info(self, **kwargs):
|
||||
"""
|
||||
To test code injection */ ' \" =end
|
||||
|
||||
|
||||
This method makes a synchronous HTTP request by default. To make an
|
||||
asynchronous HTTP request, please define a `callback` function
|
||||
to be invoked when receiving the response.
|
||||
>>> def callback_function(response):
|
||||
>>> pprint(response)
|
||||
>>>
|
||||
>>> thread = api.test_code_inject____end_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
|
||||
:return: None
|
||||
If the method is called asynchronously,
|
||||
returns the request thread.
|
||||
"""
|
||||
|
||||
all_params = ['test_code_inject____end']
|
||||
all_params.append('callback')
|
||||
all_params.append('_return_http_data_only')
|
||||
|
||||
params = locals()
|
||||
for key, val in iteritems(params['kwargs']):
|
||||
if key not in all_params:
|
||||
raise TypeError(
|
||||
"Got an unexpected keyword argument '%s'"
|
||||
" to method test_code_inject____end" % key
|
||||
)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resource_path = '/fake'.replace('{format}', 'json')
|
||||
path_params = {}
|
||||
|
||||
query_params = {}
|
||||
|
||||
header_params = {}
|
||||
|
||||
form_params = []
|
||||
local_var_files = {}
|
||||
if 'test_code_inject____end' in params:
|
||||
form_params.append(('test code inject */ ' " =end', params['test_code_inject____end']))
|
||||
|
||||
body_params = None
|
||||
|
||||
# HTTP header `Accept`
|
||||
header_params['Accept'] = self.api_client.\
|
||||
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'])
|
||||
|
||||
# Authentication setting
|
||||
auth_settings = []
|
||||
|
||||
return self.api_client.call_api(resource_path, 'PUT',
|
||||
path_params,
|
||||
query_params,
|
||||
header_params,
|
||||
body=body_params,
|
||||
post_params=form_params,
|
||||
files=local_var_files,
|
||||
response_type=None,
|
||||
auth_settings=auth_settings,
|
||||
callback=params.get('callback'),
|
||||
_return_http_data_only=params.get('_return_http_data_only'))
|
||||
@@ -0,0 +1,253 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
Swagger Petstore */ ' \" =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
|
||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
import base64
|
||||
import urllib3
|
||||
|
||||
try:
|
||||
import httplib
|
||||
except ImportError:
|
||||
# for python3
|
||||
import http.client as httplib
|
||||
|
||||
import sys
|
||||
import logging
|
||||
|
||||
from six import iteritems
|
||||
|
||||
|
||||
def singleton(cls, *args, **kw):
|
||||
instances = {}
|
||||
|
||||
def _singleton():
|
||||
if cls not in instances:
|
||||
instances[cls] = cls(*args, **kw)
|
||||
return instances[cls]
|
||||
return _singleton
|
||||
|
||||
|
||||
@singleton
|
||||
class Configuration(object):
|
||||
"""
|
||||
NOTE: This class is auto generated by the swagger code generator program.
|
||||
Ref: https://github.com/swagger-api/swagger-codegen
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
"""
|
||||
Constructor
|
||||
"""
|
||||
# Default Base url
|
||||
self.host = "https://petstore.swagger.io */ ' " =end/v2 */ ' " =end"
|
||||
# Default api client
|
||||
self.api_client = None
|
||||
# Temp file folder for downloading files
|
||||
self.temp_folder_path = None
|
||||
|
||||
# Authentication Settings
|
||||
# dict to store API key(s)
|
||||
self.api_key = {}
|
||||
# dict to store API prefix (e.g. Bearer)
|
||||
self.api_key_prefix = {}
|
||||
# Username for HTTP basic authentication
|
||||
self.username = ""
|
||||
# Password for HTTP basic authentication
|
||||
self.password = ""
|
||||
|
||||
# access token for OAuth
|
||||
self.access_token = ""
|
||||
|
||||
# Logging Settings
|
||||
self.logger = {}
|
||||
self.logger["package_logger"] = logging.getLogger("petstore_api")
|
||||
self.logger["urllib3_logger"] = logging.getLogger("urllib3")
|
||||
# Log format
|
||||
self.logger_format = '%(asctime)s %(levelname)s %(message)s'
|
||||
# Log stream handler
|
||||
self.logger_stream_handler = None
|
||||
# Log file handler
|
||||
self.logger_file_handler = None
|
||||
# Debug file location
|
||||
self.logger_file = None
|
||||
# Debug switch
|
||||
self.debug = False
|
||||
|
||||
# SSL/TLS verification
|
||||
# Set this to false to skip verifying SSL certificate when calling API from https server.
|
||||
self.verify_ssl = True
|
||||
# Set this to customize the certificate file to verify the peer.
|
||||
self.ssl_ca_cert = None
|
||||
# client certificate file
|
||||
self.cert_file = None
|
||||
# client key file
|
||||
self.key_file = None
|
||||
|
||||
@property
|
||||
def logger_file(self):
|
||||
"""
|
||||
Gets the logger_file.
|
||||
"""
|
||||
return self.__logger_file
|
||||
|
||||
@logger_file.setter
|
||||
def logger_file(self, value):
|
||||
"""
|
||||
Sets the logger_file.
|
||||
|
||||
If the logger_file is None, then add stream handler and remove file handler.
|
||||
Otherwise, add file handler and remove stream handler.
|
||||
|
||||
:param value: The logger_file path.
|
||||
:type: str
|
||||
"""
|
||||
self.__logger_file = value
|
||||
if self.__logger_file:
|
||||
# If set logging file,
|
||||
# then add file handler and remove stream handler.
|
||||
self.logger_file_handler = logging.FileHandler(self.__logger_file)
|
||||
self.logger_file_handler.setFormatter(self.logger_formatter)
|
||||
for _, logger in iteritems(self.logger):
|
||||
logger.addHandler(self.logger_file_handler)
|
||||
if self.logger_stream_handler:
|
||||
logger.removeHandler(self.logger_stream_handler)
|
||||
else:
|
||||
# If not set logging file,
|
||||
# then add stream handler and remove file handler.
|
||||
self.logger_stream_handler = logging.StreamHandler()
|
||||
self.logger_stream_handler.setFormatter(self.logger_formatter)
|
||||
for _, logger in iteritems(self.logger):
|
||||
logger.addHandler(self.logger_stream_handler)
|
||||
if self.logger_file_handler:
|
||||
logger.removeHandler(self.logger_file_handler)
|
||||
|
||||
@property
|
||||
def debug(self):
|
||||
"""
|
||||
Gets the debug status.
|
||||
"""
|
||||
return self.__debug
|
||||
|
||||
@debug.setter
|
||||
def debug(self, value):
|
||||
"""
|
||||
Sets the debug status.
|
||||
|
||||
:param value: The debug status, True or False.
|
||||
:type: bool
|
||||
"""
|
||||
self.__debug = value
|
||||
if self.__debug:
|
||||
# if debug status is True, turn on debug logging
|
||||
for _, logger in iteritems(self.logger):
|
||||
logger.setLevel(logging.DEBUG)
|
||||
# turn on httplib debug
|
||||
httplib.HTTPConnection.debuglevel = 1
|
||||
else:
|
||||
# if debug status is False, turn off debug logging,
|
||||
# setting log level to default `logging.WARNING`
|
||||
for _, logger in iteritems(self.logger):
|
||||
logger.setLevel(logging.WARNING)
|
||||
# turn off httplib debug
|
||||
httplib.HTTPConnection.debuglevel = 0
|
||||
|
||||
@property
|
||||
def logger_format(self):
|
||||
"""
|
||||
Gets the logger_format.
|
||||
"""
|
||||
return self.__logger_format
|
||||
|
||||
@logger_format.setter
|
||||
def logger_format(self, value):
|
||||
"""
|
||||
Sets the logger_format.
|
||||
|
||||
The logger_formatter will be updated when sets logger_format.
|
||||
|
||||
:param value: The format string.
|
||||
:type: str
|
||||
"""
|
||||
self.__logger_format = value
|
||||
self.logger_formatter = logging.Formatter(self.__logger_format)
|
||||
|
||||
def get_api_key_with_prefix(self, identifier):
|
||||
"""
|
||||
Gets API key (with prefix if set).
|
||||
|
||||
:param identifier: The identifier of apiKey.
|
||||
:return: The token for api key authentication.
|
||||
"""
|
||||
if self.api_key.get(identifier) and self.api_key_prefix.get(identifier):
|
||||
return self.api_key_prefix[identifier] + ' ' + self.api_key[identifier]
|
||||
elif self.api_key.get(identifier):
|
||||
return self.api_key[identifier]
|
||||
|
||||
def get_basic_auth_token(self):
|
||||
"""
|
||||
Gets HTTP basic authentication header (string).
|
||||
|
||||
:return: The token for basic HTTP authentication.
|
||||
"""
|
||||
return urllib3.util.make_headers(basic_auth=self.username + ':' + self.password)\
|
||||
.get('authorization')
|
||||
|
||||
def auth_settings(self):
|
||||
"""
|
||||
Gets Auth Settings dict for api client.
|
||||
|
||||
:return: The Auth Settings information dict.
|
||||
"""
|
||||
return {
|
||||
'api_key':
|
||||
{
|
||||
'type': 'api_key',
|
||||
'in': 'header',
|
||||
'key': 'api_key */ ' " =end',
|
||||
'value': self.get_api_key_with_prefix('api_key */ ' " =end')
|
||||
},
|
||||
|
||||
'petstore_auth':
|
||||
{
|
||||
'type': 'oauth2',
|
||||
'in': 'header',
|
||||
'key': 'Authorization',
|
||||
'value': 'Bearer ' + self.access_token
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
def to_debug_report(self):
|
||||
"""
|
||||
Gets the essential information for debugging.
|
||||
|
||||
:return: The report for debugging.
|
||||
"""
|
||||
return "Python SDK Debug Report:\n"\
|
||||
"OS: {env}\n"\
|
||||
"Python Version: {pyversion}\n"\
|
||||
"Version of the API: 1.0.0 */ ' \" =end\n"\
|
||||
"SDK Package Version: 1.0.0".\
|
||||
format(env=sys.platform, pyversion=sys.version)
|
||||
@@ -0,0 +1,28 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
Swagger Petstore */ ' \" =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
|
||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
# import models into model package
|
||||
from .model_return import ModelReturn
|
||||
@@ -0,0 +1,125 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
Swagger Petstore */ ' \" =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
|
||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
|
||||
from pprint import pformat
|
||||
from six import iteritems
|
||||
import re
|
||||
|
||||
|
||||
class ModelReturn(object):
|
||||
"""
|
||||
NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
def __init__(self, _return=None):
|
||||
"""
|
||||
ModelReturn - a model defined in Swagger
|
||||
|
||||
:param dict swaggerTypes: The key is attribute name
|
||||
and the value is attribute type.
|
||||
:param dict attributeMap: The key is attribute name
|
||||
and the value is json key in definition.
|
||||
"""
|
||||
self.swagger_types = {
|
||||
'_return': 'int'
|
||||
}
|
||||
|
||||
self.attribute_map = {
|
||||
'_return': 'return'
|
||||
}
|
||||
|
||||
self.__return = _return
|
||||
|
||||
@property
|
||||
def _return(self):
|
||||
"""
|
||||
Gets the _return of this ModelReturn.
|
||||
property description */ ' \" =end
|
||||
|
||||
:return: The _return of this ModelReturn.
|
||||
:rtype: int
|
||||
"""
|
||||
return self.__return
|
||||
|
||||
@_return.setter
|
||||
def _return(self, _return):
|
||||
"""
|
||||
Sets the _return of this ModelReturn.
|
||||
property description */ ' \" =end
|
||||
|
||||
:param _return: The _return of this ModelReturn.
|
||||
:type: int
|
||||
"""
|
||||
|
||||
self.__return = _return
|
||||
|
||||
def to_dict(self):
|
||||
"""
|
||||
Returns the model properties as a dict
|
||||
"""
|
||||
result = {}
|
||||
|
||||
for attr, _ in iteritems(self.swagger_types):
|
||||
value = getattr(self, attr)
|
||||
if isinstance(value, list):
|
||||
result[attr] = list(map(
|
||||
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
|
||||
value
|
||||
))
|
||||
elif hasattr(value, "to_dict"):
|
||||
result[attr] = value.to_dict()
|
||||
elif isinstance(value, dict):
|
||||
result[attr] = dict(map(
|
||||
lambda item: (item[0], item[1].to_dict())
|
||||
if hasattr(item[1], "to_dict") else item,
|
||||
value.items()
|
||||
))
|
||||
else:
|
||||
result[attr] = value
|
||||
|
||||
return result
|
||||
|
||||
def to_str(self):
|
||||
"""
|
||||
Returns the string representation of the model
|
||||
"""
|
||||
return pformat(self.to_dict())
|
||||
|
||||
def __repr__(self):
|
||||
"""
|
||||
For `print` and `pprint`
|
||||
"""
|
||||
return self.to_str()
|
||||
|
||||
def __eq__(self, other):
|
||||
"""
|
||||
Returns true if both objects are equal
|
||||
"""
|
||||
return self.__dict__ == other.__dict__
|
||||
|
||||
def __ne__(self, other):
|
||||
"""
|
||||
Returns true if both objects are not equal
|
||||
"""
|
||||
return not self == other
|
||||
@@ -0,0 +1,259 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
Swagger Petstore */ ' \" =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
|
||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import sys
|
||||
import io
|
||||
import json
|
||||
import ssl
|
||||
import certifi
|
||||
import logging
|
||||
|
||||
# python 2 and python 3 compatibility library
|
||||
from six import iteritems
|
||||
|
||||
from .configuration import Configuration
|
||||
|
||||
try:
|
||||
import urllib3
|
||||
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__)
|
||||
|
||||
|
||||
class RESTResponse(io.IOBase):
|
||||
|
||||
def __init__(self, resp):
|
||||
self.urllib3_response = resp
|
||||
self.status = resp.status
|
||||
self.reason = resp.reason
|
||||
self.data = resp.data
|
||||
|
||||
def getheaders(self):
|
||||
"""
|
||||
Returns a dictionary of the response headers.
|
||||
"""
|
||||
return self.urllib3_response.getheaders()
|
||||
|
||||
def getheader(self, name, default=None):
|
||||
"""
|
||||
Returns a given response header.
|
||||
"""
|
||||
return self.urllib3_response.getheader(name, default)
|
||||
|
||||
|
||||
class RESTClientObject(object):
|
||||
|
||||
def __init__(self, pools_size=4):
|
||||
# urllib3.PoolManager will pass all kw parameters to connectionpool
|
||||
# https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/poolmanager.py#L75
|
||||
# https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/connectionpool.py#L680
|
||||
# ca_certs vs cert_file vs key_file
|
||||
# http://stackoverflow.com/a/23957365/2985775
|
||||
|
||||
# cert_reqs
|
||||
if Configuration().verify_ssl:
|
||||
cert_reqs = ssl.CERT_REQUIRED
|
||||
else:
|
||||
cert_reqs = ssl.CERT_NONE
|
||||
|
||||
# ca_certs
|
||||
if Configuration().ssl_ca_cert:
|
||||
ca_certs = Configuration().ssl_ca_cert
|
||||
else:
|
||||
# if not set certificate file, use Mozilla's root certificates.
|
||||
ca_certs = certifi.where()
|
||||
|
||||
# cert_file
|
||||
cert_file = Configuration().cert_file
|
||||
|
||||
# key file
|
||||
key_file = Configuration().key_file
|
||||
|
||||
# https pool manager
|
||||
self.pool_manager = urllib3.PoolManager(
|
||||
num_pools=pools_size,
|
||||
cert_reqs=cert_reqs,
|
||||
ca_certs=ca_certs,
|
||||
cert_file=cert_file,
|
||||
key_file=key_file
|
||||
)
|
||||
|
||||
def request(self, method, url, query_params=None, headers=None,
|
||||
body=None, post_params=None):
|
||||
"""
|
||||
:param method: http request method
|
||||
:param url: http request url
|
||||
:param query_params: query parameters in the url
|
||||
:param headers: http request headers
|
||||
:param body: request json body, for `application/json`
|
||||
:param post_params: request post parameters,
|
||||
`application/x-www-form-urlencode`
|
||||
and `multipart/form-data`
|
||||
"""
|
||||
method = method.upper()
|
||||
assert method in ['GET', 'HEAD', 'DELETE', 'POST', 'PUT', 'PATCH', 'OPTIONS']
|
||||
|
||||
if post_params and body:
|
||||
raise ValueError(
|
||||
"body parameter cannot be used with post_params parameter."
|
||||
)
|
||||
|
||||
post_params = post_params or {}
|
||||
headers = headers or {}
|
||||
|
||||
if 'Content-Type' not in headers:
|
||||
headers['Content-Type'] = 'application/json'
|
||||
|
||||
try:
|
||||
# For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE`
|
||||
if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']:
|
||||
if query_params:
|
||||
url += '?' + urlencode(query_params)
|
||||
if headers['Content-Type'] == 'application/json':
|
||||
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':
|
||||
r = self.pool_manager.request(method, url,
|
||||
fields=post_params,
|
||||
encode_multipart=False,
|
||||
headers=headers)
|
||||
if 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']
|
||||
r = self.pool_manager.request(method, url,
|
||||
fields=post_params,
|
||||
encode_multipart=True,
|
||||
headers=headers)
|
||||
# For `GET`, `HEAD`
|
||||
else:
|
||||
r = self.pool_manager.request(method, url,
|
||||
fields=query_params,
|
||||
headers=headers)
|
||||
except urllib3.exceptions.SSLError as e:
|
||||
msg = "{0}\n{1}".format(type(e).__name__, str(e))
|
||||
raise ApiException(status=0, reason=msg)
|
||||
|
||||
r = RESTResponse(r)
|
||||
|
||||
# In the python 3, the response.data is bytes.
|
||||
# we need to decode it to string.
|
||||
if sys.version_info > (3,):
|
||||
r.data = r.data.decode('utf8')
|
||||
|
||||
# log response body
|
||||
logger.debug("response body: %s" % r.data)
|
||||
|
||||
if r.status not in range(200, 206):
|
||||
raise ApiException(http_resp=r)
|
||||
|
||||
return r
|
||||
|
||||
def GET(self, url, headers=None, query_params=None):
|
||||
return self.request("GET", url,
|
||||
headers=headers,
|
||||
query_params=query_params)
|
||||
|
||||
def HEAD(self, url, headers=None, query_params=None):
|
||||
return self.request("HEAD", url,
|
||||
headers=headers,
|
||||
query_params=query_params)
|
||||
|
||||
def OPTIONS(self, url, headers=None, query_params=None, post_params=None, body=None):
|
||||
return self.request("OPTIONS", url,
|
||||
headers=headers,
|
||||
query_params=query_params,
|
||||
post_params=post_params,
|
||||
body=body)
|
||||
|
||||
def DELETE(self, url, headers=None, query_params=None, body=None):
|
||||
return self.request("DELETE", url,
|
||||
headers=headers,
|
||||
query_params=query_params,
|
||||
body=body)
|
||||
|
||||
def POST(self, url, headers=None, query_params=None, post_params=None, body=None):
|
||||
return self.request("POST", url,
|
||||
headers=headers,
|
||||
query_params=query_params,
|
||||
post_params=post_params,
|
||||
body=body)
|
||||
|
||||
def PUT(self, url, headers=None, query_params=None, post_params=None, body=None):
|
||||
return self.request("PUT", url,
|
||||
headers=headers,
|
||||
query_params=query_params,
|
||||
post_params=post_params,
|
||||
body=body)
|
||||
|
||||
def PATCH(self, url, headers=None, query_params=None, post_params=None, body=None):
|
||||
return self.request("PATCH", url,
|
||||
headers=headers,
|
||||
query_params=query_params,
|
||||
post_params=post_params,
|
||||
body=body)
|
||||
|
||||
|
||||
class ApiException(Exception):
|
||||
|
||||
def __init__(self, status=None, reason=None, http_resp=None):
|
||||
if http_resp:
|
||||
self.status = http_resp.status
|
||||
self.reason = http_resp.reason
|
||||
self.body = http_resp.data
|
||||
self.headers = http_resp.getheaders()
|
||||
else:
|
||||
self.status = status
|
||||
self.reason = reason
|
||||
self.body = None
|
||||
self.headers = None
|
||||
|
||||
def __str__(self):
|
||||
"""
|
||||
Custom error messages for exception
|
||||
"""
|
||||
error_message = "({0})\n"\
|
||||
"Reason: {1}\n".format(self.status, self.reason)
|
||||
if self.headers:
|
||||
error_message += "HTTP response headers: {0}\n".format(self.headers)
|
||||
|
||||
if self.body:
|
||||
error_message += "HTTP response body: {0}\n".format(self.body)
|
||||
|
||||
return error_message
|
||||
@@ -0,0 +1,5 @@
|
||||
certifi >= 14.05.14
|
||||
six == 1.8.0
|
||||
python_dateutil >= 2.5.3
|
||||
setuptools >= 21.0.0
|
||||
urllib3 >= 1.15.1
|
||||
53
samples/client/petstore-security-test/python/setup.py
Normal file
53
samples/client/petstore-security-test/python/setup.py
Normal file
@@ -0,0 +1,53 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
Swagger Petstore */ ' \" =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
|
||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
|
||||
import sys
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
NAME = "petstore_api"
|
||||
VERSION = "1.0.0"
|
||||
|
||||
# To install the library, run the following
|
||||
#
|
||||
# python setup.py install
|
||||
#
|
||||
# prerequisite: setuptools
|
||||
# http://pypi.python.org/pypi/setuptools
|
||||
|
||||
REQUIRES = ["urllib3 >= 1.15", "six >= 1.10", "certifi", "python-dateutil"]
|
||||
|
||||
setup(
|
||||
name=NAME,
|
||||
version=VERSION,
|
||||
description="Swagger Petstore */ ' \" =end",
|
||||
author_email="apiteam@swagger.io */ ' \" =end",
|
||||
url="",
|
||||
keywords=["Swagger", "Swagger Petstore */ ' \" =end"],
|
||||
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: \" \\ */ ' \" =end
|
||||
"""
|
||||
)
|
||||
@@ -0,0 +1,5 @@
|
||||
coverage>=4.0.3
|
||||
nose>=1.3.7
|
||||
pluggy>=0.3.1
|
||||
py>=1.4.31
|
||||
randomize>=0.13
|
||||
@@ -0,0 +1,55 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
Swagger Petstore */ ' \" =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
|
||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from petstore_api.apis.fake_api import FakeApi
|
||||
|
||||
|
||||
class TestFakeApi(unittest.TestCase):
|
||||
""" FakeApi unit test stubs """
|
||||
|
||||
def setUp(self):
|
||||
self.api = petstore_api.apis.fake_api.FakeApi()
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def test_test_code_inject____end(self):
|
||||
"""
|
||||
Test case for test_code_inject____end
|
||||
|
||||
To test code injection */ ' \" =end
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,53 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
Swagger Petstore */ ' \" =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
|
||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from petstore_api.models.model_return import ModelReturn
|
||||
|
||||
|
||||
class TestModelReturn(unittest.TestCase):
|
||||
""" ModelReturn unit test stubs """
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def testModelReturn(self):
|
||||
"""
|
||||
Test ModelReturn
|
||||
"""
|
||||
model = petstore_api.models.model_return.ModelReturn()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
10
samples/client/petstore-security-test/python/tox.ini
Normal file
10
samples/client/petstore-security-test/python/tox.ini
Normal file
@@ -0,0 +1,10 @@
|
||||
[tox]
|
||||
envlist = py27, py34
|
||||
|
||||
[testenv]
|
||||
deps=-r{toxinidir}/requirements.txt
|
||||
-r{toxinidir}/test-requirements.txt
|
||||
|
||||
commands=
|
||||
nosetests \
|
||||
[]
|
||||
@@ -5,7 +5,7 @@ This Python package is automatically generated by the [Swagger Codegen](https://
|
||||
|
||||
- API version: 1.0.0
|
||||
- Package version: 1.0.0
|
||||
- Build date: 2016-06-20T11:55:16.948+08:00
|
||||
- Build date: 2016-06-28T16:59:47.081+08:00
|
||||
- Build package: class io.swagger.codegen.languages.PythonClientCodegen
|
||||
|
||||
## Requirements.
|
||||
@@ -52,24 +52,13 @@ from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
# create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi
|
||||
number = 3.4 # float | None
|
||||
double = 1.2 # float | None
|
||||
string = 'string_example' # str | None
|
||||
byte = 'B' # str | None
|
||||
integer = 56 # int | None (optional)
|
||||
int32 = 56 # int | None (optional)
|
||||
int64 = 789 # int | None (optional)
|
||||
float = 3.4 # float | None (optional)
|
||||
binary = 'B' # str | None (optional)
|
||||
date = '2013-10-20' # date | None (optional)
|
||||
date_time = '2013-10-20T19:20:30+01:00' # datetime | None (optional)
|
||||
password = 'password_example' # str | None (optional)
|
||||
test_code_inject__end = 'test_code_inject__end_example' # str | To test code injection */ =end (optional)
|
||||
|
||||
try:
|
||||
# Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
api_instance.test_endpoint_parameters(number, double, string, byte, integer=integer, int32=int32, int64=int64, float=float, binary=binary, date=date, date_time=date_time, password=password)
|
||||
# To test code injection */ =end
|
||||
api_instance.test_code_inject__end(test_code_inject__end=test_code_inject__end)
|
||||
except ApiException as e:
|
||||
print "Exception when calling FakeApi->test_endpoint_parameters: %s\n" % e
|
||||
print "Exception when calling FakeApi->test_code_inject__end: %s\n" % e
|
||||
|
||||
```
|
||||
|
||||
@@ -79,7 +68,9 @@ All URIs are relative to *http://petstore.swagger.io/v2*
|
||||
|
||||
Class | Method | HTTP request | Description
|
||||
------------ | ------------- | ------------- | -------------
|
||||
*FakeApi* | [**test_code_inject__end**](docs/FakeApi.md#test_code_inject__end) | **PUT** /fake | To test code injection */ =end
|
||||
*FakeApi* | [**test_endpoint_parameters**](docs/FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
*FakeApi* | [**test_enum_query_parameters**](docs/FakeApi.md#test_enum_query_parameters) | **GET** /fake | To test enum query parameters
|
||||
*PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store
|
||||
*PetApi* | [**delete_pet**](docs/PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet
|
||||
*PetApi* | [**find_pets_by_status**](docs/PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status
|
||||
@@ -108,6 +99,8 @@ Class | Method | HTTP request | Description
|
||||
- [Animal](docs/Animal.md)
|
||||
- [AnimalFarm](docs/AnimalFarm.md)
|
||||
- [ApiResponse](docs/ApiResponse.md)
|
||||
- [ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md)
|
||||
- [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md)
|
||||
- [ArrayTest](docs/ArrayTest.md)
|
||||
- [Cat](docs/Cat.md)
|
||||
- [Category](docs/Category.md)
|
||||
@@ -115,10 +108,13 @@ Class | Method | HTTP request | Description
|
||||
- [EnumClass](docs/EnumClass.md)
|
||||
- [EnumTest](docs/EnumTest.md)
|
||||
- [FormatTest](docs/FormatTest.md)
|
||||
- [HasOnlyReadOnly](docs/HasOnlyReadOnly.md)
|
||||
- [MapTest](docs/MapTest.md)
|
||||
- [MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md)
|
||||
- [Model200Response](docs/Model200Response.md)
|
||||
- [ModelReturn](docs/ModelReturn.md)
|
||||
- [Name](docs/Name.md)
|
||||
- [NumberOnly](docs/NumberOnly.md)
|
||||
- [Order](docs/Order.md)
|
||||
- [Pet](docs/Pet.md)
|
||||
- [ReadOnlyFirst](docs/ReadOnlyFirst.md)
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
# ArrayOfArrayOfNumberOnly
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**array_array_number** | **list[list[float]]** | | [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)
|
||||
|
||||
|
||||
10
samples/client/petstore/python/docs/ArrayOfNumberOnly.md
Normal file
10
samples/client/petstore/python/docs/ArrayOfNumberOnly.md
Normal file
@@ -0,0 +1,10 @@
|
||||
# ArrayOfNumberOnly
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**array_number** | **list[float]** | | [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)
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ Name | Type | Description | Notes
|
||||
**array_of_string** | **list[str]** | | [optional]
|
||||
**array_array_of_integer** | **list[list[int]]** | | [optional]
|
||||
**array_array_of_model** | **list[list[ReadOnlyFirst]]** | | [optional]
|
||||
**array_of_enum** | **list[str]** | | [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)
|
||||
|
||||
|
||||
@@ -4,9 +4,55 @@ All URIs are relative to *http://petstore.swagger.io/v2*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**test_code_inject__end**](FakeApi.md#test_code_inject__end) | **PUT** /fake | To test code injection */ =end
|
||||
[**test_endpoint_parameters**](FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
[**test_enum_query_parameters**](FakeApi.md#test_enum_query_parameters) | **GET** /fake | To test enum query parameters
|
||||
|
||||
|
||||
# **test_code_inject__end**
|
||||
> test_code_inject__end(test_code_inject__end=test_code_inject__end)
|
||||
|
||||
To test code injection */ =end
|
||||
|
||||
### Example
|
||||
```python
|
||||
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)
|
||||
|
||||
try:
|
||||
# To test code injection */ =end
|
||||
api_instance.test_code_inject__end(test_code_inject__end=test_code_inject__end)
|
||||
except ApiException as e:
|
||||
print "Exception when calling FakeApi->test_code_inject__end: %s\n" % e
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**test_code_inject__end** | **str**| To test code injection */ =end | [optional]
|
||||
|
||||
### Return type
|
||||
|
||||
void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json, */ =end));(phpinfo(
|
||||
- **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)
|
||||
|
||||
# **test_endpoint_parameters**
|
||||
> test_endpoint_parameters(number, double, string, byte, integer=integer, int32=int32, int64=int64, float=float, binary=binary, date=date, date_time=date_time, password=password)
|
||||
|
||||
@@ -75,3 +121,51 @@ No authorization required
|
||||
|
||||
[[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)
|
||||
|
||||
# **test_enum_query_parameters**
|
||||
> test_enum_query_parameters(enum_query_string=enum_query_string, enum_query_integer=enum_query_integer, enum_query_double=enum_query_double)
|
||||
|
||||
To test enum query parameters
|
||||
|
||||
### Example
|
||||
```python
|
||||
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()
|
||||
enum_query_string = '-efg' # str | Query parameter enum test (string) (optional) (default to -efg)
|
||||
enum_query_integer = 3.4 # float | Query parameter enum test (double) (optional)
|
||||
enum_query_double = 1.2 # float | Query parameter enum test (double) (optional)
|
||||
|
||||
try:
|
||||
# To test enum query parameters
|
||||
api_instance.test_enum_query_parameters(enum_query_string=enum_query_string, enum_query_integer=enum_query_integer, enum_query_double=enum_query_double)
|
||||
except ApiException as e:
|
||||
print "Exception when calling FakeApi->test_enum_query_parameters: %s\n" % e
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**enum_query_string** | **str**| Query parameter enum test (string) | [optional] [default to -efg]
|
||||
**enum_query_integer** | **float**| Query parameter enum test (double) | [optional]
|
||||
**enum_query_double** | **float**| Query parameter enum test (double) | [optional]
|
||||
|
||||
### Return type
|
||||
|
||||
void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json
|
||||
- **Accept**: application/json
|
||||
|
||||
[[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)
|
||||
|
||||
|
||||
11
samples/client/petstore/python/docs/HasOnlyReadOnly.md
Normal file
11
samples/client/petstore/python/docs/HasOnlyReadOnly.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# HasOnlyReadOnly
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**bar** | **str** | | [optional]
|
||||
**foo** | **str** | | [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)
|
||||
|
||||
|
||||
12
samples/client/petstore/python/docs/MapTest.md
Normal file
12
samples/client/petstore/python/docs/MapTest.md
Normal file
@@ -0,0 +1,12 @@
|
||||
# MapTest
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**map_map_of_string** | [**dict(str, dict(str, str))**](dict.md) | | [optional]
|
||||
**map_map_of_enum** | [**dict(str, dict(str, str))**](dict.md) | | [optional]
|
||||
**map_of_enum_string** | **dict(str, str)** | | [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)
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**name** | **int** | | [optional]
|
||||
**_class** | **str** | | [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)
|
||||
|
||||
|
||||
10
samples/client/petstore/python/docs/NumberOnly.md
Normal file
10
samples/client/petstore/python/docs/NumberOnly.md
Normal file
@@ -0,0 +1,10 @@
|
||||
# NumberOnly
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**just_number** | **float** | | [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)
|
||||
|
||||
|
||||
@@ -29,6 +29,8 @@ from .models.additional_properties_class import AdditionalPropertiesClass
|
||||
from .models.animal import Animal
|
||||
from .models.animal_farm import AnimalFarm
|
||||
from .models.api_response import ApiResponse
|
||||
from .models.array_of_array_of_number_only import ArrayOfArrayOfNumberOnly
|
||||
from .models.array_of_number_only import ArrayOfNumberOnly
|
||||
from .models.array_test import ArrayTest
|
||||
from .models.cat import Cat
|
||||
from .models.category import Category
|
||||
@@ -36,10 +38,13 @@ from .models.dog import Dog
|
||||
from .models.enum_class import EnumClass
|
||||
from .models.enum_test import EnumTest
|
||||
from .models.format_test import FormatTest
|
||||
from .models.has_only_read_only import HasOnlyReadOnly
|
||||
from .models.map_test import MapTest
|
||||
from .models.mixed_properties_and_additional_properties_class import MixedPropertiesAndAdditionalPropertiesClass
|
||||
from .models.model_200_response import Model200Response
|
||||
from .models.model_return import ModelReturn
|
||||
from .models.name import Name
|
||||
from .models.number_only import NumberOnly
|
||||
from .models.order import Order
|
||||
from .models.pet import Pet
|
||||
from .models.read_only_first import ReadOnlyFirst
|
||||
|
||||
@@ -51,6 +51,107 @@ class FakeApi(object):
|
||||
config.api_client = ApiClient()
|
||||
self.api_client = config.api_client
|
||||
|
||||
def test_code_inject__end(self, **kwargs):
|
||||
"""
|
||||
To test code injection */ =end
|
||||
|
||||
|
||||
This method makes a synchronous HTTP request by default. To make an
|
||||
asynchronous HTTP request, please define a `callback` function
|
||||
to be invoked when receiving the response.
|
||||
>>> def callback_function(response):
|
||||
>>> pprint(response)
|
||||
>>>
|
||||
>>> thread = api.test_code_inject__end(callback=callback_function)
|
||||
|
||||
:param callback function: The callback function
|
||||
for asynchronous request. (optional)
|
||||
:param str test_code_inject__end: To test code injection */ =end
|
||||
: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)
|
||||
else:
|
||||
(data) = self.test_code_inject__end_with_http_info(**kwargs)
|
||||
return data
|
||||
|
||||
def test_code_inject__end_with_http_info(self, **kwargs):
|
||||
"""
|
||||
To test code injection */ =end
|
||||
|
||||
|
||||
This method makes a synchronous HTTP request by default. To make an
|
||||
asynchronous HTTP request, please define a `callback` function
|
||||
to be invoked when receiving the response.
|
||||
>>> def callback_function(response):
|
||||
>>> pprint(response)
|
||||
>>>
|
||||
>>> thread = api.test_code_inject__end_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
|
||||
:return: None
|
||||
If the method is called asynchronously,
|
||||
returns the request thread.
|
||||
"""
|
||||
|
||||
all_params = ['test_code_inject__end']
|
||||
all_params.append('callback')
|
||||
all_params.append('_return_http_data_only')
|
||||
|
||||
params = locals()
|
||||
for key, val in iteritems(params['kwargs']):
|
||||
if key not in all_params:
|
||||
raise TypeError(
|
||||
"Got an unexpected keyword argument '%s'"
|
||||
" to method test_code_inject__end" % key
|
||||
)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resource_path = '/fake'.replace('{format}', 'json')
|
||||
path_params = {}
|
||||
|
||||
query_params = {}
|
||||
|
||||
header_params = {}
|
||||
|
||||
form_params = []
|
||||
local_var_files = {}
|
||||
if 'test_code_inject__end' in params:
|
||||
form_params.append(('test code inject */ =end', params['test_code_inject__end']))
|
||||
|
||||
body_params = None
|
||||
|
||||
# HTTP header `Accept`
|
||||
header_params['Accept'] = self.api_client.\
|
||||
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));(phpinfo('])
|
||||
|
||||
# Authentication setting
|
||||
auth_settings = []
|
||||
|
||||
return self.api_client.call_api(resource_path, 'PUT',
|
||||
path_params,
|
||||
query_params,
|
||||
header_params,
|
||||
body=body_params,
|
||||
post_params=form_params,
|
||||
files=local_var_files,
|
||||
response_type=None,
|
||||
auth_settings=auth_settings,
|
||||
callback=params.get('callback'),
|
||||
_return_http_data_only=params.get('_return_http_data_only'))
|
||||
|
||||
def test_endpoint_parameters(self, number, double, string, byte, **kwargs):
|
||||
"""
|
||||
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
@@ -231,3 +332,112 @@ class FakeApi(object):
|
||||
auth_settings=auth_settings,
|
||||
callback=params.get('callback'),
|
||||
_return_http_data_only=params.get('_return_http_data_only'))
|
||||
|
||||
def test_enum_query_parameters(self, **kwargs):
|
||||
"""
|
||||
To test enum query parameters
|
||||
|
||||
|
||||
This method makes a synchronous HTTP request by default. To make an
|
||||
asynchronous HTTP request, please define a `callback` function
|
||||
to be invoked when receiving the response.
|
||||
>>> def callback_function(response):
|
||||
>>> pprint(response)
|
||||
>>>
|
||||
>>> thread = api.test_enum_query_parameters(callback=callback_function)
|
||||
|
||||
:param callback function: The callback function
|
||||
for asynchronous request. (optional)
|
||||
:param str enum_query_string: Query parameter enum test (string)
|
||||
:param float enum_query_integer: Query parameter enum test (double)
|
||||
:param float enum_query_double: Query parameter enum test (double)
|
||||
: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_enum_query_parameters_with_http_info(**kwargs)
|
||||
else:
|
||||
(data) = self.test_enum_query_parameters_with_http_info(**kwargs)
|
||||
return data
|
||||
|
||||
def test_enum_query_parameters_with_http_info(self, **kwargs):
|
||||
"""
|
||||
To test enum query parameters
|
||||
|
||||
|
||||
This method makes a synchronous HTTP request by default. To make an
|
||||
asynchronous HTTP request, please define a `callback` function
|
||||
to be invoked when receiving the response.
|
||||
>>> def callback_function(response):
|
||||
>>> pprint(response)
|
||||
>>>
|
||||
>>> thread = api.test_enum_query_parameters_with_http_info(callback=callback_function)
|
||||
|
||||
:param callback function: The callback function
|
||||
for asynchronous request. (optional)
|
||||
:param str enum_query_string: Query parameter enum test (string)
|
||||
:param float enum_query_integer: Query parameter enum test (double)
|
||||
:param float enum_query_double: Query parameter enum test (double)
|
||||
:return: None
|
||||
If the method is called asynchronously,
|
||||
returns the request thread.
|
||||
"""
|
||||
|
||||
all_params = ['enum_query_string', 'enum_query_integer', 'enum_query_double']
|
||||
all_params.append('callback')
|
||||
all_params.append('_return_http_data_only')
|
||||
|
||||
params = locals()
|
||||
for key, val in iteritems(params['kwargs']):
|
||||
if key not in all_params:
|
||||
raise TypeError(
|
||||
"Got an unexpected keyword argument '%s'"
|
||||
" to method test_enum_query_parameters" % key
|
||||
)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
resource_path = '/fake'.replace('{format}', 'json')
|
||||
path_params = {}
|
||||
|
||||
query_params = {}
|
||||
if 'enum_query_integer' in params:
|
||||
query_params['enum_query_integer'] = params['enum_query_integer']
|
||||
|
||||
header_params = {}
|
||||
|
||||
form_params = []
|
||||
local_var_files = {}
|
||||
if 'enum_query_string' in params:
|
||||
form_params.append(('enum_query_string', params['enum_query_string']))
|
||||
if 'enum_query_double' in params:
|
||||
form_params.append(('enum_query_double', params['enum_query_double']))
|
||||
|
||||
body_params = None
|
||||
|
||||
# HTTP header `Accept`
|
||||
header_params['Accept'] = self.api_client.\
|
||||
select_header_accept(['application/json'])
|
||||
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'])
|
||||
|
||||
# Authentication setting
|
||||
auth_settings = []
|
||||
|
||||
return self.api_client.call_api(resource_path, 'GET',
|
||||
path_params,
|
||||
query_params,
|
||||
header_params,
|
||||
body=body_params,
|
||||
post_params=form_params,
|
||||
files=local_var_files,
|
||||
response_type=None,
|
||||
auth_settings=auth_settings,
|
||||
callback=params.get('callback'),
|
||||
_return_http_data_only=params.get('_return_http_data_only'))
|
||||
|
||||
@@ -29,6 +29,8 @@ from .additional_properties_class import AdditionalPropertiesClass
|
||||
from .animal import Animal
|
||||
from .animal_farm import AnimalFarm
|
||||
from .api_response import ApiResponse
|
||||
from .array_of_array_of_number_only import ArrayOfArrayOfNumberOnly
|
||||
from .array_of_number_only import ArrayOfNumberOnly
|
||||
from .array_test import ArrayTest
|
||||
from .cat import Cat
|
||||
from .category import Category
|
||||
@@ -36,10 +38,13 @@ from .dog import Dog
|
||||
from .enum_class import EnumClass
|
||||
from .enum_test import EnumTest
|
||||
from .format_test import FormatTest
|
||||
from .has_only_read_only import HasOnlyReadOnly
|
||||
from .map_test import MapTest
|
||||
from .mixed_properties_and_additional_properties_class import MixedPropertiesAndAdditionalPropertiesClass
|
||||
from .model_200_response import Model200Response
|
||||
from .model_return import ModelReturn
|
||||
from .name import Name
|
||||
from .number_only import NumberOnly
|
||||
from .order import Order
|
||||
from .pet import Pet
|
||||
from .read_only_first import ReadOnlyFirst
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
Swagger Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
OpenAPI spec version: 1.0.0
|
||||
Contact: apiteam@swagger.io
|
||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
|
||||
from pprint import pformat
|
||||
from six import iteritems
|
||||
import re
|
||||
|
||||
|
||||
class ArrayOfArrayOfNumberOnly(object):
|
||||
"""
|
||||
NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
def __init__(self, array_array_number=None):
|
||||
"""
|
||||
ArrayOfArrayOfNumberOnly - a model defined in Swagger
|
||||
|
||||
:param dict swaggerTypes: The key is attribute name
|
||||
and the value is attribute type.
|
||||
:param dict attributeMap: The key is attribute name
|
||||
and the value is json key in definition.
|
||||
"""
|
||||
self.swagger_types = {
|
||||
'array_array_number': 'list[list[float]]'
|
||||
}
|
||||
|
||||
self.attribute_map = {
|
||||
'array_array_number': 'ArrayArrayNumber'
|
||||
}
|
||||
|
||||
self._array_array_number = array_array_number
|
||||
|
||||
@property
|
||||
def array_array_number(self):
|
||||
"""
|
||||
Gets the array_array_number of this ArrayOfArrayOfNumberOnly.
|
||||
|
||||
|
||||
:return: The array_array_number of this ArrayOfArrayOfNumberOnly.
|
||||
:rtype: list[list[float]]
|
||||
"""
|
||||
return self._array_array_number
|
||||
|
||||
@array_array_number.setter
|
||||
def array_array_number(self, array_array_number):
|
||||
"""
|
||||
Sets the array_array_number of this ArrayOfArrayOfNumberOnly.
|
||||
|
||||
|
||||
:param array_array_number: The array_array_number of this ArrayOfArrayOfNumberOnly.
|
||||
:type: list[list[float]]
|
||||
"""
|
||||
|
||||
self._array_array_number = array_array_number
|
||||
|
||||
def to_dict(self):
|
||||
"""
|
||||
Returns the model properties as a dict
|
||||
"""
|
||||
result = {}
|
||||
|
||||
for attr, _ in iteritems(self.swagger_types):
|
||||
value = getattr(self, attr)
|
||||
if isinstance(value, list):
|
||||
result[attr] = list(map(
|
||||
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
|
||||
value
|
||||
))
|
||||
elif hasattr(value, "to_dict"):
|
||||
result[attr] = value.to_dict()
|
||||
elif isinstance(value, dict):
|
||||
result[attr] = dict(map(
|
||||
lambda item: (item[0], item[1].to_dict())
|
||||
if hasattr(item[1], "to_dict") else item,
|
||||
value.items()
|
||||
))
|
||||
else:
|
||||
result[attr] = value
|
||||
|
||||
return result
|
||||
|
||||
def to_str(self):
|
||||
"""
|
||||
Returns the string representation of the model
|
||||
"""
|
||||
return pformat(self.to_dict())
|
||||
|
||||
def __repr__(self):
|
||||
"""
|
||||
For `print` and `pprint`
|
||||
"""
|
||||
return self.to_str()
|
||||
|
||||
def __eq__(self, other):
|
||||
"""
|
||||
Returns true if both objects are equal
|
||||
"""
|
||||
return self.__dict__ == other.__dict__
|
||||
|
||||
def __ne__(self, other):
|
||||
"""
|
||||
Returns true if both objects are not equal
|
||||
"""
|
||||
return not self == other
|
||||
@@ -0,0 +1,125 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
Swagger Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
OpenAPI spec version: 1.0.0
|
||||
Contact: apiteam@swagger.io
|
||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
|
||||
from pprint import pformat
|
||||
from six import iteritems
|
||||
import re
|
||||
|
||||
|
||||
class ArrayOfNumberOnly(object):
|
||||
"""
|
||||
NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
def __init__(self, array_number=None):
|
||||
"""
|
||||
ArrayOfNumberOnly - a model defined in Swagger
|
||||
|
||||
:param dict swaggerTypes: The key is attribute name
|
||||
and the value is attribute type.
|
||||
:param dict attributeMap: The key is attribute name
|
||||
and the value is json key in definition.
|
||||
"""
|
||||
self.swagger_types = {
|
||||
'array_number': 'list[float]'
|
||||
}
|
||||
|
||||
self.attribute_map = {
|
||||
'array_number': 'ArrayNumber'
|
||||
}
|
||||
|
||||
self._array_number = array_number
|
||||
|
||||
@property
|
||||
def array_number(self):
|
||||
"""
|
||||
Gets the array_number of this ArrayOfNumberOnly.
|
||||
|
||||
|
||||
:return: The array_number of this ArrayOfNumberOnly.
|
||||
:rtype: list[float]
|
||||
"""
|
||||
return self._array_number
|
||||
|
||||
@array_number.setter
|
||||
def array_number(self, array_number):
|
||||
"""
|
||||
Sets the array_number of this ArrayOfNumberOnly.
|
||||
|
||||
|
||||
:param array_number: The array_number of this ArrayOfNumberOnly.
|
||||
:type: list[float]
|
||||
"""
|
||||
|
||||
self._array_number = array_number
|
||||
|
||||
def to_dict(self):
|
||||
"""
|
||||
Returns the model properties as a dict
|
||||
"""
|
||||
result = {}
|
||||
|
||||
for attr, _ in iteritems(self.swagger_types):
|
||||
value = getattr(self, attr)
|
||||
if isinstance(value, list):
|
||||
result[attr] = list(map(
|
||||
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
|
||||
value
|
||||
))
|
||||
elif hasattr(value, "to_dict"):
|
||||
result[attr] = value.to_dict()
|
||||
elif isinstance(value, dict):
|
||||
result[attr] = dict(map(
|
||||
lambda item: (item[0], item[1].to_dict())
|
||||
if hasattr(item[1], "to_dict") else item,
|
||||
value.items()
|
||||
))
|
||||
else:
|
||||
result[attr] = value
|
||||
|
||||
return result
|
||||
|
||||
def to_str(self):
|
||||
"""
|
||||
Returns the string representation of the model
|
||||
"""
|
||||
return pformat(self.to_dict())
|
||||
|
||||
def __repr__(self):
|
||||
"""
|
||||
For `print` and `pprint`
|
||||
"""
|
||||
return self.to_str()
|
||||
|
||||
def __eq__(self, other):
|
||||
"""
|
||||
Returns true if both objects are equal
|
||||
"""
|
||||
return self.__dict__ == other.__dict__
|
||||
|
||||
def __ne__(self, other):
|
||||
"""
|
||||
Returns true if both objects are not equal
|
||||
"""
|
||||
return not self == other
|
||||
@@ -32,7 +32,7 @@ class ArrayTest(object):
|
||||
NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
def __init__(self, array_of_string=None, array_array_of_integer=None, array_array_of_model=None):
|
||||
def __init__(self, array_of_string=None, array_array_of_integer=None, array_array_of_model=None, array_of_enum=None):
|
||||
"""
|
||||
ArrayTest - a model defined in Swagger
|
||||
|
||||
@@ -44,18 +44,21 @@ class ArrayTest(object):
|
||||
self.swagger_types = {
|
||||
'array_of_string': 'list[str]',
|
||||
'array_array_of_integer': 'list[list[int]]',
|
||||
'array_array_of_model': 'list[list[ReadOnlyFirst]]'
|
||||
'array_array_of_model': 'list[list[ReadOnlyFirst]]',
|
||||
'array_of_enum': 'list[str]'
|
||||
}
|
||||
|
||||
self.attribute_map = {
|
||||
'array_of_string': 'array_of_string',
|
||||
'array_array_of_integer': 'array_array_of_integer',
|
||||
'array_array_of_model': 'array_array_of_model'
|
||||
'array_array_of_model': 'array_array_of_model',
|
||||
'array_of_enum': 'array_of_enum'
|
||||
}
|
||||
|
||||
self._array_of_string = array_of_string
|
||||
self._array_array_of_integer = array_array_of_integer
|
||||
self._array_array_of_model = array_array_of_model
|
||||
self._array_of_enum = array_of_enum
|
||||
|
||||
@property
|
||||
def array_of_string(self):
|
||||
@@ -126,6 +129,35 @@ class ArrayTest(object):
|
||||
|
||||
self._array_array_of_model = array_array_of_model
|
||||
|
||||
@property
|
||||
def array_of_enum(self):
|
||||
"""
|
||||
Gets the array_of_enum of this ArrayTest.
|
||||
|
||||
|
||||
:return: The array_of_enum of this ArrayTest.
|
||||
:rtype: list[str]
|
||||
"""
|
||||
return self._array_of_enum
|
||||
|
||||
@array_of_enum.setter
|
||||
def array_of_enum(self, array_of_enum):
|
||||
"""
|
||||
Sets the array_of_enum of this ArrayTest.
|
||||
|
||||
|
||||
:param array_of_enum: The array_of_enum of this ArrayTest.
|
||||
:type: list[str]
|
||||
"""
|
||||
allowed_values = []
|
||||
if array_of_enum not in allowed_values:
|
||||
raise ValueError(
|
||||
"Invalid value for `array_of_enum`, must be one of {0}"
|
||||
.format(allowed_values)
|
||||
)
|
||||
|
||||
self._array_of_enum = array_of_enum
|
||||
|
||||
def to_dict(self):
|
||||
"""
|
||||
Returns the model properties as a dict
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
Swagger Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
OpenAPI spec version: 1.0.0
|
||||
Contact: apiteam@swagger.io
|
||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
|
||||
from pprint import pformat
|
||||
from six import iteritems
|
||||
import re
|
||||
|
||||
|
||||
class HasOnlyReadOnly(object):
|
||||
"""
|
||||
NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
def __init__(self):
|
||||
"""
|
||||
HasOnlyReadOnly - a model defined in Swagger
|
||||
|
||||
:param dict swaggerTypes: The key is attribute name
|
||||
and the value is attribute type.
|
||||
:param dict attributeMap: The key is attribute name
|
||||
and the value is json key in definition.
|
||||
"""
|
||||
self.swagger_types = {
|
||||
'bar': 'str',
|
||||
'foo': 'str'
|
||||
}
|
||||
|
||||
self.attribute_map = {
|
||||
'bar': 'bar',
|
||||
'foo': 'foo'
|
||||
}
|
||||
|
||||
self._bar = None
|
||||
self._foo = None
|
||||
|
||||
@property
|
||||
def bar(self):
|
||||
"""
|
||||
Gets the bar of this HasOnlyReadOnly.
|
||||
|
||||
|
||||
:return: The bar of this HasOnlyReadOnly.
|
||||
:rtype: str
|
||||
"""
|
||||
return self._bar
|
||||
|
||||
@property
|
||||
def foo(self):
|
||||
"""
|
||||
Gets the foo of this HasOnlyReadOnly.
|
||||
|
||||
|
||||
:return: The foo of this HasOnlyReadOnly.
|
||||
:rtype: str
|
||||
"""
|
||||
return self._foo
|
||||
|
||||
def to_dict(self):
|
||||
"""
|
||||
Returns the model properties as a dict
|
||||
"""
|
||||
result = {}
|
||||
|
||||
for attr, _ in iteritems(self.swagger_types):
|
||||
value = getattr(self, attr)
|
||||
if isinstance(value, list):
|
||||
result[attr] = list(map(
|
||||
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
|
||||
value
|
||||
))
|
||||
elif hasattr(value, "to_dict"):
|
||||
result[attr] = value.to_dict()
|
||||
elif isinstance(value, dict):
|
||||
result[attr] = dict(map(
|
||||
lambda item: (item[0], item[1].to_dict())
|
||||
if hasattr(item[1], "to_dict") else item,
|
||||
value.items()
|
||||
))
|
||||
else:
|
||||
result[attr] = value
|
||||
|
||||
return result
|
||||
|
||||
def to_str(self):
|
||||
"""
|
||||
Returns the string representation of the model
|
||||
"""
|
||||
return pformat(self.to_dict())
|
||||
|
||||
def __repr__(self):
|
||||
"""
|
||||
For `print` and `pprint`
|
||||
"""
|
||||
return self.to_str()
|
||||
|
||||
def __eq__(self, other):
|
||||
"""
|
||||
Returns true if both objects are equal
|
||||
"""
|
||||
return self.__dict__ == other.__dict__
|
||||
|
||||
def __ne__(self, other):
|
||||
"""
|
||||
Returns true if both objects are not equal
|
||||
"""
|
||||
return not self == other
|
||||
189
samples/client/petstore/python/petstore_api/models/map_test.py
Normal file
189
samples/client/petstore/python/petstore_api/models/map_test.py
Normal file
@@ -0,0 +1,189 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
Swagger Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
OpenAPI spec version: 1.0.0
|
||||
Contact: apiteam@swagger.io
|
||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
|
||||
from pprint import pformat
|
||||
from six import iteritems
|
||||
import re
|
||||
|
||||
|
||||
class MapTest(object):
|
||||
"""
|
||||
NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
def __init__(self, map_map_of_string=None, map_map_of_enum=None, map_of_enum_string=None):
|
||||
"""
|
||||
MapTest - a model defined in Swagger
|
||||
|
||||
:param dict swaggerTypes: The key is attribute name
|
||||
and the value is attribute type.
|
||||
:param dict attributeMap: The key is attribute name
|
||||
and the value is json key in definition.
|
||||
"""
|
||||
self.swagger_types = {
|
||||
'map_map_of_string': 'dict(str, dict(str, str))',
|
||||
'map_map_of_enum': 'dict(str, dict(str, str))',
|
||||
'map_of_enum_string': 'dict(str, str)'
|
||||
}
|
||||
|
||||
self.attribute_map = {
|
||||
'map_map_of_string': 'map_map_of_string',
|
||||
'map_map_of_enum': 'map_map_of_enum',
|
||||
'map_of_enum_string': 'map_of_enum_string'
|
||||
}
|
||||
|
||||
self._map_map_of_string = map_map_of_string
|
||||
self._map_map_of_enum = map_map_of_enum
|
||||
self._map_of_enum_string = map_of_enum_string
|
||||
|
||||
@property
|
||||
def map_map_of_string(self):
|
||||
"""
|
||||
Gets the map_map_of_string of this MapTest.
|
||||
|
||||
|
||||
:return: The map_map_of_string of this MapTest.
|
||||
:rtype: dict(str, dict(str, str))
|
||||
"""
|
||||
return self._map_map_of_string
|
||||
|
||||
@map_map_of_string.setter
|
||||
def map_map_of_string(self, map_map_of_string):
|
||||
"""
|
||||
Sets the map_map_of_string of this MapTest.
|
||||
|
||||
|
||||
:param map_map_of_string: The map_map_of_string of this MapTest.
|
||||
:type: dict(str, dict(str, str))
|
||||
"""
|
||||
|
||||
self._map_map_of_string = map_map_of_string
|
||||
|
||||
@property
|
||||
def map_map_of_enum(self):
|
||||
"""
|
||||
Gets the map_map_of_enum of this MapTest.
|
||||
|
||||
|
||||
:return: The map_map_of_enum of this MapTest.
|
||||
:rtype: dict(str, dict(str, str))
|
||||
"""
|
||||
return self._map_map_of_enum
|
||||
|
||||
@map_map_of_enum.setter
|
||||
def map_map_of_enum(self, map_map_of_enum):
|
||||
"""
|
||||
Sets the map_map_of_enum of this MapTest.
|
||||
|
||||
|
||||
:param map_map_of_enum: The map_map_of_enum of this MapTest.
|
||||
:type: dict(str, dict(str, str))
|
||||
"""
|
||||
allowed_values = []
|
||||
if map_map_of_enum not in allowed_values:
|
||||
raise ValueError(
|
||||
"Invalid value for `map_map_of_enum`, must be one of {0}"
|
||||
.format(allowed_values)
|
||||
)
|
||||
|
||||
self._map_map_of_enum = map_map_of_enum
|
||||
|
||||
@property
|
||||
def map_of_enum_string(self):
|
||||
"""
|
||||
Gets the map_of_enum_string of this MapTest.
|
||||
|
||||
|
||||
:return: The map_of_enum_string of this MapTest.
|
||||
:rtype: dict(str, str)
|
||||
"""
|
||||
return self._map_of_enum_string
|
||||
|
||||
@map_of_enum_string.setter
|
||||
def map_of_enum_string(self, map_of_enum_string):
|
||||
"""
|
||||
Sets the map_of_enum_string of this MapTest.
|
||||
|
||||
|
||||
:param map_of_enum_string: The map_of_enum_string of this MapTest.
|
||||
:type: dict(str, str)
|
||||
"""
|
||||
allowed_values = []
|
||||
if map_of_enum_string not in allowed_values:
|
||||
raise ValueError(
|
||||
"Invalid value for `map_of_enum_string`, must be one of {0}"
|
||||
.format(allowed_values)
|
||||
)
|
||||
|
||||
self._map_of_enum_string = map_of_enum_string
|
||||
|
||||
def to_dict(self):
|
||||
"""
|
||||
Returns the model properties as a dict
|
||||
"""
|
||||
result = {}
|
||||
|
||||
for attr, _ in iteritems(self.swagger_types):
|
||||
value = getattr(self, attr)
|
||||
if isinstance(value, list):
|
||||
result[attr] = list(map(
|
||||
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
|
||||
value
|
||||
))
|
||||
elif hasattr(value, "to_dict"):
|
||||
result[attr] = value.to_dict()
|
||||
elif isinstance(value, dict):
|
||||
result[attr] = dict(map(
|
||||
lambda item: (item[0], item[1].to_dict())
|
||||
if hasattr(item[1], "to_dict") else item,
|
||||
value.items()
|
||||
))
|
||||
else:
|
||||
result[attr] = value
|
||||
|
||||
return result
|
||||
|
||||
def to_str(self):
|
||||
"""
|
||||
Returns the string representation of the model
|
||||
"""
|
||||
return pformat(self.to_dict())
|
||||
|
||||
def __repr__(self):
|
||||
"""
|
||||
For `print` and `pprint`
|
||||
"""
|
||||
return self.to_str()
|
||||
|
||||
def __eq__(self, other):
|
||||
"""
|
||||
Returns true if both objects are equal
|
||||
"""
|
||||
return self.__dict__ == other.__dict__
|
||||
|
||||
def __ne__(self, other):
|
||||
"""
|
||||
Returns true if both objects are not equal
|
||||
"""
|
||||
return not self == other
|
||||
@@ -32,7 +32,7 @@ class Model200Response(object):
|
||||
NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
def __init__(self, name=None):
|
||||
def __init__(self, name=None, _class=None):
|
||||
"""
|
||||
Model200Response - a model defined in Swagger
|
||||
|
||||
@@ -42,14 +42,17 @@ class Model200Response(object):
|
||||
and the value is json key in definition.
|
||||
"""
|
||||
self.swagger_types = {
|
||||
'name': 'int'
|
||||
'name': 'int',
|
||||
'_class': 'str'
|
||||
}
|
||||
|
||||
self.attribute_map = {
|
||||
'name': 'name'
|
||||
'name': 'name',
|
||||
'_class': 'class'
|
||||
}
|
||||
|
||||
self._name = name
|
||||
self.__class = _class
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
@@ -74,6 +77,29 @@ class Model200Response(object):
|
||||
|
||||
self._name = name
|
||||
|
||||
@property
|
||||
def _class(self):
|
||||
"""
|
||||
Gets the _class of this Model200Response.
|
||||
|
||||
|
||||
:return: The _class of this Model200Response.
|
||||
:rtype: str
|
||||
"""
|
||||
return self.__class
|
||||
|
||||
@_class.setter
|
||||
def _class(self, _class):
|
||||
"""
|
||||
Sets the _class of this Model200Response.
|
||||
|
||||
|
||||
:param _class: The _class of this Model200Response.
|
||||
:type: str
|
||||
"""
|
||||
|
||||
self.__class = _class
|
||||
|
||||
def to_dict(self):
|
||||
"""
|
||||
Returns the model properties as a dict
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
Swagger Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
OpenAPI spec version: 1.0.0
|
||||
Contact: apiteam@swagger.io
|
||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
|
||||
from pprint import pformat
|
||||
from six import iteritems
|
||||
import re
|
||||
|
||||
|
||||
class NumberOnly(object):
|
||||
"""
|
||||
NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
def __init__(self, just_number=None):
|
||||
"""
|
||||
NumberOnly - a model defined in Swagger
|
||||
|
||||
:param dict swaggerTypes: The key is attribute name
|
||||
and the value is attribute type.
|
||||
:param dict attributeMap: The key is attribute name
|
||||
and the value is json key in definition.
|
||||
"""
|
||||
self.swagger_types = {
|
||||
'just_number': 'float'
|
||||
}
|
||||
|
||||
self.attribute_map = {
|
||||
'just_number': 'JustNumber'
|
||||
}
|
||||
|
||||
self._just_number = just_number
|
||||
|
||||
@property
|
||||
def just_number(self):
|
||||
"""
|
||||
Gets the just_number of this NumberOnly.
|
||||
|
||||
|
||||
:return: The just_number of this NumberOnly.
|
||||
:rtype: float
|
||||
"""
|
||||
return self._just_number
|
||||
|
||||
@just_number.setter
|
||||
def just_number(self, just_number):
|
||||
"""
|
||||
Sets the just_number of this NumberOnly.
|
||||
|
||||
|
||||
:param just_number: The just_number of this NumberOnly.
|
||||
:type: float
|
||||
"""
|
||||
|
||||
self._just_number = just_number
|
||||
|
||||
def to_dict(self):
|
||||
"""
|
||||
Returns the model properties as a dict
|
||||
"""
|
||||
result = {}
|
||||
|
||||
for attr, _ in iteritems(self.swagger_types):
|
||||
value = getattr(self, attr)
|
||||
if isinstance(value, list):
|
||||
result[attr] = list(map(
|
||||
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
|
||||
value
|
||||
))
|
||||
elif hasattr(value, "to_dict"):
|
||||
result[attr] = value.to_dict()
|
||||
elif isinstance(value, dict):
|
||||
result[attr] = dict(map(
|
||||
lambda item: (item[0], item[1].to_dict())
|
||||
if hasattr(item[1], "to_dict") else item,
|
||||
value.items()
|
||||
))
|
||||
else:
|
||||
result[attr] = value
|
||||
|
||||
return result
|
||||
|
||||
def to_str(self):
|
||||
"""
|
||||
Returns the string representation of the model
|
||||
"""
|
||||
return pformat(self.to_dict())
|
||||
|
||||
def __repr__(self):
|
||||
"""
|
||||
For `print` and `pprint`
|
||||
"""
|
||||
return self.to_str()
|
||||
|
||||
def __eq__(self, other):
|
||||
"""
|
||||
Returns true if both objects are equal
|
||||
"""
|
||||
return self.__dict__ == other.__dict__
|
||||
|
||||
def __ne__(self, other):
|
||||
"""
|
||||
Returns true if both objects are not equal
|
||||
"""
|
||||
return not self == other
|
||||
@@ -0,0 +1,53 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
Swagger Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
OpenAPI spec version: 1.0.0
|
||||
Contact: apiteam@swagger.io
|
||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from petstore_api.models.array_of_array_of_number_only import ArrayOfArrayOfNumberOnly
|
||||
|
||||
|
||||
class TestArrayOfArrayOfNumberOnly(unittest.TestCase):
|
||||
""" ArrayOfArrayOfNumberOnly unit test stubs """
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def testArrayOfArrayOfNumberOnly(self):
|
||||
"""
|
||||
Test ArrayOfArrayOfNumberOnly
|
||||
"""
|
||||
model = petstore_api.models.array_of_array_of_number_only.ArrayOfArrayOfNumberOnly()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,53 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
Swagger Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
OpenAPI spec version: 1.0.0
|
||||
Contact: apiteam@swagger.io
|
||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from petstore_api.models.array_of_number_only import ArrayOfNumberOnly
|
||||
|
||||
|
||||
class TestArrayOfNumberOnly(unittest.TestCase):
|
||||
""" ArrayOfNumberOnly unit test stubs """
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def testArrayOfNumberOnly(self):
|
||||
"""
|
||||
Test ArrayOfNumberOnly
|
||||
"""
|
||||
model = petstore_api.models.array_of_number_only.ArrayOfNumberOnly()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,53 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
Swagger Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
OpenAPI spec version: 1.0.0
|
||||
Contact: apiteam@swagger.io
|
||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from petstore_api.models.has_only_read_only import HasOnlyReadOnly
|
||||
|
||||
|
||||
class TestHasOnlyReadOnly(unittest.TestCase):
|
||||
""" HasOnlyReadOnly unit test stubs """
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def testHasOnlyReadOnly(self):
|
||||
"""
|
||||
Test HasOnlyReadOnly
|
||||
"""
|
||||
model = petstore_api.models.has_only_read_only.HasOnlyReadOnly()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
53
samples/client/petstore/python/test/test_map_test.py
Normal file
53
samples/client/petstore/python/test/test_map_test.py
Normal file
@@ -0,0 +1,53 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
Swagger Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
OpenAPI spec version: 1.0.0
|
||||
Contact: apiteam@swagger.io
|
||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from petstore_api.models.map_test import MapTest
|
||||
|
||||
|
||||
class TestMapTest(unittest.TestCase):
|
||||
""" MapTest unit test stubs """
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def testMapTest(self):
|
||||
"""
|
||||
Test MapTest
|
||||
"""
|
||||
model = petstore_api.models.map_test.MapTest()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
53
samples/client/petstore/python/test/test_number_only.py
Normal file
53
samples/client/petstore/python/test/test_number_only.py
Normal file
@@ -0,0 +1,53 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
Swagger Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
OpenAPI spec version: 1.0.0
|
||||
Contact: apiteam@swagger.io
|
||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from petstore_api.models.number_only import NumberOnly
|
||||
|
||||
|
||||
class TestNumberOnly(unittest.TestCase):
|
||||
""" NumberOnly unit test stubs """
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def testNumberOnly(self):
|
||||
"""
|
||||
Test NumberOnly
|
||||
"""
|
||||
model = petstore_api.models.number_only.NumberOnly()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user