mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-06-05 08:20:53 +00:00
remove python3 generator
This commit is contained in:
parent
cbc2fb237d
commit
3dc3af8d18
@ -1,31 +0,0 @@
|
|||||||
#!/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/python3 -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l python3 -o samples/client/petstore/python3"
|
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
|
@ -1,219 +0,0 @@
|
|||||||
package io.swagger.codegen.languages;
|
|
||||||
|
|
||||||
import io.swagger.codegen.CodegenConfig;
|
|
||||||
import io.swagger.codegen.CodegenType;
|
|
||||||
import io.swagger.codegen.DefaultCodegen;
|
|
||||||
import io.swagger.codegen.SupportingFile;
|
|
||||||
import io.swagger.models.properties.ArrayProperty;
|
|
||||||
import io.swagger.models.properties.MapProperty;
|
|
||||||
import io.swagger.models.properties.Property;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashSet;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
|
||||||
|
|
||||||
public class Python3ClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|
||||||
String module = "client";
|
|
||||||
|
|
||||||
public Python3ClientCodegen() {
|
|
||||||
super();
|
|
||||||
outputFolder = "generated-code/python3";
|
|
||||||
modelTemplateFiles.put("model.mustache", ".py");
|
|
||||||
apiTemplateFiles.put("api.mustache", ".py");
|
|
||||||
templateDir = "python3";
|
|
||||||
|
|
||||||
apiPackage = module;
|
|
||||||
modelPackage = module + ".models";
|
|
||||||
|
|
||||||
languageSpecificPrimitives.clear();
|
|
||||||
languageSpecificPrimitives.add("int");
|
|
||||||
languageSpecificPrimitives.add("float");
|
|
||||||
//languageSpecificPrimitives.add("long");
|
|
||||||
languageSpecificPrimitives.add("list");
|
|
||||||
languageSpecificPrimitives.add("bool");
|
|
||||||
languageSpecificPrimitives.add("str");
|
|
||||||
languageSpecificPrimitives.add("datetime");
|
|
||||||
languageSpecificPrimitives.add("date");
|
|
||||||
|
|
||||||
typeMapping.clear();
|
|
||||||
typeMapping.put("integer", "int");
|
|
||||||
typeMapping.put("float", "float");
|
|
||||||
typeMapping.put("long", "int");
|
|
||||||
typeMapping.put("double", "float");
|
|
||||||
typeMapping.put("array", "list");
|
|
||||||
typeMapping.put("map", "map");
|
|
||||||
typeMapping.put("boolean", "bool");
|
|
||||||
typeMapping.put("string", "str");
|
|
||||||
typeMapping.put("date", "date");
|
|
||||||
typeMapping.put("DateTime", "datetime");
|
|
||||||
|
|
||||||
// from https://docs.python.org/release/2.5.4/ref/keywords.html
|
|
||||||
reservedWords = new HashSet<String>(
|
|
||||||
Arrays.asList(
|
|
||||||
"and", "del", "from", "not", "while", "as", "elif", "global", "or", "with",
|
|
||||||
"assert", "else", "if", "pass", "yield", "break", "except", "import",
|
|
||||||
"print", "class", "exec", "in", "raise", "continue", "finally", "is",
|
|
||||||
"return", "def", "for", "lambda", "try"));
|
|
||||||
|
|
||||||
//supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
|
||||||
supportingFiles.add(new SupportingFile("swagger.mustache", module, "swagger.py"));
|
|
||||||
supportingFiles.add(new SupportingFile("__init__.mustache", module, "__init__.py"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public CodegenType getTag() {
|
|
||||||
return CodegenType.CLIENT;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return "python3";
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getHelp() {
|
|
||||||
return "Generates a Python3 client library.";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String escapeReservedWord(String name) {
|
|
||||||
return "_" + name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String apiFileFolder() {
|
|
||||||
return outputFolder + "/" + apiPackage().replace('.', File.separatorChar);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String modelFileFolder() {
|
|
||||||
return outputFolder + "/" + modelPackage().replace('.', File.separatorChar);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getTypeDeclaration(Property p) {
|
|
||||||
if (p instanceof ArrayProperty) {
|
|
||||||
ArrayProperty ap = (ArrayProperty) p;
|
|
||||||
Property inner = ap.getItems();
|
|
||||||
return getSwaggerType(p) + "[" + getTypeDeclaration(inner) + "]";
|
|
||||||
} else if (p instanceof MapProperty) {
|
|
||||||
MapProperty mp = (MapProperty) p;
|
|
||||||
Property inner = mp.getAdditionalProperties();
|
|
||||||
|
|
||||||
return getSwaggerType(p) + "(String, " + getTypeDeclaration(inner) + ")";
|
|
||||||
}
|
|
||||||
return super.getTypeDeclaration(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getSwaggerType(Property p) {
|
|
||||||
String swaggerType = super.getSwaggerType(p);
|
|
||||||
String type = null;
|
|
||||||
if (typeMapping.containsKey(swaggerType)) {
|
|
||||||
type = typeMapping.get(swaggerType);
|
|
||||||
if (languageSpecificPrimitives.contains(type)) {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
type = swaggerType;
|
|
||||||
}
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toDefaultValue(Property p) {
|
|
||||||
// TODO: Support Python def value
|
|
||||||
return "null";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toVarName(String name) {
|
|
||||||
// replace - with _ e.g. created-at => created_at
|
|
||||||
name = name.replaceAll("-", "_");
|
|
||||||
|
|
||||||
// if it's all uppper case, convert to lower case
|
|
||||||
if (name.matches("^[A-Z_]*$")) {
|
|
||||||
name = name.toLowerCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
// camelize (lower first character) the variable name
|
|
||||||
// petId => pet_id
|
|
||||||
name = underscore(name);
|
|
||||||
|
|
||||||
// for reserved word or word starting with number, append _
|
|
||||||
if (reservedWords.contains(name) || name.matches("^\\d.*")) {
|
|
||||||
name = escapeReservedWord(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toParamName(String name) {
|
|
||||||
// should be the same as variable name
|
|
||||||
return toVarName(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toModelName(String name) {
|
|
||||||
// model name cannot use reserved keyword, e.g. return
|
|
||||||
if (reservedWords.contains(name)) {
|
|
||||||
throw new RuntimeException(name + " (reserved word) cannot be used as a model name");
|
|
||||||
}
|
|
||||||
|
|
||||||
// camelize the model name
|
|
||||||
// phone_number => PhoneNumber
|
|
||||||
return camelize(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toModelFilename(String name) {
|
|
||||||
// model name cannot use reserved keyword, e.g. return
|
|
||||||
if (reservedWords.contains(name)) {
|
|
||||||
throw new RuntimeException(name + " (reserved word) cannot be used as a model name");
|
|
||||||
}
|
|
||||||
|
|
||||||
// underscore the model file name
|
|
||||||
// PhoneNumber.rb => phone_number.rb
|
|
||||||
return underscore(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toApiFilename(String name) {
|
|
||||||
// replace - with _ e.g. created-at => created_at
|
|
||||||
name = name.replaceAll("-", "_");
|
|
||||||
|
|
||||||
// e.g. PhoneNumberApi.rb => phone_number_api.rb
|
|
||||||
return underscore(name) + "_api";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toApiName(String name) {
|
|
||||||
if (name.length() == 0) {
|
|
||||||
return "DefaultApi";
|
|
||||||
}
|
|
||||||
// e.g. phone_number_api => PhoneNumberApi
|
|
||||||
return camelize(name) + "Api";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toApiVarName(String name) {
|
|
||||||
if (name.length() == 0) {
|
|
||||||
return "default_api";
|
|
||||||
}
|
|
||||||
return underscore(name) + "_api";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toOperationId(String operationId) {
|
|
||||||
// throw exception if method name is empty
|
|
||||||
if (StringUtils.isEmpty(operationId)) {
|
|
||||||
throw new RuntimeException("Empty method name (operationId) not allowed");
|
|
||||||
}
|
|
||||||
|
|
||||||
// method name cannot use reserved keyword, e.g. return
|
|
||||||
if (reservedWords.contains(operationId)) {
|
|
||||||
throw new RuntimeException(operationId + " (reserved word) cannot be used as method name");
|
|
||||||
}
|
|
||||||
|
|
||||||
return underscore(operationId);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -11,7 +11,6 @@ io.swagger.codegen.languages.ObjcClientCodegen
|
|||||||
io.swagger.codegen.languages.PerlClientCodegen
|
io.swagger.codegen.languages.PerlClientCodegen
|
||||||
io.swagger.codegen.languages.PhpClientCodegen
|
io.swagger.codegen.languages.PhpClientCodegen
|
||||||
io.swagger.codegen.languages.PythonClientCodegen
|
io.swagger.codegen.languages.PythonClientCodegen
|
||||||
io.swagger.codegen.languages.Python3ClientCodegen
|
|
||||||
io.swagger.codegen.languages.Qt5CPPGenerator
|
io.swagger.codegen.languages.Qt5CPPGenerator
|
||||||
io.swagger.codegen.languages.RetrofitClientCodegen
|
io.swagger.codegen.languages.RetrofitClientCodegen
|
||||||
io.swagger.codegen.languages.RubyClientCodegen
|
io.swagger.codegen.languages.RubyClientCodegen
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
"""Add all of the modules in the current directory to __all__"""
|
|
||||||
import os
|
|
||||||
|
|
||||||
__all__ = []
|
|
||||||
|
|
||||||
for module in os.listdir(os.path.dirname(__file__)):
|
|
||||||
if module != '__init__.py' and module[-3:] == '.py':
|
|
||||||
__all__.append(module[:-3])
|
|
@ -1,95 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
"""
|
|
||||||
{{classname}}.py
|
|
||||||
Copyright 2015 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.
|
|
||||||
|
|
||||||
NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
|
||||||
"""
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
|
|
||||||
from .models import *
|
|
||||||
|
|
||||||
|
|
||||||
{{#operations}}
|
|
||||||
class {{classname}}(object):
|
|
||||||
|
|
||||||
def __init__(self, apiClient):
|
|
||||||
self.apiClient = apiClient
|
|
||||||
|
|
||||||
{{newline}}
|
|
||||||
{{#operation}}
|
|
||||||
def {{nickname}}(self, {{#requiredParams}}{{paramName}}{{#defaultValue}} = None{{/defaultValue}}, {{/requiredParams}}**kwargs):
|
|
||||||
"""{{{summary}}}
|
|
||||||
{{{notes}}}
|
|
||||||
|
|
||||||
Args:
|
|
||||||
{{#allParams}}{{paramName}}, {{dataType}}: {{{description}}} {{#required}}(required){{/required}}{{^required}}(optional){{/required}}
|
|
||||||
{{/allParams}}
|
|
||||||
|
|
||||||
Returns: {{returnType}}
|
|
||||||
"""
|
|
||||||
|
|
||||||
allParams = [{{#allParams}}'{{paramName}}'{{#hasMore}}, {{/hasMore}}{{/allParams}}]
|
|
||||||
|
|
||||||
params = locals()
|
|
||||||
for (key, val) in params['kwargs'].items():
|
|
||||||
if key not in allParams:
|
|
||||||
raise TypeError("Got an unexpected keyword argument '%s' to method {{nickname}}" % key)
|
|
||||||
params[key] = val
|
|
||||||
del params['kwargs']
|
|
||||||
|
|
||||||
resourcePath = '{{path}}'
|
|
||||||
resourcePath = resourcePath.replace('{format}', 'json')
|
|
||||||
method = '{{httpMethod}}'
|
|
||||||
|
|
||||||
queryParams = {}
|
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
{{#queryParams}}
|
|
||||||
if ('{{paramName}}' in params):
|
|
||||||
queryParams['{{paramName}}'] = self.apiClient.toPathValue(params['{{paramName}}'])
|
|
||||||
{{/queryParams}}
|
|
||||||
|
|
||||||
{{#headerParams}}
|
|
||||||
if ('{{paramName}}' in params):
|
|
||||||
headerParams['{{paramName}}'] = params['{{paramName}}']
|
|
||||||
{{/headerParams}}
|
|
||||||
|
|
||||||
{{#pathParams}}
|
|
||||||
if ('{{paramName}}' in params):
|
|
||||||
replacement = str(self.apiClient.toPathValue(params['{{paramName}}']))
|
|
||||||
resourcePath = resourcePath.replace('{' + '{{baseName}}' + '}',
|
|
||||||
replacement)
|
|
||||||
{{/pathParams}}
|
|
||||||
|
|
||||||
postData = (params['body'] if 'body' in params else None)
|
|
||||||
|
|
||||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
|
||||||
postData, headerParams)
|
|
||||||
|
|
||||||
{{#returnType}}
|
|
||||||
if not response:
|
|
||||||
return None
|
|
||||||
|
|
||||||
responseObject = self.apiClient.deserialize(response, '{{returnType}}')
|
|
||||||
return responseObject
|
|
||||||
{{/returnType}}
|
|
||||||
{{newline}}
|
|
||||||
{{newline}}
|
|
||||||
{{/operation}}
|
|
||||||
{{newline}}
|
|
||||||
{{/operations}}
|
|
||||||
{{newline}}
|
|
@ -1,40 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
"""
|
|
||||||
Copyright 2015 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.
|
|
||||||
"""
|
|
||||||
{{#models}}
|
|
||||||
{{#model}}
|
|
||||||
|
|
||||||
class {{classname}}:
|
|
||||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
|
||||||
Do not edit the class manually."""
|
|
||||||
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
self.swaggerTypes = {
|
|
||||||
{{#vars}}
|
|
||||||
'{{name}}': '{{{datatype}}}'{{#hasMore}},
|
|
||||||
{{/hasMore}}
|
|
||||||
{{/vars}}{{newline}}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
{{#vars}}
|
|
||||||
{{#description}}#{{description}}
|
|
||||||
{{/description}}
|
|
||||||
self.{{name}} = None # {{{datatype}}}
|
|
||||||
{{/vars}}
|
|
||||||
{{/model}}
|
|
||||||
{{/models}}
|
|
@ -1,230 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
"""Wordnik.com's 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."""
|
|
||||||
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
import re
|
|
||||||
import urllib.request, urllib.error, urllib.parse
|
|
||||||
import http.client
|
|
||||||
import json
|
|
||||||
import datetime
|
|
||||||
|
|
||||||
from .models import *
|
|
||||||
|
|
||||||
|
|
||||||
class ApiClient:
|
|
||||||
"""Generic API client for Swagger client library builds"""
|
|
||||||
|
|
||||||
def __init__(self, apiKey=None, apiServer=None, cookie=None):
|
|
||||||
if apiKey == None:
|
|
||||||
raise Exception('You must pass an apiKey when instantiating the '
|
|
||||||
'APIClient')
|
|
||||||
self.apiKey = apiKey
|
|
||||||
self.apiServer = apiServer
|
|
||||||
self.cookie = cookie
|
|
||||||
|
|
||||||
def callAPI(self, resourcePath, method, queryParams, postData,
|
|
||||||
headerParams=None):
|
|
||||||
|
|
||||||
url = self.apiServer + resourcePath
|
|
||||||
headers = {}
|
|
||||||
if headerParams:
|
|
||||||
for param, value in headerParams.items():
|
|
||||||
headers[param] = value
|
|
||||||
|
|
||||||
#headers['Content-type'] = 'application/json'
|
|
||||||
headers['api_key'] = self.apiKey
|
|
||||||
|
|
||||||
if self.cookie:
|
|
||||||
headers['Cookie'] = self.cookie
|
|
||||||
|
|
||||||
data = None
|
|
||||||
|
|
||||||
if queryParams:
|
|
||||||
# Need to remove None values, these should not be sent
|
|
||||||
sentQueryParams = {}
|
|
||||||
for param, value in queryParams.items():
|
|
||||||
if value != None:
|
|
||||||
sentQueryParams[param] = value
|
|
||||||
url = url + '?' + urllib.parse.urlencode(sentQueryParams)
|
|
||||||
|
|
||||||
if method in ['GET']:
|
|
||||||
|
|
||||||
#Options to add statements later on and for compatibility
|
|
||||||
pass
|
|
||||||
|
|
||||||
elif method in ['PATCH', 'POST', 'PUT', 'DELETE']:
|
|
||||||
|
|
||||||
if postData:
|
|
||||||
headers['Content-type'] = 'application/json'
|
|
||||||
data = self.sanitizeForSerialization(postData)
|
|
||||||
data = json.dumps(data)
|
|
||||||
|
|
||||||
else:
|
|
||||||
raise Exception('Method ' + method + ' is not recognized.')
|
|
||||||
|
|
||||||
if data:
|
|
||||||
data = data.encode('utf-8')
|
|
||||||
|
|
||||||
requestParams = MethodRequest(method=method, url=url,
|
|
||||||
headers=headers, data=data)
|
|
||||||
|
|
||||||
# Make the request
|
|
||||||
request = urllib.request.urlopen(requestParams)
|
|
||||||
encoding = request.headers.get_content_charset()
|
|
||||||
if not encoding:
|
|
||||||
encoding = 'iso-8859-1'
|
|
||||||
response = request.read().decode(encoding)
|
|
||||||
|
|
||||||
try:
|
|
||||||
data = json.loads(response)
|
|
||||||
except ValueError: # PUT requests don't return anything
|
|
||||||
data = None
|
|
||||||
|
|
||||||
return data
|
|
||||||
|
|
||||||
def toPathValue(self, obj):
|
|
||||||
"""Convert a string or object to a path-friendly value
|
|
||||||
Args:
|
|
||||||
obj -- object or string value
|
|
||||||
Returns:
|
|
||||||
string -- quoted value
|
|
||||||
"""
|
|
||||||
if type(obj) == list:
|
|
||||||
return urllib.parse.quote(','.join(obj))
|
|
||||||
else:
|
|
||||||
return urllib.parse.quote(str(obj))
|
|
||||||
|
|
||||||
def sanitizeForSerialization(self, obj):
|
|
||||||
"""Dump an object into JSON for POSTing."""
|
|
||||||
|
|
||||||
if type(obj) == type(None):
|
|
||||||
return None
|
|
||||||
elif type(obj) in [str, int, float, bool]:
|
|
||||||
return obj
|
|
||||||
elif type(obj) == list:
|
|
||||||
return [self.sanitizeForSerialization(subObj) for subObj in obj]
|
|
||||||
elif type(obj) == datetime.datetime:
|
|
||||||
return obj.isoformat()
|
|
||||||
else:
|
|
||||||
if type(obj) == dict:
|
|
||||||
objDict = obj
|
|
||||||
else:
|
|
||||||
objDict = obj.__dict__
|
|
||||||
return {key: self.sanitizeForSerialization(val)
|
|
||||||
for (key, val) in objDict.items()
|
|
||||||
if key != 'swaggerTypes'}
|
|
||||||
|
|
||||||
def _iso8601Format(self, timesep, microsecond, offset, zulu):
|
|
||||||
"""Format for parsing a datetime string with given properties.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
timesep -- string separating time from date ('T' or 't')
|
|
||||||
microsecond -- microsecond portion of time ('.XXX')
|
|
||||||
offset -- time offset (+/-XX:XX) or None
|
|
||||||
zulu -- 'Z' or 'z' for UTC, or None for time offset (+/-XX:XX)
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
str - format string for datetime.strptime"""
|
|
||||||
|
|
||||||
return '%Y-%m-%d{}%H:%M:%S{}{}'.format(
|
|
||||||
timesep,
|
|
||||||
'.%f' if microsecond else '',
|
|
||||||
zulu or ('%z' if offset else ''))
|
|
||||||
|
|
||||||
# http://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14
|
|
||||||
_iso8601Regex = re.compile(
|
|
||||||
r'^\d\d\d\d-\d\d-\d\d([Tt])\d\d:\d\d:\d\d(\.\d+)?(([Zz])|(\+|-)\d\d:?\d\d)?$')
|
|
||||||
|
|
||||||
def _parseDatetime(self, d):
|
|
||||||
if d is None:
|
|
||||||
return None
|
|
||||||
m = ApiClient._iso8601Regex.match(d)
|
|
||||||
if not m:
|
|
||||||
raise Exception('datetime regex match failed "%s"' % d)
|
|
||||||
timesep, microsecond, offset, zulu, plusminus = m.groups()
|
|
||||||
format = self._iso8601Format(timesep, microsecond, offset, zulu)
|
|
||||||
if offset and not zulu:
|
|
||||||
d = d.rsplit(sep=plusminus, maxsplit=1)[0] + offset.replace(':', '')
|
|
||||||
return datetime.datetime.strptime(d, format)
|
|
||||||
|
|
||||||
def deserialize(self, obj, objClass):
|
|
||||||
"""Derialize a JSON string into an object.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
obj -- string or object to be deserialized
|
|
||||||
objClass -- class literal for deserialzied object, or string
|
|
||||||
of class name
|
|
||||||
Returns:
|
|
||||||
object -- deserialized object"""
|
|
||||||
|
|
||||||
# Have to accept objClass as string or actual type. Type could be a
|
|
||||||
# native Python type, or one of the model classes.
|
|
||||||
if type(objClass) == str:
|
|
||||||
if 'list[' in objClass:
|
|
||||||
match = re.match('list\[(.*)\]', objClass)
|
|
||||||
subClass = match.group(1)
|
|
||||||
return [self.deserialize(subObj, subClass) for subObj in obj]
|
|
||||||
|
|
||||||
if (objClass in ['int', 'float', 'dict', 'list', 'str', 'bool', 'datetime']):
|
|
||||||
objClass = eval(objClass)
|
|
||||||
else: # not a native type, must be model class
|
|
||||||
objClass = eval(objClass + '.' + objClass)
|
|
||||||
|
|
||||||
if objClass in [int, float, dict, list, str, bool]:
|
|
||||||
return objClass(obj)
|
|
||||||
elif objClass == datetime:
|
|
||||||
return self._parseDatetime(obj)
|
|
||||||
|
|
||||||
instance = objClass()
|
|
||||||
|
|
||||||
for attr, attrType in instance.swaggerTypes.items():
|
|
||||||
|
|
||||||
if attr in obj:
|
|
||||||
value = obj[attr]
|
|
||||||
if attrType in ['str', 'int', 'float', 'bool']:
|
|
||||||
attrType = eval(attrType)
|
|
||||||
try:
|
|
||||||
value = attrType(value)
|
|
||||||
except UnicodeEncodeError:
|
|
||||||
value = unicode(value)
|
|
||||||
except TypeError:
|
|
||||||
value = value
|
|
||||||
setattr(instance, attr, value)
|
|
||||||
elif (attrType == 'datetime'):
|
|
||||||
setattr(instance, attr, self._parseDatetime(value))
|
|
||||||
elif 'list[' in attrType:
|
|
||||||
match = re.match('list\[(.*)\]', attrType)
|
|
||||||
subClass = match.group(1)
|
|
||||||
subValues = []
|
|
||||||
if not value:
|
|
||||||
setattr(instance, attr, None)
|
|
||||||
else:
|
|
||||||
for subValue in value:
|
|
||||||
subValues.append(self.deserialize(subValue,
|
|
||||||
subClass))
|
|
||||||
setattr(instance, attr, subValues)
|
|
||||||
else:
|
|
||||||
setattr(instance, attr, self.deserialize(value,
|
|
||||||
attrType))
|
|
||||||
|
|
||||||
return instance
|
|
||||||
|
|
||||||
|
|
||||||
class MethodRequest(urllib.request.Request):
|
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
"""Construct a MethodRequest. Usage is the same as for
|
|
||||||
`urllib.Request` except it also takes an optional `method`
|
|
||||||
keyword argument. If supplied, `method` will be used instead of
|
|
||||||
the default."""
|
|
||||||
|
|
||||||
if 'method' in kwargs:
|
|
||||||
self.method = kwargs.pop('method')
|
|
||||||
return urllib.request.Request.__init__(self, *args, **kwargs)
|
|
||||||
|
|
||||||
def get_method(self):
|
|
||||||
return getattr(self, 'method', urllib.request.Request.get_method(self))
|
|
@ -1,409 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
"""
|
|
||||||
WordAPI.py
|
|
||||||
Copyright 2014 Wordnik, Inc.
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
|
||||||
"""
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
|
|
||||||
from .models import *
|
|
||||||
|
|
||||||
|
|
||||||
class PetApi(object):
|
|
||||||
|
|
||||||
def __init__(self, apiClient):
|
|
||||||
self.apiClient = apiClient
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def getPetById(self, petId, **kwargs):
|
|
||||||
"""Find pet by ID
|
|
||||||
|
|
||||||
Args:
|
|
||||||
petId, int: ID of pet that needs to be fetched (required)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Returns: Pet
|
|
||||||
"""
|
|
||||||
|
|
||||||
allParams = ['petId']
|
|
||||||
|
|
||||||
params = locals()
|
|
||||||
for (key, val) in params['kwargs'].items():
|
|
||||||
if key not in allParams:
|
|
||||||
raise TypeError("Got an unexpected keyword argument '%s' to method getPetById" % key)
|
|
||||||
params[key] = val
|
|
||||||
del params['kwargs']
|
|
||||||
|
|
||||||
resourcePath = '/pet/{petId}'
|
|
||||||
resourcePath = resourcePath.replace('{format}', 'json')
|
|
||||||
method = 'GET'
|
|
||||||
|
|
||||||
queryParams = {}
|
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
if ('petId' in params):
|
|
||||||
replacement = str(self.apiClient.toPathValue(params['petId']))
|
|
||||||
resourcePath = resourcePath.replace('{' + 'petId' + '}',
|
|
||||||
replacement)
|
|
||||||
postData = (params['body'] if 'body' in params else None)
|
|
||||||
|
|
||||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
|
||||||
postData, headerParams)
|
|
||||||
|
|
||||||
if not response:
|
|
||||||
return None
|
|
||||||
|
|
||||||
responseObject = self.apiClient.deserialize(response, 'Pet')
|
|
||||||
return responseObject
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def deletePet(self, petId, **kwargs):
|
|
||||||
"""Deletes a pet
|
|
||||||
|
|
||||||
Args:
|
|
||||||
petId, str: Pet id to delete (required)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
"""
|
|
||||||
|
|
||||||
allParams = ['petId']
|
|
||||||
|
|
||||||
params = locals()
|
|
||||||
for (key, val) in params['kwargs'].items():
|
|
||||||
if key not in allParams:
|
|
||||||
raise TypeError("Got an unexpected keyword argument '%s' to method deletePet" % key)
|
|
||||||
params[key] = val
|
|
||||||
del params['kwargs']
|
|
||||||
|
|
||||||
resourcePath = '/pet/{petId}'
|
|
||||||
resourcePath = resourcePath.replace('{format}', 'json')
|
|
||||||
method = 'DELETE'
|
|
||||||
|
|
||||||
queryParams = {}
|
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
if ('petId' in params):
|
|
||||||
replacement = str(self.apiClient.toPathValue(params['petId']))
|
|
||||||
resourcePath = resourcePath.replace('{' + 'petId' + '}',
|
|
||||||
replacement)
|
|
||||||
postData = (params['body'] if 'body' in params else None)
|
|
||||||
|
|
||||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
|
||||||
postData, headerParams)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def partialUpdate(self, petId, body, **kwargs):
|
|
||||||
"""partial updates to a pet
|
|
||||||
|
|
||||||
Args:
|
|
||||||
petId, str: ID of pet that needs to be fetched (required)
|
|
||||||
|
|
||||||
body, Pet: Pet object that needs to be added to the store (required)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Returns: Array[Pet]
|
|
||||||
"""
|
|
||||||
|
|
||||||
allParams = ['petId', 'body']
|
|
||||||
|
|
||||||
params = locals()
|
|
||||||
for (key, val) in params['kwargs'].items():
|
|
||||||
if key not in allParams:
|
|
||||||
raise TypeError("Got an unexpected keyword argument '%s' to method partialUpdate" % key)
|
|
||||||
params[key] = val
|
|
||||||
del params['kwargs']
|
|
||||||
|
|
||||||
resourcePath = '/pet/{petId}'
|
|
||||||
resourcePath = resourcePath.replace('{format}', 'json')
|
|
||||||
method = 'PATCH'
|
|
||||||
|
|
||||||
queryParams = {}
|
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
if ('petId' in params):
|
|
||||||
replacement = str(self.apiClient.toPathValue(params['petId']))
|
|
||||||
resourcePath = resourcePath.replace('{' + 'petId' + '}',
|
|
||||||
replacement)
|
|
||||||
postData = (params['body'] if 'body' in params else None)
|
|
||||||
|
|
||||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
|
||||||
postData, headerParams)
|
|
||||||
|
|
||||||
if not response:
|
|
||||||
return None
|
|
||||||
|
|
||||||
responseObject = self.apiClient.deserialize(response, 'Array[Pet]')
|
|
||||||
return responseObject
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def updatePetWithForm(self, petId, **kwargs):
|
|
||||||
"""Updates a pet in the store with form data
|
|
||||||
|
|
||||||
Args:
|
|
||||||
petId, str: ID of pet that needs to be updated (required)
|
|
||||||
|
|
||||||
name, str: Updated name of the pet (optional)
|
|
||||||
|
|
||||||
status, str: Updated status of the pet (optional)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
"""
|
|
||||||
|
|
||||||
allParams = ['petId', 'name', 'status']
|
|
||||||
|
|
||||||
params = locals()
|
|
||||||
for (key, val) in params['kwargs'].items():
|
|
||||||
if key not in allParams:
|
|
||||||
raise TypeError("Got an unexpected keyword argument '%s' to method updatePetWithForm" % key)
|
|
||||||
params[key] = val
|
|
||||||
del params['kwargs']
|
|
||||||
|
|
||||||
resourcePath = '/pet/{petId}'
|
|
||||||
resourcePath = resourcePath.replace('{format}', 'json')
|
|
||||||
method = 'POST'
|
|
||||||
|
|
||||||
queryParams = {}
|
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
if ('petId' in params):
|
|
||||||
replacement = str(self.apiClient.toPathValue(params['petId']))
|
|
||||||
resourcePath = resourcePath.replace('{' + 'petId' + '}',
|
|
||||||
replacement)
|
|
||||||
postData = (params['body'] if 'body' in params else None)
|
|
||||||
|
|
||||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
|
||||||
postData, headerParams)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def uploadFile(self, **kwargs):
|
|
||||||
"""uploads an image
|
|
||||||
|
|
||||||
Args:
|
|
||||||
additionalMetadata, str: Additional data to pass to server (optional)
|
|
||||||
|
|
||||||
body, File: file to upload (optional)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
"""
|
|
||||||
|
|
||||||
allParams = ['additionalMetadata', 'body']
|
|
||||||
|
|
||||||
params = locals()
|
|
||||||
for (key, val) in params['kwargs'].items():
|
|
||||||
if key not in allParams:
|
|
||||||
raise TypeError("Got an unexpected keyword argument '%s' to method uploadFile" % key)
|
|
||||||
params[key] = val
|
|
||||||
del params['kwargs']
|
|
||||||
|
|
||||||
resourcePath = '/pet/uploadImage'
|
|
||||||
resourcePath = resourcePath.replace('{format}', 'json')
|
|
||||||
method = 'POST'
|
|
||||||
|
|
||||||
queryParams = {}
|
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
postData = (params['body'] if 'body' in params else None)
|
|
||||||
|
|
||||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
|
||||||
postData, headerParams)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def addPet(self, body, **kwargs):
|
|
||||||
"""Add a new pet to the store
|
|
||||||
|
|
||||||
Args:
|
|
||||||
body, Pet: Pet object that needs to be added to the store (required)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
"""
|
|
||||||
|
|
||||||
allParams = ['body']
|
|
||||||
|
|
||||||
params = locals()
|
|
||||||
for (key, val) in params['kwargs'].items():
|
|
||||||
if key not in allParams:
|
|
||||||
raise TypeError("Got an unexpected keyword argument '%s' to method addPet" % key)
|
|
||||||
params[key] = val
|
|
||||||
del params['kwargs']
|
|
||||||
|
|
||||||
resourcePath = '/pet'
|
|
||||||
resourcePath = resourcePath.replace('{format}', 'json')
|
|
||||||
method = 'POST'
|
|
||||||
|
|
||||||
queryParams = {}
|
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
postData = (params['body'] if 'body' in params else None)
|
|
||||||
|
|
||||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
|
||||||
postData, headerParams)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def updatePet(self, body, **kwargs):
|
|
||||||
"""Update an existing pet
|
|
||||||
|
|
||||||
Args:
|
|
||||||
body, Pet: Pet object that needs to be updated in the store (required)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
"""
|
|
||||||
|
|
||||||
allParams = ['body']
|
|
||||||
|
|
||||||
params = locals()
|
|
||||||
for (key, val) in params['kwargs'].items():
|
|
||||||
if key not in allParams:
|
|
||||||
raise TypeError("Got an unexpected keyword argument '%s' to method updatePet" % key)
|
|
||||||
params[key] = val
|
|
||||||
del params['kwargs']
|
|
||||||
|
|
||||||
resourcePath = '/pet'
|
|
||||||
resourcePath = resourcePath.replace('{format}', 'json')
|
|
||||||
method = 'PUT'
|
|
||||||
|
|
||||||
queryParams = {}
|
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
postData = (params['body'] if 'body' in params else None)
|
|
||||||
|
|
||||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
|
||||||
postData, headerParams)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def findPetsByStatus(self, status= None, **kwargs):
|
|
||||||
"""Finds Pets by status
|
|
||||||
|
|
||||||
Args:
|
|
||||||
status, str: Status values that need to be considered for filter (required)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Returns: Array[Pet]
|
|
||||||
"""
|
|
||||||
|
|
||||||
allParams = ['status']
|
|
||||||
|
|
||||||
params = locals()
|
|
||||||
for (key, val) in params['kwargs'].items():
|
|
||||||
if key not in allParams:
|
|
||||||
raise TypeError("Got an unexpected keyword argument '%s' to method findPetsByStatus" % key)
|
|
||||||
params[key] = val
|
|
||||||
del params['kwargs']
|
|
||||||
|
|
||||||
resourcePath = '/pet/findByStatus'
|
|
||||||
resourcePath = resourcePath.replace('{format}', 'json')
|
|
||||||
method = 'GET'
|
|
||||||
|
|
||||||
queryParams = {}
|
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
if ('status' in params):
|
|
||||||
queryParams['status'] = self.apiClient.toPathValue(params['status'])
|
|
||||||
postData = (params['body'] if 'body' in params else None)
|
|
||||||
|
|
||||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
|
||||||
postData, headerParams)
|
|
||||||
|
|
||||||
if not response:
|
|
||||||
return None
|
|
||||||
|
|
||||||
responseObject = self.apiClient.deserialize(response, 'Array[Pet]')
|
|
||||||
return responseObject
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def findPetsByTags(self, tags, **kwargs):
|
|
||||||
"""Finds Pets by tags
|
|
||||||
|
|
||||||
Args:
|
|
||||||
tags, str: Tags to filter by (required)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Returns: Array[Pet]
|
|
||||||
"""
|
|
||||||
|
|
||||||
allParams = ['tags']
|
|
||||||
|
|
||||||
params = locals()
|
|
||||||
for (key, val) in params['kwargs'].items():
|
|
||||||
if key not in allParams:
|
|
||||||
raise TypeError("Got an unexpected keyword argument '%s' to method findPetsByTags" % key)
|
|
||||||
params[key] = val
|
|
||||||
del params['kwargs']
|
|
||||||
|
|
||||||
resourcePath = '/pet/findByTags'
|
|
||||||
resourcePath = resourcePath.replace('{format}', 'json')
|
|
||||||
method = 'GET'
|
|
||||||
|
|
||||||
queryParams = {}
|
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
if ('tags' in params):
|
|
||||||
queryParams['tags'] = self.apiClient.toPathValue(params['tags'])
|
|
||||||
postData = (params['body'] if 'body' in params else None)
|
|
||||||
|
|
||||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
|
||||||
postData, headerParams)
|
|
||||||
|
|
||||||
if not response:
|
|
||||||
return None
|
|
||||||
|
|
||||||
responseObject = self.apiClient.deserialize(response, 'Array[Pet]')
|
|
||||||
return responseObject
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2014 Wordnik, Inc.
|
|
||||||
*
|
|
||||||
* 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 java.io.File
|
|
||||||
|
|
||||||
object Python3PetstoreCodegen extends BasicPython3Generator {
|
|
||||||
def main(args: Array[String]) = generateClient(args)
|
|
||||||
|
|
||||||
override def supportingFiles = List(
|
|
||||||
("__init__.mustache", destinationDir, "__init__.py"),
|
|
||||||
("swagger.mustache", destinationDir + File.separator + apiPackage.getOrElse(""), "swagger.py"),
|
|
||||||
("__init__.mustache", destinationDir + File.separator + modelPackage.getOrElse(""), "__init__.py"))
|
|
||||||
|
|
||||||
override def destinationDir = "samples/client/petstore/python3"
|
|
||||||
}
|
|
@ -1,158 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
"""
|
|
||||||
WordAPI.py
|
|
||||||
Copyright 2014 Wordnik, Inc.
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
|
||||||
"""
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
|
|
||||||
from .models import *
|
|
||||||
|
|
||||||
|
|
||||||
class StoreApi(object):
|
|
||||||
|
|
||||||
def __init__(self, apiClient):
|
|
||||||
self.apiClient = apiClient
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def getOrderById(self, orderId, **kwargs):
|
|
||||||
"""Find purchase order by ID
|
|
||||||
|
|
||||||
Args:
|
|
||||||
orderId, str: ID of pet that needs to be fetched (required)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Returns: Order
|
|
||||||
"""
|
|
||||||
|
|
||||||
allParams = ['orderId']
|
|
||||||
|
|
||||||
params = locals()
|
|
||||||
for (key, val) in params['kwargs'].items():
|
|
||||||
if key not in allParams:
|
|
||||||
raise TypeError("Got an unexpected keyword argument '%s' to method getOrderById" % key)
|
|
||||||
params[key] = val
|
|
||||||
del params['kwargs']
|
|
||||||
|
|
||||||
resourcePath = '/store/order/{orderId}'
|
|
||||||
resourcePath = resourcePath.replace('{format}', 'json')
|
|
||||||
method = 'GET'
|
|
||||||
|
|
||||||
queryParams = {}
|
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
if ('orderId' in params):
|
|
||||||
replacement = str(self.apiClient.toPathValue(params['orderId']))
|
|
||||||
resourcePath = resourcePath.replace('{' + 'orderId' + '}',
|
|
||||||
replacement)
|
|
||||||
postData = (params['body'] if 'body' in params else None)
|
|
||||||
|
|
||||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
|
||||||
postData, headerParams)
|
|
||||||
|
|
||||||
if not response:
|
|
||||||
return None
|
|
||||||
|
|
||||||
responseObject = self.apiClient.deserialize(response, 'Order')
|
|
||||||
return responseObject
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def deleteOrder(self, orderId, **kwargs):
|
|
||||||
"""Delete purchase order by ID
|
|
||||||
|
|
||||||
Args:
|
|
||||||
orderId, str: ID of the order that needs to be deleted (required)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
"""
|
|
||||||
|
|
||||||
allParams = ['orderId']
|
|
||||||
|
|
||||||
params = locals()
|
|
||||||
for (key, val) in params['kwargs'].items():
|
|
||||||
if key not in allParams:
|
|
||||||
raise TypeError("Got an unexpected keyword argument '%s' to method deleteOrder" % key)
|
|
||||||
params[key] = val
|
|
||||||
del params['kwargs']
|
|
||||||
|
|
||||||
resourcePath = '/store/order/{orderId}'
|
|
||||||
resourcePath = resourcePath.replace('{format}', 'json')
|
|
||||||
method = 'DELETE'
|
|
||||||
|
|
||||||
queryParams = {}
|
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
if ('orderId' in params):
|
|
||||||
replacement = str(self.apiClient.toPathValue(params['orderId']))
|
|
||||||
resourcePath = resourcePath.replace('{' + 'orderId' + '}',
|
|
||||||
replacement)
|
|
||||||
postData = (params['body'] if 'body' in params else None)
|
|
||||||
|
|
||||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
|
||||||
postData, headerParams)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def placeOrder(self, body, **kwargs):
|
|
||||||
"""Place an order for a pet
|
|
||||||
|
|
||||||
Args:
|
|
||||||
body, Order: order placed for purchasing the pet (required)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
"""
|
|
||||||
|
|
||||||
allParams = ['body']
|
|
||||||
|
|
||||||
params = locals()
|
|
||||||
for (key, val) in params['kwargs'].items():
|
|
||||||
if key not in allParams:
|
|
||||||
raise TypeError("Got an unexpected keyword argument '%s' to method placeOrder" % key)
|
|
||||||
params[key] = val
|
|
||||||
del params['kwargs']
|
|
||||||
|
|
||||||
resourcePath = '/store/order'
|
|
||||||
resourcePath = resourcePath.replace('{format}', 'json')
|
|
||||||
method = 'POST'
|
|
||||||
|
|
||||||
queryParams = {}
|
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
postData = (params['body'] if 'body' in params else None)
|
|
||||||
|
|
||||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
|
||||||
postData, headerParams)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,353 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
"""
|
|
||||||
WordAPI.py
|
|
||||||
Copyright 2014 Wordnik, Inc.
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
|
||||||
"""
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
|
|
||||||
from .models import *
|
|
||||||
|
|
||||||
|
|
||||||
class UserApi(object):
|
|
||||||
|
|
||||||
def __init__(self, apiClient):
|
|
||||||
self.apiClient = apiClient
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def updateUser(self, username, body, **kwargs):
|
|
||||||
"""Updated user
|
|
||||||
|
|
||||||
Args:
|
|
||||||
username, str: name that need to be deleted (required)
|
|
||||||
|
|
||||||
body, User: Updated user object (required)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
"""
|
|
||||||
|
|
||||||
allParams = ['username', 'body']
|
|
||||||
|
|
||||||
params = locals()
|
|
||||||
for (key, val) in params['kwargs'].items():
|
|
||||||
if key not in allParams:
|
|
||||||
raise TypeError("Got an unexpected keyword argument '%s' to method updateUser" % key)
|
|
||||||
params[key] = val
|
|
||||||
del params['kwargs']
|
|
||||||
|
|
||||||
resourcePath = '/user/{username}'
|
|
||||||
resourcePath = resourcePath.replace('{format}', 'json')
|
|
||||||
method = 'PUT'
|
|
||||||
|
|
||||||
queryParams = {}
|
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
if ('username' in params):
|
|
||||||
replacement = str(self.apiClient.toPathValue(params['username']))
|
|
||||||
resourcePath = resourcePath.replace('{' + 'username' + '}',
|
|
||||||
replacement)
|
|
||||||
postData = (params['body'] if 'body' in params else None)
|
|
||||||
|
|
||||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
|
||||||
postData, headerParams)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def deleteUser(self, username, **kwargs):
|
|
||||||
"""Delete user
|
|
||||||
|
|
||||||
Args:
|
|
||||||
username, str: The name that needs to be deleted (required)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
"""
|
|
||||||
|
|
||||||
allParams = ['username']
|
|
||||||
|
|
||||||
params = locals()
|
|
||||||
for (key, val) in params['kwargs'].items():
|
|
||||||
if key not in allParams:
|
|
||||||
raise TypeError("Got an unexpected keyword argument '%s' to method deleteUser" % key)
|
|
||||||
params[key] = val
|
|
||||||
del params['kwargs']
|
|
||||||
|
|
||||||
resourcePath = '/user/{username}'
|
|
||||||
resourcePath = resourcePath.replace('{format}', 'json')
|
|
||||||
method = 'DELETE'
|
|
||||||
|
|
||||||
queryParams = {}
|
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
if ('username' in params):
|
|
||||||
replacement = str(self.apiClient.toPathValue(params['username']))
|
|
||||||
resourcePath = resourcePath.replace('{' + 'username' + '}',
|
|
||||||
replacement)
|
|
||||||
postData = (params['body'] if 'body' in params else None)
|
|
||||||
|
|
||||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
|
||||||
postData, headerParams)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def getUserByName(self, username, **kwargs):
|
|
||||||
"""Get user by user name
|
|
||||||
|
|
||||||
Args:
|
|
||||||
username, str: The name that needs to be fetched. Use user1 for testing. (required)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Returns: User
|
|
||||||
"""
|
|
||||||
|
|
||||||
allParams = ['username']
|
|
||||||
|
|
||||||
params = locals()
|
|
||||||
for (key, val) in params['kwargs'].items():
|
|
||||||
if key not in allParams:
|
|
||||||
raise TypeError("Got an unexpected keyword argument '%s' to method getUserByName" % key)
|
|
||||||
params[key] = val
|
|
||||||
del params['kwargs']
|
|
||||||
|
|
||||||
resourcePath = '/user/{username}'
|
|
||||||
resourcePath = resourcePath.replace('{format}', 'json')
|
|
||||||
method = 'GET'
|
|
||||||
|
|
||||||
queryParams = {}
|
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
if ('username' in params):
|
|
||||||
replacement = str(self.apiClient.toPathValue(params['username']))
|
|
||||||
resourcePath = resourcePath.replace('{' + 'username' + '}',
|
|
||||||
replacement)
|
|
||||||
postData = (params['body'] if 'body' in params else None)
|
|
||||||
|
|
||||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
|
||||||
postData, headerParams)
|
|
||||||
|
|
||||||
if not response:
|
|
||||||
return None
|
|
||||||
|
|
||||||
responseObject = self.apiClient.deserialize(response, 'User')
|
|
||||||
return responseObject
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def loginUser(self, username, password, **kwargs):
|
|
||||||
"""Logs user into the system
|
|
||||||
|
|
||||||
Args:
|
|
||||||
username, str: The user name for login (required)
|
|
||||||
|
|
||||||
password, str: The password for login in clear text (required)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Returns: str
|
|
||||||
"""
|
|
||||||
|
|
||||||
allParams = ['username', 'password']
|
|
||||||
|
|
||||||
params = locals()
|
|
||||||
for (key, val) in params['kwargs'].items():
|
|
||||||
if key not in allParams:
|
|
||||||
raise TypeError("Got an unexpected keyword argument '%s' to method loginUser" % key)
|
|
||||||
params[key] = val
|
|
||||||
del params['kwargs']
|
|
||||||
|
|
||||||
resourcePath = '/user/login'
|
|
||||||
resourcePath = resourcePath.replace('{format}', 'json')
|
|
||||||
method = 'GET'
|
|
||||||
|
|
||||||
queryParams = {}
|
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
if ('username' in params):
|
|
||||||
queryParams['username'] = self.apiClient.toPathValue(params['username'])
|
|
||||||
if ('password' in params):
|
|
||||||
queryParams['password'] = self.apiClient.toPathValue(params['password'])
|
|
||||||
postData = (params['body'] if 'body' in params else None)
|
|
||||||
|
|
||||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
|
||||||
postData, headerParams)
|
|
||||||
|
|
||||||
if not response:
|
|
||||||
return None
|
|
||||||
|
|
||||||
responseObject = self.apiClient.deserialize(response, 'str')
|
|
||||||
return responseObject
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def logoutUser(self, **kwargs):
|
|
||||||
"""Logs out current logged in user session
|
|
||||||
|
|
||||||
Args:
|
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
"""
|
|
||||||
|
|
||||||
allParams = []
|
|
||||||
|
|
||||||
params = locals()
|
|
||||||
for (key, val) in params['kwargs'].items():
|
|
||||||
if key not in allParams:
|
|
||||||
raise TypeError("Got an unexpected keyword argument '%s' to method logoutUser" % key)
|
|
||||||
params[key] = val
|
|
||||||
del params['kwargs']
|
|
||||||
|
|
||||||
resourcePath = '/user/logout'
|
|
||||||
resourcePath = resourcePath.replace('{format}', 'json')
|
|
||||||
method = 'GET'
|
|
||||||
|
|
||||||
queryParams = {}
|
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
postData = (params['body'] if 'body' in params else None)
|
|
||||||
|
|
||||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
|
||||||
postData, headerParams)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def createUser(self, body, **kwargs):
|
|
||||||
"""Create user
|
|
||||||
|
|
||||||
Args:
|
|
||||||
body, User: Created user object (required)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
"""
|
|
||||||
|
|
||||||
allParams = ['body']
|
|
||||||
|
|
||||||
params = locals()
|
|
||||||
for (key, val) in params['kwargs'].items():
|
|
||||||
if key not in allParams:
|
|
||||||
raise TypeError("Got an unexpected keyword argument '%s' to method createUser" % key)
|
|
||||||
params[key] = val
|
|
||||||
del params['kwargs']
|
|
||||||
|
|
||||||
resourcePath = '/user'
|
|
||||||
resourcePath = resourcePath.replace('{format}', 'json')
|
|
||||||
method = 'POST'
|
|
||||||
|
|
||||||
queryParams = {}
|
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
postData = (params['body'] if 'body' in params else None)
|
|
||||||
|
|
||||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
|
||||||
postData, headerParams)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def createUsersWithArrayInput(self, body, **kwargs):
|
|
||||||
"""Creates list of users with given input array
|
|
||||||
|
|
||||||
Args:
|
|
||||||
body, list[User]: List of user object (required)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
"""
|
|
||||||
|
|
||||||
allParams = ['body']
|
|
||||||
|
|
||||||
params = locals()
|
|
||||||
for (key, val) in params['kwargs'].items():
|
|
||||||
if key not in allParams:
|
|
||||||
raise TypeError("Got an unexpected keyword argument '%s' to method createUsersWithArrayInput" % key)
|
|
||||||
params[key] = val
|
|
||||||
del params['kwargs']
|
|
||||||
|
|
||||||
resourcePath = '/user/createWithArray'
|
|
||||||
resourcePath = resourcePath.replace('{format}', 'json')
|
|
||||||
method = 'POST'
|
|
||||||
|
|
||||||
queryParams = {}
|
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
postData = (params['body'] if 'body' in params else None)
|
|
||||||
|
|
||||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
|
||||||
postData, headerParams)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def createUsersWithListInput(self, body, **kwargs):
|
|
||||||
"""Creates list of users with given list input
|
|
||||||
|
|
||||||
Args:
|
|
||||||
body, list[User]: List of user object (required)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
"""
|
|
||||||
|
|
||||||
allParams = ['body']
|
|
||||||
|
|
||||||
params = locals()
|
|
||||||
for (key, val) in params['kwargs'].items():
|
|
||||||
if key not in allParams:
|
|
||||||
raise TypeError("Got an unexpected keyword argument '%s' to method createUsersWithListInput" % key)
|
|
||||||
params[key] = val
|
|
||||||
del params['kwargs']
|
|
||||||
|
|
||||||
resourcePath = '/user/createWithList'
|
|
||||||
resourcePath = resourcePath.replace('{format}', 'json')
|
|
||||||
method = 'POST'
|
|
||||||
|
|
||||||
queryParams = {}
|
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
postData = (params['body'] if 'body' in params else None)
|
|
||||||
|
|
||||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
|
||||||
postData, headerParams)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
"""Add all of the modules in the current directory to __all__"""
|
|
||||||
import os
|
|
||||||
|
|
||||||
__all__ = []
|
|
||||||
|
|
||||||
for module in os.listdir(os.path.dirname(__file__)):
|
|
||||||
if module != '__init__.py' and module[-3:] == '.py':
|
|
||||||
__all__.append(module[:-3])
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
"""Add all of the modules in the current directory to __all__"""
|
|
||||||
import os
|
|
||||||
|
|
||||||
__all__ = []
|
|
||||||
|
|
||||||
for module in os.listdir(os.path.dirname(__file__)):
|
|
||||||
if module != '__init__.py' and module[-3:] == '.py':
|
|
||||||
__all__.append(module[:-3])
|
|
@ -1,40 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
"""
|
|
||||||
Copyright 2015 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.
|
|
||||||
"""
|
|
||||||
|
|
||||||
class Category:
|
|
||||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
|
||||||
Do not edit the class manually."""
|
|
||||||
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
self.swaggerTypes = {
|
|
||||||
|
|
||||||
'id': 'int',
|
|
||||||
|
|
||||||
|
|
||||||
'name': 'str'
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
self.id = None # int
|
|
||||||
|
|
||||||
|
|
||||||
self.name = None # str
|
|
||||||
|
|
@ -1,65 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
"""
|
|
||||||
Copyright 2015 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.
|
|
||||||
"""
|
|
||||||
|
|
||||||
class Order:
|
|
||||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
|
||||||
Do not edit the class manually."""
|
|
||||||
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
self.swaggerTypes = {
|
|
||||||
|
|
||||||
'id': 'int',
|
|
||||||
|
|
||||||
|
|
||||||
'pet_id': 'int',
|
|
||||||
|
|
||||||
|
|
||||||
'quantity': 'int',
|
|
||||||
|
|
||||||
|
|
||||||
'ship_date': 'DateTime',
|
|
||||||
|
|
||||||
|
|
||||||
'status': 'str',
|
|
||||||
|
|
||||||
|
|
||||||
'complete': 'bool'
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
self.id = None # int
|
|
||||||
|
|
||||||
|
|
||||||
self.pet_id = None # int
|
|
||||||
|
|
||||||
|
|
||||||
self.quantity = None # int
|
|
||||||
|
|
||||||
|
|
||||||
self.ship_date = None # DateTime
|
|
||||||
|
|
||||||
#Order Status
|
|
||||||
|
|
||||||
self.status = None # str
|
|
||||||
|
|
||||||
|
|
||||||
self.complete = None # bool
|
|
||||||
|
|
@ -1,65 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
"""
|
|
||||||
Copyright 2015 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.
|
|
||||||
"""
|
|
||||||
|
|
||||||
class Pet:
|
|
||||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
|
||||||
Do not edit the class manually."""
|
|
||||||
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
self.swaggerTypes = {
|
|
||||||
|
|
||||||
'id': 'int',
|
|
||||||
|
|
||||||
|
|
||||||
'category': 'Category',
|
|
||||||
|
|
||||||
|
|
||||||
'name': 'str',
|
|
||||||
|
|
||||||
|
|
||||||
'photo_urls': 'list[str]',
|
|
||||||
|
|
||||||
|
|
||||||
'tags': 'list[Tag]',
|
|
||||||
|
|
||||||
|
|
||||||
'status': 'str'
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
self.id = None # int
|
|
||||||
|
|
||||||
|
|
||||||
self.category = None # Category
|
|
||||||
|
|
||||||
|
|
||||||
self.name = None # str
|
|
||||||
|
|
||||||
|
|
||||||
self.photo_urls = None # list[str]
|
|
||||||
|
|
||||||
|
|
||||||
self.tags = None # list[Tag]
|
|
||||||
|
|
||||||
#pet status in the store
|
|
||||||
|
|
||||||
self.status = None # str
|
|
||||||
|
|
@ -1,40 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
"""
|
|
||||||
Copyright 2015 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.
|
|
||||||
"""
|
|
||||||
|
|
||||||
class Tag:
|
|
||||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
|
||||||
Do not edit the class manually."""
|
|
||||||
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
self.swaggerTypes = {
|
|
||||||
|
|
||||||
'id': 'int',
|
|
||||||
|
|
||||||
|
|
||||||
'name': 'str'
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
self.id = None # int
|
|
||||||
|
|
||||||
|
|
||||||
self.name = None # str
|
|
||||||
|
|
@ -1,77 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
"""
|
|
||||||
Copyright 2015 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.
|
|
||||||
"""
|
|
||||||
|
|
||||||
class User:
|
|
||||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
|
||||||
Do not edit the class manually."""
|
|
||||||
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
self.swaggerTypes = {
|
|
||||||
|
|
||||||
'id': 'int',
|
|
||||||
|
|
||||||
|
|
||||||
'username': 'str',
|
|
||||||
|
|
||||||
|
|
||||||
'first_name': 'str',
|
|
||||||
|
|
||||||
|
|
||||||
'last_name': 'str',
|
|
||||||
|
|
||||||
|
|
||||||
'email': 'str',
|
|
||||||
|
|
||||||
|
|
||||||
'password': 'str',
|
|
||||||
|
|
||||||
|
|
||||||
'phone': 'str',
|
|
||||||
|
|
||||||
|
|
||||||
'user_status': 'int'
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
self.id = None # int
|
|
||||||
|
|
||||||
|
|
||||||
self.username = None # str
|
|
||||||
|
|
||||||
|
|
||||||
self.first_name = None # str
|
|
||||||
|
|
||||||
|
|
||||||
self.last_name = None # str
|
|
||||||
|
|
||||||
|
|
||||||
self.email = None # str
|
|
||||||
|
|
||||||
|
|
||||||
self.password = None # str
|
|
||||||
|
|
||||||
|
|
||||||
self.phone = None # str
|
|
||||||
|
|
||||||
#User Status
|
|
||||||
|
|
||||||
self.user_status = None # int
|
|
||||||
|
|
@ -1,422 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
"""
|
|
||||||
PetApi.py
|
|
||||||
Copyright 2015 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.
|
|
||||||
|
|
||||||
NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
|
||||||
"""
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
|
|
||||||
from .models import *
|
|
||||||
|
|
||||||
|
|
||||||
class PetApi(object):
|
|
||||||
|
|
||||||
def __init__(self, apiClient):
|
|
||||||
self.apiClient = apiClient
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def update_pet(self, **kwargs):
|
|
||||||
"""Update an existing pet
|
|
||||||
|
|
||||||
|
|
||||||
Args:
|
|
||||||
body, Pet: Pet object that needs to be added to the store (optional)
|
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
"""
|
|
||||||
|
|
||||||
allParams = ['body']
|
|
||||||
|
|
||||||
params = locals()
|
|
||||||
for (key, val) in params['kwargs'].items():
|
|
||||||
if key not in allParams:
|
|
||||||
raise TypeError("Got an unexpected keyword argument '%s' to method update_pet" % key)
|
|
||||||
params[key] = val
|
|
||||||
del params['kwargs']
|
|
||||||
|
|
||||||
resourcePath = '/pet'
|
|
||||||
resourcePath = resourcePath.replace('{format}', 'json')
|
|
||||||
method = 'PUT'
|
|
||||||
|
|
||||||
queryParams = {}
|
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
postData = (params['body'] if 'body' in params else None)
|
|
||||||
|
|
||||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
|
||||||
postData, headerParams)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def add_pet(self, **kwargs):
|
|
||||||
"""Add a new pet to the store
|
|
||||||
|
|
||||||
|
|
||||||
Args:
|
|
||||||
body, Pet: Pet object that needs to be added to the store (optional)
|
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
"""
|
|
||||||
|
|
||||||
allParams = ['body']
|
|
||||||
|
|
||||||
params = locals()
|
|
||||||
for (key, val) in params['kwargs'].items():
|
|
||||||
if key not in allParams:
|
|
||||||
raise TypeError("Got an unexpected keyword argument '%s' to method add_pet" % key)
|
|
||||||
params[key] = val
|
|
||||||
del params['kwargs']
|
|
||||||
|
|
||||||
resourcePath = '/pet'
|
|
||||||
resourcePath = resourcePath.replace('{format}', 'json')
|
|
||||||
method = 'POST'
|
|
||||||
|
|
||||||
queryParams = {}
|
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
postData = (params['body'] if 'body' in params else None)
|
|
||||||
|
|
||||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
|
||||||
postData, headerParams)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def find_pets_by_status(self, **kwargs):
|
|
||||||
"""Finds Pets by status
|
|
||||||
Multiple status values can be provided with comma seperated strings
|
|
||||||
|
|
||||||
Args:
|
|
||||||
status, list[str]: Status values that need to be considered for filter (optional)
|
|
||||||
|
|
||||||
|
|
||||||
Returns: list[Pet]
|
|
||||||
"""
|
|
||||||
|
|
||||||
allParams = ['status']
|
|
||||||
|
|
||||||
params = locals()
|
|
||||||
for (key, val) in params['kwargs'].items():
|
|
||||||
if key not in allParams:
|
|
||||||
raise TypeError("Got an unexpected keyword argument '%s' to method find_pets_by_status" % key)
|
|
||||||
params[key] = val
|
|
||||||
del params['kwargs']
|
|
||||||
|
|
||||||
resourcePath = '/pet/findByStatus'
|
|
||||||
resourcePath = resourcePath.replace('{format}', 'json')
|
|
||||||
method = 'GET'
|
|
||||||
|
|
||||||
queryParams = {}
|
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
|
|
||||||
if ('status' in params):
|
|
||||||
queryParams['status'] = self.apiClient.toPathValue(params['status'])
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
postData = (params['body'] if 'body' in params else None)
|
|
||||||
|
|
||||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
|
||||||
postData, headerParams)
|
|
||||||
|
|
||||||
|
|
||||||
if not response:
|
|
||||||
return None
|
|
||||||
|
|
||||||
responseObject = self.apiClient.deserialize(response, 'list[Pet]')
|
|
||||||
return responseObject
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def find_pets_by_tags(self, **kwargs):
|
|
||||||
"""Finds Pets by tags
|
|
||||||
Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
tags, list[str]: Tags to filter by (optional)
|
|
||||||
|
|
||||||
|
|
||||||
Returns: list[Pet]
|
|
||||||
"""
|
|
||||||
|
|
||||||
allParams = ['tags']
|
|
||||||
|
|
||||||
params = locals()
|
|
||||||
for (key, val) in params['kwargs'].items():
|
|
||||||
if key not in allParams:
|
|
||||||
raise TypeError("Got an unexpected keyword argument '%s' to method find_pets_by_tags" % key)
|
|
||||||
params[key] = val
|
|
||||||
del params['kwargs']
|
|
||||||
|
|
||||||
resourcePath = '/pet/findByTags'
|
|
||||||
resourcePath = resourcePath.replace('{format}', 'json')
|
|
||||||
method = 'GET'
|
|
||||||
|
|
||||||
queryParams = {}
|
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
|
|
||||||
if ('tags' in params):
|
|
||||||
queryParams['tags'] = self.apiClient.toPathValue(params['tags'])
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
postData = (params['body'] if 'body' in params else None)
|
|
||||||
|
|
||||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
|
||||||
postData, headerParams)
|
|
||||||
|
|
||||||
|
|
||||||
if not response:
|
|
||||||
return None
|
|
||||||
|
|
||||||
responseObject = self.apiClient.deserialize(response, 'list[Pet]')
|
|
||||||
return responseObject
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_pet_by_id(self, **kwargs):
|
|
||||||
"""Find pet by ID
|
|
||||||
Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
|
|
||||||
|
|
||||||
Args:
|
|
||||||
pet_id, int: ID of pet that needs to be fetched (required)
|
|
||||||
|
|
||||||
|
|
||||||
Returns: Pet
|
|
||||||
"""
|
|
||||||
|
|
||||||
allParams = ['pet_id']
|
|
||||||
|
|
||||||
params = locals()
|
|
||||||
for (key, val) in params['kwargs'].items():
|
|
||||||
if key not in allParams:
|
|
||||||
raise TypeError("Got an unexpected keyword argument '%s' to method get_pet_by_id" % key)
|
|
||||||
params[key] = val
|
|
||||||
del params['kwargs']
|
|
||||||
|
|
||||||
resourcePath = '/pet/{petId}'
|
|
||||||
resourcePath = resourcePath.replace('{format}', 'json')
|
|
||||||
method = 'GET'
|
|
||||||
|
|
||||||
queryParams = {}
|
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ('pet_id' in params):
|
|
||||||
replacement = str(self.apiClient.toPathValue(params['pet_id']))
|
|
||||||
resourcePath = resourcePath.replace('{' + 'petId' + '}',
|
|
||||||
replacement)
|
|
||||||
|
|
||||||
|
|
||||||
postData = (params['body'] if 'body' in params else None)
|
|
||||||
|
|
||||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
|
||||||
postData, headerParams)
|
|
||||||
|
|
||||||
|
|
||||||
if not response:
|
|
||||||
return None
|
|
||||||
|
|
||||||
responseObject = self.apiClient.deserialize(response, 'Pet')
|
|
||||||
return responseObject
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def update_pet_with_form(self, **kwargs):
|
|
||||||
"""Updates a pet in the store with form data
|
|
||||||
|
|
||||||
|
|
||||||
Args:
|
|
||||||
pet_id, str: ID of pet that needs to be updated (required)
|
|
||||||
name, str: Updated name of the pet (optional)
|
|
||||||
status, str: Updated status of the pet (optional)
|
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
"""
|
|
||||||
|
|
||||||
allParams = ['pet_id', 'name', 'status']
|
|
||||||
|
|
||||||
params = locals()
|
|
||||||
for (key, val) in params['kwargs'].items():
|
|
||||||
if key not in allParams:
|
|
||||||
raise TypeError("Got an unexpected keyword argument '%s' to method update_pet_with_form" % key)
|
|
||||||
params[key] = val
|
|
||||||
del params['kwargs']
|
|
||||||
|
|
||||||
resourcePath = '/pet/{petId}'
|
|
||||||
resourcePath = resourcePath.replace('{format}', 'json')
|
|
||||||
method = 'POST'
|
|
||||||
|
|
||||||
queryParams = {}
|
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ('pet_id' in params):
|
|
||||||
replacement = str(self.apiClient.toPathValue(params['pet_id']))
|
|
||||||
resourcePath = resourcePath.replace('{' + 'petId' + '}',
|
|
||||||
replacement)
|
|
||||||
|
|
||||||
|
|
||||||
postData = (params['body'] if 'body' in params else None)
|
|
||||||
|
|
||||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
|
||||||
postData, headerParams)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def delete_pet(self, **kwargs):
|
|
||||||
"""Deletes a pet
|
|
||||||
|
|
||||||
|
|
||||||
Args:
|
|
||||||
api_key, str: (optional)
|
|
||||||
pet_id, int: Pet id to delete (required)
|
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
"""
|
|
||||||
|
|
||||||
allParams = ['api_key', 'pet_id']
|
|
||||||
|
|
||||||
params = locals()
|
|
||||||
for (key, val) in params['kwargs'].items():
|
|
||||||
if key not in allParams:
|
|
||||||
raise TypeError("Got an unexpected keyword argument '%s' to method delete_pet" % key)
|
|
||||||
params[key] = val
|
|
||||||
del params['kwargs']
|
|
||||||
|
|
||||||
resourcePath = '/pet/{petId}'
|
|
||||||
resourcePath = resourcePath.replace('{format}', 'json')
|
|
||||||
method = 'DELETE'
|
|
||||||
|
|
||||||
queryParams = {}
|
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ('api_key' in params):
|
|
||||||
headerParams['api_key'] = params['api_key']
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ('pet_id' in params):
|
|
||||||
replacement = str(self.apiClient.toPathValue(params['pet_id']))
|
|
||||||
resourcePath = resourcePath.replace('{' + 'petId' + '}',
|
|
||||||
replacement)
|
|
||||||
|
|
||||||
|
|
||||||
postData = (params['body'] if 'body' in params else None)
|
|
||||||
|
|
||||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
|
||||||
postData, headerParams)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def upload_file(self, **kwargs):
|
|
||||||
"""uploads an image
|
|
||||||
|
|
||||||
|
|
||||||
Args:
|
|
||||||
pet_id, int: ID of pet to update (required)
|
|
||||||
additional_metadata, str: Additional data to pass to server (optional)
|
|
||||||
file, file: file to upload (optional)
|
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
"""
|
|
||||||
|
|
||||||
allParams = ['pet_id', 'additional_metadata', 'file']
|
|
||||||
|
|
||||||
params = locals()
|
|
||||||
for (key, val) in params['kwargs'].items():
|
|
||||||
if key not in allParams:
|
|
||||||
raise TypeError("Got an unexpected keyword argument '%s' to method upload_file" % key)
|
|
||||||
params[key] = val
|
|
||||||
del params['kwargs']
|
|
||||||
|
|
||||||
resourcePath = '/pet/{petId}/uploadImage'
|
|
||||||
resourcePath = resourcePath.replace('{format}', 'json')
|
|
||||||
method = 'POST'
|
|
||||||
|
|
||||||
queryParams = {}
|
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ('pet_id' in params):
|
|
||||||
replacement = str(self.apiClient.toPathValue(params['pet_id']))
|
|
||||||
resourcePath = resourcePath.replace('{' + 'petId' + '}',
|
|
||||||
replacement)
|
|
||||||
|
|
||||||
|
|
||||||
postData = (params['body'] if 'body' in params else None)
|
|
||||||
|
|
||||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
|
||||||
postData, headerParams)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,229 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
"""
|
|
||||||
StoreApi.py
|
|
||||||
Copyright 2015 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.
|
|
||||||
|
|
||||||
NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
|
||||||
"""
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
|
|
||||||
from .models import *
|
|
||||||
|
|
||||||
|
|
||||||
class StoreApi(object):
|
|
||||||
|
|
||||||
def __init__(self, apiClient):
|
|
||||||
self.apiClient = apiClient
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_inventory(self, **kwargs):
|
|
||||||
"""Returns pet inventories by status
|
|
||||||
Returns a map of status codes to quantities
|
|
||||||
|
|
||||||
Args:
|
|
||||||
|
|
||||||
|
|
||||||
Returns: map(String, int)
|
|
||||||
"""
|
|
||||||
|
|
||||||
allParams = []
|
|
||||||
|
|
||||||
params = locals()
|
|
||||||
for (key, val) in params['kwargs'].items():
|
|
||||||
if key not in allParams:
|
|
||||||
raise TypeError("Got an unexpected keyword argument '%s' to method get_inventory" % key)
|
|
||||||
params[key] = val
|
|
||||||
del params['kwargs']
|
|
||||||
|
|
||||||
resourcePath = '/store/inventory'
|
|
||||||
resourcePath = resourcePath.replace('{format}', 'json')
|
|
||||||
method = 'GET'
|
|
||||||
|
|
||||||
queryParams = {}
|
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
postData = (params['body'] if 'body' in params else None)
|
|
||||||
|
|
||||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
|
||||||
postData, headerParams)
|
|
||||||
|
|
||||||
|
|
||||||
if not response:
|
|
||||||
return None
|
|
||||||
|
|
||||||
responseObject = self.apiClient.deserialize(response, 'map(String, int)')
|
|
||||||
return responseObject
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def place_order(self, **kwargs):
|
|
||||||
"""Place an order for a pet
|
|
||||||
|
|
||||||
|
|
||||||
Args:
|
|
||||||
body, Order: order placed for purchasing the pet (optional)
|
|
||||||
|
|
||||||
|
|
||||||
Returns: Order
|
|
||||||
"""
|
|
||||||
|
|
||||||
allParams = ['body']
|
|
||||||
|
|
||||||
params = locals()
|
|
||||||
for (key, val) in params['kwargs'].items():
|
|
||||||
if key not in allParams:
|
|
||||||
raise TypeError("Got an unexpected keyword argument '%s' to method place_order" % key)
|
|
||||||
params[key] = val
|
|
||||||
del params['kwargs']
|
|
||||||
|
|
||||||
resourcePath = '/store/order'
|
|
||||||
resourcePath = resourcePath.replace('{format}', 'json')
|
|
||||||
method = 'POST'
|
|
||||||
|
|
||||||
queryParams = {}
|
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
postData = (params['body'] if 'body' in params else None)
|
|
||||||
|
|
||||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
|
||||||
postData, headerParams)
|
|
||||||
|
|
||||||
|
|
||||||
if not response:
|
|
||||||
return None
|
|
||||||
|
|
||||||
responseObject = self.apiClient.deserialize(response, 'Order')
|
|
||||||
return responseObject
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_order_by_id(self, **kwargs):
|
|
||||||
"""Find purchase order by ID
|
|
||||||
For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
|
||||||
|
|
||||||
Args:
|
|
||||||
order_id, str: ID of pet that needs to be fetched (required)
|
|
||||||
|
|
||||||
|
|
||||||
Returns: Order
|
|
||||||
"""
|
|
||||||
|
|
||||||
allParams = ['order_id']
|
|
||||||
|
|
||||||
params = locals()
|
|
||||||
for (key, val) in params['kwargs'].items():
|
|
||||||
if key not in allParams:
|
|
||||||
raise TypeError("Got an unexpected keyword argument '%s' to method get_order_by_id" % key)
|
|
||||||
params[key] = val
|
|
||||||
del params['kwargs']
|
|
||||||
|
|
||||||
resourcePath = '/store/order/{orderId}'
|
|
||||||
resourcePath = resourcePath.replace('{format}', 'json')
|
|
||||||
method = 'GET'
|
|
||||||
|
|
||||||
queryParams = {}
|
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ('order_id' in params):
|
|
||||||
replacement = str(self.apiClient.toPathValue(params['order_id']))
|
|
||||||
resourcePath = resourcePath.replace('{' + 'orderId' + '}',
|
|
||||||
replacement)
|
|
||||||
|
|
||||||
|
|
||||||
postData = (params['body'] if 'body' in params else None)
|
|
||||||
|
|
||||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
|
||||||
postData, headerParams)
|
|
||||||
|
|
||||||
|
|
||||||
if not response:
|
|
||||||
return None
|
|
||||||
|
|
||||||
responseObject = self.apiClient.deserialize(response, 'Order')
|
|
||||||
return responseObject
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def delete_order(self, **kwargs):
|
|
||||||
"""Delete purchase order by ID
|
|
||||||
For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
|
||||||
|
|
||||||
Args:
|
|
||||||
order_id, str: ID of the order that needs to be deleted (required)
|
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
"""
|
|
||||||
|
|
||||||
allParams = ['order_id']
|
|
||||||
|
|
||||||
params = locals()
|
|
||||||
for (key, val) in params['kwargs'].items():
|
|
||||||
if key not in allParams:
|
|
||||||
raise TypeError("Got an unexpected keyword argument '%s' to method delete_order" % key)
|
|
||||||
params[key] = val
|
|
||||||
del params['kwargs']
|
|
||||||
|
|
||||||
resourcePath = '/store/order/{orderId}'
|
|
||||||
resourcePath = resourcePath.replace('{format}', 'json')
|
|
||||||
method = 'DELETE'
|
|
||||||
|
|
||||||
queryParams = {}
|
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ('order_id' in params):
|
|
||||||
replacement = str(self.apiClient.toPathValue(params['order_id']))
|
|
||||||
resourcePath = resourcePath.replace('{' + 'orderId' + '}',
|
|
||||||
replacement)
|
|
||||||
|
|
||||||
|
|
||||||
postData = (params['body'] if 'body' in params else None)
|
|
||||||
|
|
||||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
|
||||||
postData, headerParams)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,230 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
"""Wordnik.com's 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."""
|
|
||||||
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
import re
|
|
||||||
import urllib.request, urllib.error, urllib.parse
|
|
||||||
import http.client
|
|
||||||
import json
|
|
||||||
import datetime
|
|
||||||
|
|
||||||
from .models import *
|
|
||||||
|
|
||||||
|
|
||||||
class ApiClient:
|
|
||||||
"""Generic API client for Swagger client library builds"""
|
|
||||||
|
|
||||||
def __init__(self, apiKey=None, apiServer=None):
|
|
||||||
if apiKey == None:
|
|
||||||
raise Exception('You must pass an apiKey when instantiating the '
|
|
||||||
'APIClient')
|
|
||||||
self.apiKey = apiKey
|
|
||||||
self.apiServer = apiServer
|
|
||||||
self.cookie = None
|
|
||||||
|
|
||||||
def callAPI(self, resourcePath, method, queryParams, postData,
|
|
||||||
headerParams=None):
|
|
||||||
|
|
||||||
url = self.apiServer + resourcePath
|
|
||||||
headers = {}
|
|
||||||
if headerParams:
|
|
||||||
for param, value in headerParams.items():
|
|
||||||
headers[param] = value
|
|
||||||
|
|
||||||
#headers['Content-type'] = 'application/json'
|
|
||||||
headers['api_key'] = self.apiKey
|
|
||||||
|
|
||||||
if self.cookie:
|
|
||||||
headers['Cookie'] = self.cookie
|
|
||||||
|
|
||||||
data = None
|
|
||||||
|
|
||||||
if queryParams:
|
|
||||||
# Need to remove None values, these should not be sent
|
|
||||||
sentQueryParams = {}
|
|
||||||
for param, value in queryParams.items():
|
|
||||||
if value != None:
|
|
||||||
sentQueryParams[param] = value
|
|
||||||
url = url + '?' + urllib.parse.urlencode(sentQueryParams)
|
|
||||||
|
|
||||||
if method in ['GET']:
|
|
||||||
|
|
||||||
#Options to add statements later on and for compatibility
|
|
||||||
pass
|
|
||||||
|
|
||||||
elif method in ['PATCH', 'POST', 'PUT', 'DELETE']:
|
|
||||||
|
|
||||||
if postData:
|
|
||||||
headers['Content-type'] = 'application/json'
|
|
||||||
data = self.sanitizeForSerialization(postData)
|
|
||||||
data = json.dumps(data)
|
|
||||||
|
|
||||||
else:
|
|
||||||
raise Exception('Method ' + method + ' is not recognized.')
|
|
||||||
|
|
||||||
if data:
|
|
||||||
data = data.encode('utf-8')
|
|
||||||
|
|
||||||
requestParams = MethodRequest(method=method, url=url,
|
|
||||||
headers=headers, data=data)
|
|
||||||
|
|
||||||
# Make the request
|
|
||||||
request = urllib.request.urlopen(requestParams)
|
|
||||||
encoding = request.headers.get_content_charset()
|
|
||||||
if not encoding:
|
|
||||||
encoding = 'iso-8859-1'
|
|
||||||
response = request.read().decode(encoding)
|
|
||||||
|
|
||||||
try:
|
|
||||||
data = json.loads(response)
|
|
||||||
except ValueError: # PUT requests don't return anything
|
|
||||||
data = None
|
|
||||||
|
|
||||||
return data
|
|
||||||
|
|
||||||
def toPathValue(self, obj):
|
|
||||||
"""Convert a string or object to a path-friendly value
|
|
||||||
Args:
|
|
||||||
obj -- object or string value
|
|
||||||
Returns:
|
|
||||||
string -- quoted value
|
|
||||||
"""
|
|
||||||
if type(obj) == list:
|
|
||||||
return urllib.parse.quote(','.join(obj))
|
|
||||||
else:
|
|
||||||
return urllib.parse.quote(str(obj))
|
|
||||||
|
|
||||||
def sanitizeForSerialization(self, obj):
|
|
||||||
"""Dump an object into JSON for POSTing."""
|
|
||||||
|
|
||||||
if type(obj) == type(None):
|
|
||||||
return None
|
|
||||||
elif type(obj) in [str, int, float, bool]:
|
|
||||||
return obj
|
|
||||||
elif type(obj) == list:
|
|
||||||
return [self.sanitizeForSerialization(subObj) for subObj in obj]
|
|
||||||
elif type(obj) == datetime.datetime:
|
|
||||||
return obj.isoformat()
|
|
||||||
else:
|
|
||||||
if type(obj) == dict:
|
|
||||||
objDict = obj
|
|
||||||
else:
|
|
||||||
objDict = obj.__dict__
|
|
||||||
return {key: self.sanitizeForSerialization(val)
|
|
||||||
for (key, val) in objDict.items()
|
|
||||||
if key != 'swaggerTypes'}
|
|
||||||
|
|
||||||
def _iso8601Format(self, timesep, microsecond, offset, zulu):
|
|
||||||
"""Format for parsing a datetime string with given properties.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
timesep -- string separating time from date ('T' or 't')
|
|
||||||
microsecond -- microsecond portion of time ('.XXX')
|
|
||||||
offset -- time offset (+/-XX:XX) or None
|
|
||||||
zulu -- 'Z' or 'z' for UTC, or None for time offset (+/-XX:XX)
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
str - format string for datetime.strptime"""
|
|
||||||
|
|
||||||
return '%Y-%m-%d{}%H:%M:%S{}{}'.format(
|
|
||||||
timesep,
|
|
||||||
'.%f' if microsecond else '',
|
|
||||||
zulu or ('%z' if offset else ''))
|
|
||||||
|
|
||||||
# http://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14
|
|
||||||
_iso8601Regex = re.compile(
|
|
||||||
r'^\d\d\d\d-\d\d-\d\d([Tt])\d\d:\d\d:\d\d(\.\d+)?(([Zz])|(\+|-)\d\d:?\d\d)?$')
|
|
||||||
|
|
||||||
def _parseDatetime(self, d):
|
|
||||||
if d is None:
|
|
||||||
return None
|
|
||||||
m = ApiClient._iso8601Regex.match(d)
|
|
||||||
if not m:
|
|
||||||
raise Exception('datetime regex match failed "%s"' % d)
|
|
||||||
timesep, microsecond, offset, zulu, plusminus = m.groups()
|
|
||||||
format = self._iso8601Format(timesep, microsecond, offset, zulu)
|
|
||||||
if offset and not zulu:
|
|
||||||
d = d.rsplit(sep=plusminus, maxsplit=1)[0] + offset.replace(':', '')
|
|
||||||
return datetime.datetime.strptime(d, format)
|
|
||||||
|
|
||||||
def deserialize(self, obj, objClass):
|
|
||||||
"""Derialize a JSON string into an object.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
obj -- string or object to be deserialized
|
|
||||||
objClass -- class literal for deserialzied object, or string
|
|
||||||
of class name
|
|
||||||
Returns:
|
|
||||||
object -- deserialized object"""
|
|
||||||
|
|
||||||
# Have to accept objClass as string or actual type. Type could be a
|
|
||||||
# native Python type, or one of the model classes.
|
|
||||||
if type(objClass) == str:
|
|
||||||
if 'list[' in objClass:
|
|
||||||
match = re.match('list\[(.*)\]', objClass)
|
|
||||||
subClass = match.group(1)
|
|
||||||
return [self.deserialize(subObj, subClass) for subObj in obj]
|
|
||||||
|
|
||||||
if (objClass in ['int', 'float', 'dict', 'list', 'str', 'bool', 'datetime']):
|
|
||||||
objClass = eval(objClass)
|
|
||||||
else: # not a native type, must be model class
|
|
||||||
objClass = eval(objClass + '.' + objClass)
|
|
||||||
|
|
||||||
if objClass in [int, float, dict, list, str, bool]:
|
|
||||||
return objClass(obj)
|
|
||||||
elif objClass == datetime:
|
|
||||||
return self._parseDatetime(obj)
|
|
||||||
|
|
||||||
instance = objClass()
|
|
||||||
|
|
||||||
for attr, attrType in instance.swaggerTypes.items():
|
|
||||||
|
|
||||||
if attr in obj:
|
|
||||||
value = obj[attr]
|
|
||||||
if attrType in ['str', 'int', 'float', 'bool']:
|
|
||||||
attrType = eval(attrType)
|
|
||||||
try:
|
|
||||||
value = attrType(value)
|
|
||||||
except UnicodeEncodeError:
|
|
||||||
value = unicode(value)
|
|
||||||
except TypeError:
|
|
||||||
value = value
|
|
||||||
setattr(instance, attr, value)
|
|
||||||
elif (attrType == 'datetime'):
|
|
||||||
setattr(instance, attr, self._parseDatetime(value))
|
|
||||||
elif 'list[' in attrType:
|
|
||||||
match = re.match('list\[(.*)\]', attrType)
|
|
||||||
subClass = match.group(1)
|
|
||||||
subValues = []
|
|
||||||
if not value:
|
|
||||||
setattr(instance, attr, None)
|
|
||||||
else:
|
|
||||||
for subValue in value:
|
|
||||||
subValues.append(self.deserialize(subValue,
|
|
||||||
subClass))
|
|
||||||
setattr(instance, attr, subValues)
|
|
||||||
else:
|
|
||||||
setattr(instance, attr, self.deserialize(value,
|
|
||||||
attrType))
|
|
||||||
|
|
||||||
return instance
|
|
||||||
|
|
||||||
|
|
||||||
class MethodRequest(urllib.request.Request):
|
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
"""Construct a MethodRequest. Usage is the same as for
|
|
||||||
`urllib.Request` except it also takes an optional `method`
|
|
||||||
keyword argument. If supplied, `method` will be used instead of
|
|
||||||
the default."""
|
|
||||||
|
|
||||||
if 'method' in kwargs:
|
|
||||||
self.method = kwargs.pop('method')
|
|
||||||
return urllib.request.Request.__init__(self, *args, **kwargs)
|
|
||||||
|
|
||||||
def get_method(self):
|
|
||||||
return getattr(self, 'method', urllib.request.Request.get_method(self))
|
|
@ -1,404 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
"""
|
|
||||||
UserApi.py
|
|
||||||
Copyright 2015 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.
|
|
||||||
|
|
||||||
NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
|
||||||
"""
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
|
|
||||||
from .models import *
|
|
||||||
|
|
||||||
|
|
||||||
class UserApi(object):
|
|
||||||
|
|
||||||
def __init__(self, apiClient):
|
|
||||||
self.apiClient = apiClient
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def create_user(self, **kwargs):
|
|
||||||
"""Create user
|
|
||||||
This can only be done by the logged in user.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
body, User: Created user object (optional)
|
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
"""
|
|
||||||
|
|
||||||
allParams = ['body']
|
|
||||||
|
|
||||||
params = locals()
|
|
||||||
for (key, val) in params['kwargs'].items():
|
|
||||||
if key not in allParams:
|
|
||||||
raise TypeError("Got an unexpected keyword argument '%s' to method create_user" % key)
|
|
||||||
params[key] = val
|
|
||||||
del params['kwargs']
|
|
||||||
|
|
||||||
resourcePath = '/user'
|
|
||||||
resourcePath = resourcePath.replace('{format}', 'json')
|
|
||||||
method = 'POST'
|
|
||||||
|
|
||||||
queryParams = {}
|
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
postData = (params['body'] if 'body' in params else None)
|
|
||||||
|
|
||||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
|
||||||
postData, headerParams)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def create_users_with_array_input(self, **kwargs):
|
|
||||||
"""Creates list of users with given input array
|
|
||||||
|
|
||||||
|
|
||||||
Args:
|
|
||||||
body, list[User]: List of user object (optional)
|
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
"""
|
|
||||||
|
|
||||||
allParams = ['body']
|
|
||||||
|
|
||||||
params = locals()
|
|
||||||
for (key, val) in params['kwargs'].items():
|
|
||||||
if key not in allParams:
|
|
||||||
raise TypeError("Got an unexpected keyword argument '%s' to method create_users_with_array_input" % key)
|
|
||||||
params[key] = val
|
|
||||||
del params['kwargs']
|
|
||||||
|
|
||||||
resourcePath = '/user/createWithArray'
|
|
||||||
resourcePath = resourcePath.replace('{format}', 'json')
|
|
||||||
method = 'POST'
|
|
||||||
|
|
||||||
queryParams = {}
|
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
postData = (params['body'] if 'body' in params else None)
|
|
||||||
|
|
||||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
|
||||||
postData, headerParams)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def create_users_with_list_input(self, **kwargs):
|
|
||||||
"""Creates list of users with given input array
|
|
||||||
|
|
||||||
|
|
||||||
Args:
|
|
||||||
body, list[User]: List of user object (optional)
|
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
"""
|
|
||||||
|
|
||||||
allParams = ['body']
|
|
||||||
|
|
||||||
params = locals()
|
|
||||||
for (key, val) in params['kwargs'].items():
|
|
||||||
if key not in allParams:
|
|
||||||
raise TypeError("Got an unexpected keyword argument '%s' to method create_users_with_list_input" % key)
|
|
||||||
params[key] = val
|
|
||||||
del params['kwargs']
|
|
||||||
|
|
||||||
resourcePath = '/user/createWithList'
|
|
||||||
resourcePath = resourcePath.replace('{format}', 'json')
|
|
||||||
method = 'POST'
|
|
||||||
|
|
||||||
queryParams = {}
|
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
postData = (params['body'] if 'body' in params else None)
|
|
||||||
|
|
||||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
|
||||||
postData, headerParams)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def login_user(self, **kwargs):
|
|
||||||
"""Logs user into the system
|
|
||||||
|
|
||||||
|
|
||||||
Args:
|
|
||||||
username, str: The user name for login (optional)
|
|
||||||
password, str: The password for login in clear text (optional)
|
|
||||||
|
|
||||||
|
|
||||||
Returns: str
|
|
||||||
"""
|
|
||||||
|
|
||||||
allParams = ['username', 'password']
|
|
||||||
|
|
||||||
params = locals()
|
|
||||||
for (key, val) in params['kwargs'].items():
|
|
||||||
if key not in allParams:
|
|
||||||
raise TypeError("Got an unexpected keyword argument '%s' to method login_user" % key)
|
|
||||||
params[key] = val
|
|
||||||
del params['kwargs']
|
|
||||||
|
|
||||||
resourcePath = '/user/login'
|
|
||||||
resourcePath = resourcePath.replace('{format}', 'json')
|
|
||||||
method = 'GET'
|
|
||||||
|
|
||||||
queryParams = {}
|
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
|
|
||||||
if ('username' in params):
|
|
||||||
queryParams['username'] = self.apiClient.toPathValue(params['username'])
|
|
||||||
|
|
||||||
if ('password' in params):
|
|
||||||
queryParams['password'] = self.apiClient.toPathValue(params['password'])
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
postData = (params['body'] if 'body' in params else None)
|
|
||||||
|
|
||||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
|
||||||
postData, headerParams)
|
|
||||||
|
|
||||||
|
|
||||||
if not response:
|
|
||||||
return None
|
|
||||||
|
|
||||||
responseObject = self.apiClient.deserialize(response, 'str')
|
|
||||||
return responseObject
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def logout_user(self, **kwargs):
|
|
||||||
"""Logs out current logged in user session
|
|
||||||
|
|
||||||
|
|
||||||
Args:
|
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
"""
|
|
||||||
|
|
||||||
allParams = []
|
|
||||||
|
|
||||||
params = locals()
|
|
||||||
for (key, val) in params['kwargs'].items():
|
|
||||||
if key not in allParams:
|
|
||||||
raise TypeError("Got an unexpected keyword argument '%s' to method logout_user" % key)
|
|
||||||
params[key] = val
|
|
||||||
del params['kwargs']
|
|
||||||
|
|
||||||
resourcePath = '/user/logout'
|
|
||||||
resourcePath = resourcePath.replace('{format}', 'json')
|
|
||||||
method = 'GET'
|
|
||||||
|
|
||||||
queryParams = {}
|
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
postData = (params['body'] if 'body' in params else None)
|
|
||||||
|
|
||||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
|
||||||
postData, headerParams)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_user_by_name(self, **kwargs):
|
|
||||||
"""Get user by user name
|
|
||||||
|
|
||||||
|
|
||||||
Args:
|
|
||||||
username, str: The name that needs to be fetched. Use user1 for testing. (required)
|
|
||||||
|
|
||||||
|
|
||||||
Returns: User
|
|
||||||
"""
|
|
||||||
|
|
||||||
allParams = ['username']
|
|
||||||
|
|
||||||
params = locals()
|
|
||||||
for (key, val) in params['kwargs'].items():
|
|
||||||
if key not in allParams:
|
|
||||||
raise TypeError("Got an unexpected keyword argument '%s' to method get_user_by_name" % key)
|
|
||||||
params[key] = val
|
|
||||||
del params['kwargs']
|
|
||||||
|
|
||||||
resourcePath = '/user/{username}'
|
|
||||||
resourcePath = resourcePath.replace('{format}', 'json')
|
|
||||||
method = 'GET'
|
|
||||||
|
|
||||||
queryParams = {}
|
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ('username' in params):
|
|
||||||
replacement = str(self.apiClient.toPathValue(params['username']))
|
|
||||||
resourcePath = resourcePath.replace('{' + 'username' + '}',
|
|
||||||
replacement)
|
|
||||||
|
|
||||||
|
|
||||||
postData = (params['body'] if 'body' in params else None)
|
|
||||||
|
|
||||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
|
||||||
postData, headerParams)
|
|
||||||
|
|
||||||
|
|
||||||
if not response:
|
|
||||||
return None
|
|
||||||
|
|
||||||
responseObject = self.apiClient.deserialize(response, 'User')
|
|
||||||
return responseObject
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def update_user(self, **kwargs):
|
|
||||||
"""Updated user
|
|
||||||
This can only be done by the logged in user.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
username, str: name that need to be deleted (required)
|
|
||||||
body, User: Updated user object (optional)
|
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
"""
|
|
||||||
|
|
||||||
allParams = ['username', 'body']
|
|
||||||
|
|
||||||
params = locals()
|
|
||||||
for (key, val) in params['kwargs'].items():
|
|
||||||
if key not in allParams:
|
|
||||||
raise TypeError("Got an unexpected keyword argument '%s' to method update_user" % key)
|
|
||||||
params[key] = val
|
|
||||||
del params['kwargs']
|
|
||||||
|
|
||||||
resourcePath = '/user/{username}'
|
|
||||||
resourcePath = resourcePath.replace('{format}', 'json')
|
|
||||||
method = 'PUT'
|
|
||||||
|
|
||||||
queryParams = {}
|
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ('username' in params):
|
|
||||||
replacement = str(self.apiClient.toPathValue(params['username']))
|
|
||||||
resourcePath = resourcePath.replace('{' + 'username' + '}',
|
|
||||||
replacement)
|
|
||||||
|
|
||||||
|
|
||||||
postData = (params['body'] if 'body' in params else None)
|
|
||||||
|
|
||||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
|
||||||
postData, headerParams)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def delete_user(self, **kwargs):
|
|
||||||
"""Delete user
|
|
||||||
This can only be done by the logged in user.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
username, str: The name that needs to be deleted (required)
|
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
"""
|
|
||||||
|
|
||||||
allParams = ['username']
|
|
||||||
|
|
||||||
params = locals()
|
|
||||||
for (key, val) in params['kwargs'].items():
|
|
||||||
if key not in allParams:
|
|
||||||
raise TypeError("Got an unexpected keyword argument '%s' to method delete_user" % key)
|
|
||||||
params[key] = val
|
|
||||||
del params['kwargs']
|
|
||||||
|
|
||||||
resourcePath = '/user/{username}'
|
|
||||||
resourcePath = resourcePath.replace('{format}', 'json')
|
|
||||||
method = 'DELETE'
|
|
||||||
|
|
||||||
queryParams = {}
|
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ('username' in params):
|
|
||||||
replacement = str(self.apiClient.toPathValue(params['username']))
|
|
||||||
resourcePath = resourcePath.replace('{' + 'username' + '}',
|
|
||||||
replacement)
|
|
||||||
|
|
||||||
|
|
||||||
postData = (params['body'] if 'body' in params else None)
|
|
||||||
|
|
||||||
response = self.apiClient.callAPI(resourcePath, method, queryParams,
|
|
||||||
postData, headerParams)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,32 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
"""
|
|
||||||
Copyright 2014 Wordnik, Inc.
|
|
||||||
|
|
||||||
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.
|
|
||||||
"""
|
|
||||||
class Category:
|
|
||||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
|
||||||
Do not edit the class manually."""
|
|
||||||
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
self.swaggerTypes = {
|
|
||||||
'id': 'int',
|
|
||||||
'name': 'str'
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
self.id = None # int
|
|
||||||
self.name = None # str
|
|
||||||
|
|
@ -1,39 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
"""
|
|
||||||
Copyright 2014 Wordnik, Inc.
|
|
||||||
|
|
||||||
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.
|
|
||||||
"""
|
|
||||||
class Order:
|
|
||||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
|
||||||
Do not edit the class manually."""
|
|
||||||
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
self.swaggerTypes = {
|
|
||||||
'id': 'int',
|
|
||||||
'petId': 'int',
|
|
||||||
'quantity': 'int',
|
|
||||||
'status': 'str',
|
|
||||||
'shipDate': 'datetime'
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
self.id = None # int
|
|
||||||
self.petId = None # int
|
|
||||||
self.quantity = None # int
|
|
||||||
#Order Status
|
|
||||||
self.status = None # str
|
|
||||||
self.shipDate = None # datetime
|
|
||||||
|
|
@ -1,42 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
"""
|
|
||||||
Copyright 2014 Wordnik, Inc.
|
|
||||||
|
|
||||||
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.
|
|
||||||
"""
|
|
||||||
class Pet:
|
|
||||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
|
||||||
Do not edit the class manually."""
|
|
||||||
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
self.swaggerTypes = {
|
|
||||||
'id': 'int',
|
|
||||||
'category': 'Category',
|
|
||||||
'name': 'str',
|
|
||||||
'photoUrls': 'list[str]',
|
|
||||||
'tags': 'list[Tag]',
|
|
||||||
'status': 'str'
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#unique identifier for the pet
|
|
||||||
self.id = None # int
|
|
||||||
self.category = None # Category
|
|
||||||
self.name = None # str
|
|
||||||
self.photoUrls = None # list[str]
|
|
||||||
self.tags = None # list[Tag]
|
|
||||||
#pet status in the store
|
|
||||||
self.status = None # str
|
|
||||||
|
|
@ -1,32 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
"""
|
|
||||||
Copyright 2014 Wordnik, Inc.
|
|
||||||
|
|
||||||
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.
|
|
||||||
"""
|
|
||||||
class Tag:
|
|
||||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
|
||||||
Do not edit the class manually."""
|
|
||||||
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
self.swaggerTypes = {
|
|
||||||
'id': 'int',
|
|
||||||
'name': 'str'
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
self.id = None # int
|
|
||||||
self.name = None # str
|
|
||||||
|
|
@ -1,45 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
"""
|
|
||||||
Copyright 2014 Wordnik, Inc.
|
|
||||||
|
|
||||||
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.
|
|
||||||
"""
|
|
||||||
class User:
|
|
||||||
"""NOTE: This class is auto generated by the swagger code generator program.
|
|
||||||
Do not edit the class manually."""
|
|
||||||
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
self.swaggerTypes = {
|
|
||||||
'id': 'int',
|
|
||||||
'firstName': 'str',
|
|
||||||
'username': 'str',
|
|
||||||
'lastName': 'str',
|
|
||||||
'email': 'str',
|
|
||||||
'password': 'str',
|
|
||||||
'phone': 'str',
|
|
||||||
'userStatus': 'int'
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
self.id = None # int
|
|
||||||
self.firstName = None # str
|
|
||||||
self.username = None # str
|
|
||||||
self.lastName = None # str
|
|
||||||
self.email = None # str
|
|
||||||
self.password = None # str
|
|
||||||
self.phone = None # str
|
|
||||||
#User Status
|
|
||||||
self.userStatus = None # int
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
"""Add all of the modules in the current directory to __all__"""
|
|
||||||
import os
|
|
||||||
|
|
||||||
__all__ = []
|
|
||||||
|
|
||||||
for module in os.listdir(os.path.dirname(__file__)):
|
|
||||||
if module != '__init__.py' and module[-3:] == '.py':
|
|
||||||
__all__.append(module[:-3])
|
|
||||||
|
|
@ -1,204 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
"""Wordnik.com's 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."""
|
|
||||||
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
import re
|
|
||||||
import urllib.request, urllib.error, urllib.parse
|
|
||||||
import http.client
|
|
||||||
import json
|
|
||||||
import datetime
|
|
||||||
|
|
||||||
from .models import *
|
|
||||||
|
|
||||||
|
|
||||||
class ApiClient:
|
|
||||||
"""Generic API client for Swagger client library builds"""
|
|
||||||
|
|
||||||
def __init__(self, apiKey=None, apiServer=None):
|
|
||||||
if apiKey == None:
|
|
||||||
raise Exception('You must pass an apiKey when instantiating the '
|
|
||||||
'APIClient')
|
|
||||||
self.apiKey = apiKey
|
|
||||||
self.apiServer = apiServer
|
|
||||||
self.cookie = None
|
|
||||||
|
|
||||||
def callAPI(self, resourcePath, method, queryParams, postData,
|
|
||||||
headerParams=None):
|
|
||||||
|
|
||||||
url = self.apiServer + resourcePath
|
|
||||||
headers = {}
|
|
||||||
if headerParams:
|
|
||||||
for param, value in headerParams.items():
|
|
||||||
headers[param] = value
|
|
||||||
|
|
||||||
#headers['Content-type'] = 'application/json'
|
|
||||||
headers['api_key'] = self.apiKey
|
|
||||||
|
|
||||||
if self.cookie:
|
|
||||||
headers['Cookie'] = self.cookie
|
|
||||||
|
|
||||||
data = None
|
|
||||||
|
|
||||||
|
|
||||||
if queryParams:
|
|
||||||
# Need to remove None values, these should not be sent
|
|
||||||
sentQueryParams = {}
|
|
||||||
for param, value in queryParams.items():
|
|
||||||
if value != None:
|
|
||||||
sentQueryParams[param] = value
|
|
||||||
url = url + '?' + urllib.parse.urlencode(sentQueryParams)
|
|
||||||
|
|
||||||
if method in ['GET']:
|
|
||||||
|
|
||||||
#Options to add statements later on and for compatibility
|
|
||||||
pass
|
|
||||||
|
|
||||||
elif method in ['POST', 'PUT', 'DELETE']:
|
|
||||||
|
|
||||||
if postData:
|
|
||||||
headers['Content-type'] = 'application/json'
|
|
||||||
data = self.sanitizeForSerialization(postData)
|
|
||||||
data = json.dumps(data)
|
|
||||||
|
|
||||||
else:
|
|
||||||
raise Exception('Method ' + method + ' is not recognized.')
|
|
||||||
|
|
||||||
if data:
|
|
||||||
data = data.encode('utf-8')
|
|
||||||
|
|
||||||
requestParams = MethodRequest(method=method, url=url,
|
|
||||||
headers=headers, data=data)
|
|
||||||
|
|
||||||
# Make the request
|
|
||||||
request = urllib.request.urlopen(requestParams)
|
|
||||||
encoding = request.headers.get_content_charset()
|
|
||||||
if not encoding:
|
|
||||||
encoding = 'iso-8859-1'
|
|
||||||
response = request.read().decode(encoding)
|
|
||||||
|
|
||||||
try:
|
|
||||||
data = json.loads(response)
|
|
||||||
except ValueError: # PUT requests don't return anything
|
|
||||||
data = None
|
|
||||||
|
|
||||||
return data
|
|
||||||
|
|
||||||
def toPathValue(self, obj):
|
|
||||||
"""Convert a string or object to a path-friendly value
|
|
||||||
Args:
|
|
||||||
obj -- object or string value
|
|
||||||
Returns:
|
|
||||||
string -- quoted value
|
|
||||||
"""
|
|
||||||
if type(obj) == list:
|
|
||||||
return urllib.parse.quote(','.join(obj))
|
|
||||||
else:
|
|
||||||
return urllib.parse.quote(str(obj))
|
|
||||||
|
|
||||||
def sanitizeForSerialization(self, obj):
|
|
||||||
"""Dump an object into JSON for POSTing."""
|
|
||||||
|
|
||||||
if type(obj) == type(None):
|
|
||||||
return None
|
|
||||||
elif type(obj) in [str, int, float, bool]:
|
|
||||||
return obj
|
|
||||||
elif type(obj) == list:
|
|
||||||
return [self.sanitizeForSerialization(subObj) for subObj in obj]
|
|
||||||
elif type(obj) == datetime.datetime:
|
|
||||||
return obj.isoformat()
|
|
||||||
else:
|
|
||||||
if type(obj) == dict:
|
|
||||||
objDict = obj
|
|
||||||
else:
|
|
||||||
objDict = obj.__dict__
|
|
||||||
return {key: self.sanitizeForSerialization(val)
|
|
||||||
for (key, val) in objDict.items()
|
|
||||||
if key != 'swaggerTypes'}
|
|
||||||
|
|
||||||
def deserialize(self, obj, objClass):
|
|
||||||
"""Derialize a JSON string into an object.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
obj -- string or object to be deserialized
|
|
||||||
objClass -- class literal for deserialzied object, or string
|
|
||||||
of class name
|
|
||||||
Returns:
|
|
||||||
object -- deserialized object"""
|
|
||||||
|
|
||||||
# Have to accept objClass as string or actual type. Type could be a
|
|
||||||
# native Python type, or one of the model classes.
|
|
||||||
if type(objClass) == str:
|
|
||||||
if 'list[' in objClass:
|
|
||||||
match = re.match('list\[(.*)\]', objClass)
|
|
||||||
subClass = match.group(1)
|
|
||||||
return [self.deserialize(subObj, subClass) for subObj in obj]
|
|
||||||
|
|
||||||
if (objClass in ['int', 'float', 'dict', 'list', 'str', 'bool', 'datetime']):
|
|
||||||
objClass = eval(objClass)
|
|
||||||
else: # not a native type, must be model class
|
|
||||||
objClass = eval(objClass + '.' + objClass)
|
|
||||||
|
|
||||||
if objClass in [int, float, dict, list, str, bool]:
|
|
||||||
return objClass(obj)
|
|
||||||
elif objClass == datetime:
|
|
||||||
# Server will always return a time stamp in UTC, but with
|
|
||||||
# trailing +0000 indicating no offset from UTC. So don't process
|
|
||||||
# last 5 characters.
|
|
||||||
return datetime.datetime.strptime(obj[:-5],
|
|
||||||
"%Y-%m-%dT%H:%M:%S.%f")
|
|
||||||
|
|
||||||
instance = objClass()
|
|
||||||
|
|
||||||
for attr, attrType in instance.swaggerTypes.items():
|
|
||||||
|
|
||||||
if attr in obj:
|
|
||||||
value = obj[attr]
|
|
||||||
if attrType in ['str', 'int', 'float', 'bool']:
|
|
||||||
attrType = eval(attrType)
|
|
||||||
try:
|
|
||||||
value = attrType(value)
|
|
||||||
except UnicodeEncodeError:
|
|
||||||
value = unicode(value)
|
|
||||||
except TypeError:
|
|
||||||
value = value
|
|
||||||
setattr(instance, attr, value)
|
|
||||||
elif (attrType == 'datetime'):
|
|
||||||
setattr(instance, attr, datetime.datetime.strptime(value[:-5],
|
|
||||||
"%Y-%m-%dT%H:%M:%S.%f"))
|
|
||||||
elif 'list[' in attrType:
|
|
||||||
match = re.match('list\[(.*)\]', attrType)
|
|
||||||
subClass = match.group(1)
|
|
||||||
subValues = []
|
|
||||||
if not value:
|
|
||||||
setattr(instance, attr, None)
|
|
||||||
else:
|
|
||||||
for subValue in value:
|
|
||||||
subValues.append(self.deserialize(subValue,
|
|
||||||
subClass))
|
|
||||||
setattr(instance, attr, subValues)
|
|
||||||
else:
|
|
||||||
setattr(instance, attr, self.deserialize(value,
|
|
||||||
objClass))
|
|
||||||
|
|
||||||
return instance
|
|
||||||
|
|
||||||
|
|
||||||
class MethodRequest(urllib.request.Request):
|
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
"""Construct a MethodRequest. Usage is the same as for
|
|
||||||
`urllib.Request` except it also takes an optional `method`
|
|
||||||
keyword argument. If supplied, `method` will be used instead of
|
|
||||||
the default."""
|
|
||||||
|
|
||||||
if 'method' in kwargs:
|
|
||||||
self.method = kwargs.pop('method')
|
|
||||||
return urllib.request.Request.__init__(self, *args, **kwargs)
|
|
||||||
|
|
||||||
def get_method(self):
|
|
||||||
return getattr(self, 'method', urllib.request.Request.get_method(self))
|
|
||||||
|
|
@ -1,37 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
"""Unit tests for SwaggerPython Petstore sample app API client.
|
|
||||||
|
|
||||||
Run all tests:
|
|
||||||
|
|
||||||
python BaseApiTest.py
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
import unittest
|
|
||||||
|
|
||||||
sys.path = ['./'] + sys.path
|
|
||||||
from petstore import *
|
|
||||||
|
|
||||||
|
|
||||||
class BaseApiTest(unittest.TestCase):
|
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
self.apiKey = 'special-key'
|
|
||||||
self.apiUrl = 'http://petstore.swagger.wordnik.com/api'
|
|
||||||
self.username = 'test'
|
|
||||||
self.password = 'test'
|
|
||||||
|
|
||||||
client = swagger.ApiClient(self.apiKey, self.apiUrl)
|
|
||||||
self.petApi = PetApi.PetApi(client)
|
|
||||||
self.storeApi = StoreApi.StoreApi(client)
|
|
||||||
self.userApi = UserApi.UserApi(client)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
|
|
||||||
from PetApiTest import PetApiTest
|
|
||||||
from StoreApiTest import StoreApiTest
|
|
||||||
from UserApiTest import UserApiTest
|
|
||||||
|
|
||||||
unittest.main()
|
|
@ -1,134 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
import sys
|
|
||||||
import unittest
|
|
||||||
import urllib.request, urllib.error, urllib.parse
|
|
||||||
import json
|
|
||||||
import random
|
|
||||||
|
|
||||||
from BaseApiTest import BaseApiTest
|
|
||||||
|
|
||||||
sys.path = ['./'] + sys.path
|
|
||||||
from petstore import *
|
|
||||||
from petstore.models import *
|
|
||||||
|
|
||||||
|
|
||||||
class PetApiTest(BaseApiTest):
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def setUpClass(cls):
|
|
||||||
# super(PetApiTest, self).setUp()
|
|
||||||
cls.randomId = int(90000 * random.random()) + 10000
|
|
||||||
|
|
||||||
def testPetApis(self):
|
|
||||||
url = self.apiUrl + '/pet.json'
|
|
||||||
request = urllib.request.urlopen(url)
|
|
||||||
encoding = request.headers.get_content_charset()
|
|
||||||
if not encoding:
|
|
||||||
encoding = 'iso-8859-1'
|
|
||||||
response = request.read().decode(encoding)
|
|
||||||
doc = json.loads(response)
|
|
||||||
assert len(doc['apis']) == 3, 'there should be 3 pet apis'
|
|
||||||
|
|
||||||
def testPetApisAuthenticated(self):
|
|
||||||
url = self.apiUrl + '/pet.json?' + 'api_key=special-key'
|
|
||||||
request = urllib.request.urlopen(url)
|
|
||||||
encoding = request.headers.get_content_charset()
|
|
||||||
if not encoding:
|
|
||||||
encoding = 'iso-8859-1'
|
|
||||||
response = request.read().decode(encoding)
|
|
||||||
doc = json.loads(response)
|
|
||||||
|
|
||||||
assert len(doc['apis']) == 4, 'there should be 4 pet apis when' + \
|
|
||||||
'authenticated'
|
|
||||||
|
|
||||||
def testGetPetById(self):
|
|
||||||
res = self.petApi.getPetById(1)
|
|
||||||
assert res, 'null getWord result'
|
|
||||||
assert res.id == 1, 'pet id should be 1'
|
|
||||||
|
|
||||||
def testAddPet(self):
|
|
||||||
pet = Pet.Pet()
|
|
||||||
|
|
||||||
pet.id = self.randomId
|
|
||||||
tag1 = Tag.Tag()
|
|
||||||
tag1.name = "tag1"
|
|
||||||
tag2 = Tag.Tag()
|
|
||||||
tag2.name = "some tag"
|
|
||||||
pet.tags = [tag1, tag2]
|
|
||||||
category = Category.Category()
|
|
||||||
category.name = "Cats"
|
|
||||||
pet.category = category
|
|
||||||
pet.status = "sold"
|
|
||||||
pet.name = "Shermie"
|
|
||||||
pet.photoUrls = ["http://foo.com/1.jpg", "http://foo.com/1.jpg"]
|
|
||||||
self.petApi.addPet(pet)
|
|
||||||
|
|
||||||
new_pet = self.petApi.getPetById(pet.id)
|
|
||||||
|
|
||||||
assert new_pet.id == pet.id, 'ids should match'
|
|
||||||
assert new_pet.name == pet.name, 'names should match'
|
|
||||||
assert(set([tag.name for tag in new_pet.tags]) ==
|
|
||||||
set([tag.name for tag in pet.tags])), 'tags should match'
|
|
||||||
assert new_pet.status == pet.status, 'status should match'
|
|
||||||
assert new_pet.category.name == pet.category.name, 'category should match'
|
|
||||||
assert new_pet.photoUrls == pet.photoUrls, 'photoUrls should match'
|
|
||||||
|
|
||||||
def testUpdatePet(self):
|
|
||||||
alpahbet = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
|
|
||||||
|
|
||||||
pet = Pet.Pet()
|
|
||||||
pet.id = self.randomId
|
|
||||||
|
|
||||||
tag1 = Tag.Tag()
|
|
||||||
tag1.name = "special-tag"
|
|
||||||
tag2 = Tag.Tag()
|
|
||||||
random.shuffle(alpahbet)
|
|
||||||
tag2.name = ''.join(alpahbet)
|
|
||||||
pet.tags = [tag1, tag2]
|
|
||||||
category = Category.Category()
|
|
||||||
random.shuffle(alpahbet)
|
|
||||||
category.name = ''.join(alpahbet)
|
|
||||||
pet.category = category
|
|
||||||
pet.status = "sold"
|
|
||||||
random.shuffle(alpahbet)
|
|
||||||
pet.name = ''.join(alpahbet)
|
|
||||||
pet.photoUrls = ["http://foo.com/22.jpg", "http://foo.com/55.jpg"]
|
|
||||||
self.petApi.updatePet(pet)
|
|
||||||
|
|
||||||
updated_pet = self.petApi.getPetById(pet.id)
|
|
||||||
|
|
||||||
assert updated_pet.id == pet.id, 'ids should match'
|
|
||||||
assert updated_pet.name == pet.name, 'names should match'
|
|
||||||
assert(set([tag.name for tag in updated_pet.tags]) ==
|
|
||||||
set([tag.name for tag in pet.tags])), 'tags should match'
|
|
||||||
assert updated_pet.status == pet.status, 'status should match'
|
|
||||||
assert updated_pet.category.name == pet.category.name, 'category should match'
|
|
||||||
assert updated_pet.photoUrls == pet.photoUrls, 'photoUrls should match'
|
|
||||||
|
|
||||||
def testFindPetsByTags(self):
|
|
||||||
pet = Pet.Pet()
|
|
||||||
pet.id = self.randomId
|
|
||||||
|
|
||||||
tag1 = Tag.Tag()
|
|
||||||
tag1.name = "special-tag"
|
|
||||||
pet.tags = [tag1]
|
|
||||||
self.petApi.updatePet(pet)
|
|
||||||
|
|
||||||
res = self.petApi.findPetsByTags("special-tag")
|
|
||||||
assert self.randomId in [pet.id for pet in res], 'must find by tag'
|
|
||||||
|
|
||||||
def testFindPetsByStatus(self):
|
|
||||||
pet = Pet.Pet()
|
|
||||||
pet.id = self.randomId
|
|
||||||
|
|
||||||
tag1 = Tag.Tag()
|
|
||||||
tag1.name = "special-tag"
|
|
||||||
pet.status = "sold"
|
|
||||||
self.petApi.updatePet(pet)
|
|
||||||
|
|
||||||
res = self.petApi.findPetsByStatus("sold")
|
|
||||||
assert self.randomId in [pet.id for pet in res], 'must find by status'
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
unittest.main()
|
|
@ -1,50 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
import sys
|
|
||||||
import unittest
|
|
||||||
import datetime
|
|
||||||
import random
|
|
||||||
|
|
||||||
from BaseApiTest import BaseApiTest
|
|
||||||
|
|
||||||
sys.path = ['./'] + sys.path
|
|
||||||
from petstore import *
|
|
||||||
from petstore.models import *
|
|
||||||
|
|
||||||
|
|
||||||
class StoreApiTest(BaseApiTest):
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def setUpClass(cls):
|
|
||||||
# super(PetApiTest, self).setUp()
|
|
||||||
cls.randomId = int(9500 * random.random()) + 500
|
|
||||||
|
|
||||||
def testGetOrderById(self):
|
|
||||||
res = self.storeApi.getOrderById(1)
|
|
||||||
assert res, 'null getOrderById result'
|
|
||||||
assert 1 == res.id, 'order id should be int(1)'
|
|
||||||
|
|
||||||
def testDeleteOrder(self):
|
|
||||||
self.storeApi.deleteOrder(3)
|
|
||||||
self.storeApi.deleteOrder("foo")
|
|
||||||
|
|
||||||
def testPlaceOrder(self):
|
|
||||||
|
|
||||||
order = Order.Order()
|
|
||||||
order.id = self.randomId
|
|
||||||
order.petId = 1
|
|
||||||
order.status = 'ordered'
|
|
||||||
order.quantity = 10
|
|
||||||
order.shipDate = datetime.datetime.strptime("2011-01-09T13:55:07.123",
|
|
||||||
"%Y-%m-%dT%H:%M:%S.%f")
|
|
||||||
self.storeApi.placeOrder(order)
|
|
||||||
|
|
||||||
new_order = self.storeApi.getOrderById(self.randomId)
|
|
||||||
assert new_order.id == new_order.id, 'ids should match'
|
|
||||||
assert new_order.petId == new_order.petId, 'petIds should match'
|
|
||||||
assert new_order.status == new_order.status, 'status should match'
|
|
||||||
assert new_order.quantity == new_order.quantity, 'quantity should match'
|
|
||||||
assert new_order.shipDate == new_order.shipDate, 'shipDate should match'
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
unittest.main()
|
|
@ -1,229 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
import sys
|
|
||||||
import unittest
|
|
||||||
import random
|
|
||||||
import urllib
|
|
||||||
|
|
||||||
from BaseApiTest import BaseApiTest
|
|
||||||
|
|
||||||
sys.path = ['./'] + sys.path
|
|
||||||
from petstore import *
|
|
||||||
from petstore.models import *
|
|
||||||
|
|
||||||
|
|
||||||
def randomString():
|
|
||||||
return str(randomInt())
|
|
||||||
|
|
||||||
|
|
||||||
def randomInt():
|
|
||||||
return random.randint(1000, 100000)
|
|
||||||
|
|
||||||
|
|
||||||
class UserApiTest(BaseApiTest):
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def setUpClass(cls):
|
|
||||||
alpahbet = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
|
|
||||||
random.shuffle(alpahbet)
|
|
||||||
cls.randomUsername1 = ''.join(alpahbet)
|
|
||||||
random.shuffle(alpahbet)
|
|
||||||
cls.randomUsername2 = ''.join(alpahbet)
|
|
||||||
random.shuffle(alpahbet)
|
|
||||||
cls.randomUsername3 = ''.join(alpahbet)
|
|
||||||
random.shuffle(alpahbet)
|
|
||||||
cls.randomUsername4 = ''.join(alpahbet)
|
|
||||||
random.shuffle(alpahbet)
|
|
||||||
cls.randomUsername5 = ''.join(alpahbet)
|
|
||||||
|
|
||||||
def testCreateUsersWithArrayInput(self):
|
|
||||||
|
|
||||||
user = User.User()
|
|
||||||
|
|
||||||
user.id = randomInt()
|
|
||||||
user.lastName = randomString()
|
|
||||||
user.username = self.randomUsername1
|
|
||||||
user.phone = randomString()
|
|
||||||
user.email = randomString()
|
|
||||||
user.userStatus = int(randomString())
|
|
||||||
user.firstName = randomString()
|
|
||||||
user.password = randomString()
|
|
||||||
|
|
||||||
otherUser = User.User()
|
|
||||||
|
|
||||||
otherUser.id = randomInt()
|
|
||||||
otherUser.lastName = randomString()
|
|
||||||
otherUser.username = self.randomUsername2
|
|
||||||
otherUser.phone = randomString()
|
|
||||||
otherUser.email = randomString()
|
|
||||||
otherUser.userStatus = int(randomString())
|
|
||||||
otherUser.firstName = randomString()
|
|
||||||
otherUser.password = randomString()
|
|
||||||
|
|
||||||
users = [user, otherUser]
|
|
||||||
self.userApi.createUsersWithArrayInput(users)
|
|
||||||
|
|
||||||
newUser = self.userApi.getUserByName(self.randomUsername1)
|
|
||||||
|
|
||||||
assert newUser.id == user.id, 'id matches user'
|
|
||||||
assert newUser.lastName == user.lastName, 'lastName matches user'
|
|
||||||
assert newUser.username == user.username, 'username matches user'
|
|
||||||
assert newUser.phone == user.phone, 'phone matches user'
|
|
||||||
assert newUser.email == user.email, 'email matches user'
|
|
||||||
assert newUser.userStatus == user.userStatus, 'status matches user'
|
|
||||||
assert newUser.firstName == user.firstName, 'firstName matches user'
|
|
||||||
assert newUser.password == user.password, 'password matches user'
|
|
||||||
|
|
||||||
newUser = self.userApi.getUserByName(self.randomUsername2)
|
|
||||||
|
|
||||||
assert newUser.id == otherUser.id, 'id matches user'
|
|
||||||
assert newUser.lastName == otherUser.lastName, 'lastName matches user'
|
|
||||||
assert newUser.username == otherUser.username, 'username matches user'
|
|
||||||
assert newUser.phone == otherUser.phone, 'phone matches user'
|
|
||||||
assert newUser.email == otherUser.email, 'email matches user'
|
|
||||||
assert newUser.userStatus == otherUser.userStatus, 'status matches user'
|
|
||||||
assert newUser.firstName == otherUser.firstName, 'firstName matches user'
|
|
||||||
assert newUser.password == otherUser.password, 'password matches user'
|
|
||||||
|
|
||||||
def testCreateUsersWithListInput(self):
|
|
||||||
|
|
||||||
user = User.User()
|
|
||||||
|
|
||||||
user.id = randomInt()
|
|
||||||
user.lastName = randomString()
|
|
||||||
user.username = self.randomUsername3
|
|
||||||
user.phone = randomString()
|
|
||||||
user.email = randomString()
|
|
||||||
user.userStatus = int(randomString())
|
|
||||||
user.firstName = randomString()
|
|
||||||
user.password = randomString()
|
|
||||||
|
|
||||||
otherUser = User.User()
|
|
||||||
|
|
||||||
otherUser.id = randomInt()
|
|
||||||
otherUser.lastName = randomString()
|
|
||||||
otherUser.username = self.randomUsername4
|
|
||||||
otherUser.phone = randomString()
|
|
||||||
otherUser.email = randomString()
|
|
||||||
otherUser.userStatus = int(randomString())
|
|
||||||
otherUser.firstName = randomString()
|
|
||||||
otherUser.password = randomString()
|
|
||||||
|
|
||||||
users = [user, otherUser]
|
|
||||||
self.userApi.createUsersWithListInput(users)
|
|
||||||
|
|
||||||
newUser = self.userApi.getUserByName(self.randomUsername3)
|
|
||||||
|
|
||||||
assert newUser.id == user.id, 'id matches user'
|
|
||||||
assert newUser.lastName == user.lastName, 'lastName matches user'
|
|
||||||
assert newUser.username == user.username, 'username matches user'
|
|
||||||
assert newUser.phone == user.phone, 'phone matches user'
|
|
||||||
assert newUser.email == user.email, 'email matches user'
|
|
||||||
assert newUser.userStatus == user.userStatus, 'status matches user'
|
|
||||||
assert newUser.firstName == user.firstName, 'firstName matches user'
|
|
||||||
assert newUser.password == user.password, 'password matches user'
|
|
||||||
|
|
||||||
newUser = self.userApi.getUserByName(self.randomUsername4)
|
|
||||||
|
|
||||||
assert newUser.id == otherUser.id, 'id matches user'
|
|
||||||
assert newUser.lastName == otherUser.lastName, 'lastName matches user'
|
|
||||||
assert newUser.username == otherUser.username, 'username matches user'
|
|
||||||
assert newUser.phone == otherUser.phone, 'phone matches user'
|
|
||||||
assert newUser.email == otherUser.email, 'email matches user'
|
|
||||||
assert newUser.userStatus == otherUser.userStatus, 'status matches user'
|
|
||||||
assert newUser.firstName == otherUser.firstName, 'firstName matches user'
|
|
||||||
assert newUser.password == otherUser.password, 'password matches user'
|
|
||||||
|
|
||||||
def testCreateUser(self):
|
|
||||||
|
|
||||||
user = User.User()
|
|
||||||
|
|
||||||
user.id = randomInt()
|
|
||||||
user.lastName = randomString()
|
|
||||||
user.username = self.randomUsername5
|
|
||||||
user.phone = randomString()
|
|
||||||
user.email = randomString()
|
|
||||||
user.userStatus = int(randomString())
|
|
||||||
user.firstName = randomString()
|
|
||||||
user.password = randomString()
|
|
||||||
|
|
||||||
self.userApi.createUser(user)
|
|
||||||
|
|
||||||
newUser = self.userApi.getUserByName(self.randomUsername5)
|
|
||||||
|
|
||||||
assert newUser.id, user.id
|
|
||||||
assert newUser.lastName, user.lastName
|
|
||||||
assert newUser.username, user.username
|
|
||||||
assert newUser.phone, user.phone
|
|
||||||
assert newUser.email, user.email
|
|
||||||
assert newUser.userStatus, user.userStatus
|
|
||||||
assert newUser.firstName, user.firstName
|
|
||||||
assert newUser.password, user.password
|
|
||||||
|
|
||||||
def testUpdateUser(self):
|
|
||||||
|
|
||||||
user = User.User()
|
|
||||||
username = randomString()
|
|
||||||
user.id = randomInt()
|
|
||||||
user.lastName = randomString()
|
|
||||||
user.username = username
|
|
||||||
user.phone = randomString()
|
|
||||||
user.email = randomString()
|
|
||||||
user.userStatus = int(randomString())
|
|
||||||
user.firstName = randomString()
|
|
||||||
user.password = randomString()
|
|
||||||
|
|
||||||
self.userApi.createUser(user)
|
|
||||||
|
|
||||||
user = self.userApi.getUserByName(username)
|
|
||||||
|
|
||||||
user.lastName = randomString()
|
|
||||||
user.phone = randomString()
|
|
||||||
user.email = randomString()
|
|
||||||
user.userStatus = int(randomString())
|
|
||||||
user.firstName = randomString()
|
|
||||||
user.password = randomString()
|
|
||||||
|
|
||||||
self.userApi.updateUser(username, user)
|
|
||||||
|
|
||||||
updatedUser = self.userApi.getUserByName(username)
|
|
||||||
|
|
||||||
assert updatedUser.lastName == user.lastName, 'should match lastName'
|
|
||||||
assert updatedUser.username == user.username, 'should match username'
|
|
||||||
assert updatedUser.phone == user.phone, 'should match phone'
|
|
||||||
assert updatedUser.email == user.email, 'should match email'
|
|
||||||
assert updatedUser.userStatus == user.userStatus, 'should match status'
|
|
||||||
assert updatedUser.firstName == user.firstName, 'should match firstName'
|
|
||||||
assert updatedUser.password == user.password, 'should match password'
|
|
||||||
|
|
||||||
def testDeleteUser(self):
|
|
||||||
|
|
||||||
user = User.User()
|
|
||||||
username = randomString()
|
|
||||||
user.username = username
|
|
||||||
|
|
||||||
self.userApi.createUser(user)
|
|
||||||
|
|
||||||
self.userApi.deleteUser(username)
|
|
||||||
|
|
||||||
userGone = False
|
|
||||||
|
|
||||||
try:
|
|
||||||
self.userApi.getUserByName(username)
|
|
||||||
except urllib.request.HTTPError:
|
|
||||||
userGone = True
|
|
||||||
|
|
||||||
assert userGone, 'user should be deleted'
|
|
||||||
|
|
||||||
def testLoginUser(self):
|
|
||||||
|
|
||||||
res = self.userApi.loginUser("anyusername", "anypassword")
|
|
||||||
|
|
||||||
assert res[:23] == "logged in user session:", 'should get session'
|
|
||||||
|
|
||||||
def testLogoutUser(self):
|
|
||||||
# We just want to make sure there are no errors in this test.
|
|
||||||
self.userApi.logoutUser()
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
unittest.main()
|
|
Loading…
x
Reference in New Issue
Block a user