forked from loafle/openapi-generator-original
[Python] Adds allOf/oneOf/anyOf composed models (#4446)
* Adds composed model support for allOf oneOf anyOf * Moves discriminator into discriminator() class method, adds test_deserialize_lizard, adds setting discriminator using allOf schema
This commit is contained in:
committed by
Jim Schubert
parent
02f5cb1a65
commit
789f1a06f0
15
README.md
15
README.md
@@ -482,7 +482,7 @@ SYNOPSIS
|
||||
[--model-name-prefix <model name prefix>]
|
||||
[--model-name-suffix <model name suffix>]
|
||||
[--model-package <model package>]
|
||||
[(-o <output directory> | --output <output directory>)]
|
||||
[(-o <output directory> | --output <output directory>)]
|
||||
[(-p <additional properties> | --additional-properties <additional properties>)...]
|
||||
[--package-name <package name>] [--release-note <release note>]
|
||||
[--remove-operation-id-prefix]
|
||||
@@ -562,7 +562,7 @@ Here is a list of community-conitributed IDE plug-ins that integrate with OpenAP
|
||||
- Visual Studio: [REST API Client Code Generator](https://marketplace.visualstudio.com/items?itemName=ChristianResmaHelle.ApiClientCodeGenerator) by [Christian Resma Helle](https://christian-helle.blogspot.com/)
|
||||
- Visual Studio Code: [Codewind OpenAPI Tools](https://marketplace.visualstudio.com/items?itemName=IBM.codewind-openapi-tools) by [IBM](https://marketplace.visualstudio.com/publishers/IBM)
|
||||
|
||||
|
||||
|
||||
## [4 - Companies/Projects using OpenAPI Generator](#table-of-contents)
|
||||
Here are some companies/projects (alphabetical order) using OpenAPI Generator in production. To add your company/project to the list, please visit [README.md](README.md) and click on the icon to edit the page.
|
||||
|
||||
@@ -728,7 +728,7 @@ OpenAPI Generator core team members are contributors who have been making signif
|
||||
* [@jmini](https://github.com/jmini) (2018/04) [:heart:](https://www.patreon.com/jmini)
|
||||
* [@etherealjoy](https://github.com/etherealjoy) (2019/06)
|
||||
|
||||
:heart: = Link to support the contributor directly
|
||||
:heart: = Link to support the contributor directly
|
||||
|
||||
#### Template Creator
|
||||
|
||||
@@ -783,8 +783,9 @@ Here is a list of template creators:
|
||||
* Perl: @wing328 [:heart:](https://www.patreon.com/wing328)
|
||||
* PHP (Guzzle): @baartosz
|
||||
* PowerShell: @beatcracker
|
||||
* Python-experimental: @spacether
|
||||
* R: @ramnov
|
||||
* Ruby (Faraday): @meganemura @dkliban
|
||||
* Ruby (Faraday): @meganemura @dkliban
|
||||
* Rust: @farcaller
|
||||
* Rust (rust-server): @metaswitch
|
||||
* Scala (scalaz & http4s): @tbrown1979
|
||||
@@ -794,7 +795,7 @@ Here is a list of template creators:
|
||||
* Swift 4: @ehyche
|
||||
* TypeScript (Angular1): @mhardorf
|
||||
* TypeScript (Angular2): @roni-frantchi
|
||||
* TypeScript (Angular6): @akehir
|
||||
* TypeScript (Angular6): @akehir
|
||||
* TypeScript (Angular7): @topce
|
||||
* TypeScript (Axios): @nicokoenig
|
||||
* TypeScript (Fetch): @leonyu
|
||||
@@ -806,7 +807,7 @@ Here is a list of template creators:
|
||||
* Server Stubs
|
||||
* Ada: @stcarrez
|
||||
* C# ASP.NET 5: @jimschubert [:heart:](https://www.patreon.com/jimschubert)
|
||||
* C# ASP.NET Core 3.0: @A-Joshi
|
||||
* C# ASP.NET Core 3.0: @A-Joshi
|
||||
* C# NancyFX: @mstefaniuk
|
||||
* C++ (Qt5 QHttpEngine): @etherealjoy
|
||||
* C++ Pistache: @sebymiano
|
||||
@@ -849,7 +850,7 @@ Here is a list of template creators:
|
||||
* Configuration
|
||||
* Apache2: @stkrwork
|
||||
* Schema
|
||||
* Avro: @sgadouar
|
||||
* Avro: @sgadouar
|
||||
* GraphQL: @wing328 [:heart:](https://www.patreon.com/wing328)
|
||||
* MySQL: @ybelenko
|
||||
* Protocol Buffer: @wing328
|
||||
|
||||
@@ -1858,10 +1858,12 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
m.allVars = new ArrayList<CodegenProperty>();
|
||||
if (composed.getAllOf() != null) {
|
||||
int modelImplCnt = 0; // only one inline object allowed in a ComposedModel
|
||||
int modelDiscriminators = 0; // only one discriminator allowed in a ComposedModel
|
||||
for (Schema innerSchema : composed.getAllOf()) { // TOOD need to work with anyOf, oneOf as well
|
||||
if (m.discriminator == null) {
|
||||
if (m.discriminator == null && innerSchema.getDiscriminator() != null) {
|
||||
LOGGER.debug("discriminator is set to null (not correctly set earlier): {}", name);
|
||||
m.discriminator = createDiscriminator(name, schema);
|
||||
m.discriminator = createDiscriminator(name, innerSchema);
|
||||
modelDiscriminators++;
|
||||
}
|
||||
|
||||
if (innerSchema.getXml() != null) {
|
||||
@@ -1869,6 +1871,9 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
m.xmlNamespace = innerSchema.getXml().getNamespace();
|
||||
m.xmlName = innerSchema.getXml().getName();
|
||||
}
|
||||
if (modelDiscriminators > 1) {
|
||||
LOGGER.error("Allof composed schema is inheriting >1 discriminator. Only use one discriminator: {}", composed);
|
||||
}
|
||||
|
||||
if (modelImplCnt++ > 1) {
|
||||
LOGGER.warn("More than one inline schema specified in allOf:. Only the first one is recognized. All others are ignored.");
|
||||
|
||||
@@ -273,7 +273,7 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
|
||||
}
|
||||
|
||||
private static String dropDots(String str) {
|
||||
protected static String dropDots(String str) {
|
||||
return str.replaceAll("\\.", "_");
|
||||
}
|
||||
|
||||
|
||||
@@ -52,6 +52,8 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
|
||||
// this may set datatype right for additional properties
|
||||
instantiationTypes.put("map", "dict");
|
||||
languageSpecificPrimitives.add("file_type");
|
||||
languageSpecificPrimitives.add("none_type");
|
||||
|
||||
apiTemplateFiles.remove("api.mustache");
|
||||
apiTemplateFiles.put("python-experimental/api.mustache", ".py");
|
||||
@@ -65,6 +67,9 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
modelTemplateFiles.remove("model.mustache");
|
||||
modelTemplateFiles.put("python-experimental/model.mustache", ".py");
|
||||
|
||||
modelTestTemplateFiles.remove("model_test.mustache", ".py");
|
||||
modelTestTemplateFiles.put("python-experimental/model_test.mustache", ".py");
|
||||
|
||||
generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
|
||||
.stability(Stability.EXPERIMENTAL)
|
||||
.build();
|
||||
@@ -79,11 +84,33 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
|
||||
supportingFiles.add(new SupportingFile("python-experimental/model_utils.mustache", packagePath(), "model_utils.py"));
|
||||
|
||||
supportingFiles.remove(new SupportingFile("__init__model.mustache", packagePath() + File.separatorChar + "models", "__init__.py"));
|
||||
supportingFiles.add(new SupportingFile("python-experimental/__init__model.mustache", packagePath() + File.separatorChar + "models", "__init__.py"));
|
||||
|
||||
supportingFiles.remove(new SupportingFile("__init__package.mustache", packagePath(), "__init__.py"));
|
||||
supportingFiles.add(new SupportingFile("python-experimental/__init__package.mustache", packagePath(), "__init__.py"));
|
||||
|
||||
|
||||
Boolean generateSourceCodeOnly = false;
|
||||
if (additionalProperties.containsKey(CodegenConstants.SOURCECODEONLY_GENERATION)) {
|
||||
generateSourceCodeOnly = Boolean.valueOf(additionalProperties.get(CodegenConstants.SOURCECODEONLY_GENERATION).toString());
|
||||
}
|
||||
|
||||
// remove what PythonClientCodegen did
|
||||
String readmePath = "README.md";
|
||||
String readmeTemplate = "README.mustache";
|
||||
if (generateSourceCodeOnly) {
|
||||
readmePath = packagePath() + "_" + readmePath;
|
||||
readmeTemplate = "README_onlypackage.mustache";
|
||||
}
|
||||
supportingFiles.remove(new SupportingFile(readmeTemplate, "", readmePath));
|
||||
// add the correct readme
|
||||
readmeTemplate = "python-experimental/README.mustache";
|
||||
if (generateSourceCodeOnly) {
|
||||
readmeTemplate = "python-experimental/README_onlypackage.mustache";
|
||||
}
|
||||
supportingFiles.add(new SupportingFile(readmeTemplate, "", readmePath));
|
||||
|
||||
if (!generateSourceCodeOnly) {
|
||||
supportingFiles.remove(new SupportingFile("setup.mustache", "", "setup.py"));
|
||||
supportingFiles.add(new SupportingFile("python-experimental/setup.mustache", "", "setup.py"));
|
||||
@@ -213,19 +240,76 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
}
|
||||
}
|
||||
|
||||
public void addModelImport(Map<String, Object> objs, CodegenModel cm, String otherModelName) {
|
||||
// adds the absolute path to otherModelName as an import in CodegenModel cm
|
||||
HashMap referencedModel = (HashMap) objs.get(otherModelName);
|
||||
if (referencedModel == null) {
|
||||
// this happens with a model where type=string and format=number which is a non-standard format
|
||||
@Override
|
||||
public String toModelImport(String name) {
|
||||
// name looks like cat.Cat
|
||||
String moduleName = name.split("\\.")[0];
|
||||
// https://exceptionshub.com/circular-or-cyclic-imports-in-python.html
|
||||
return "from " + modelPackage() + " import "+ moduleName;
|
||||
}
|
||||
|
||||
private String robustImport(String name) {
|
||||
// name looks like cat.Cat
|
||||
String moduleName = name.split("\\.")[0];
|
||||
// https://exceptionshub.com/circular-or-cyclic-imports-in-python.html
|
||||
String modelImport = "try:\n from " + modelPackage() + " import "+ moduleName+ "\nexcept ImportError:\n "+moduleName+" = sys.modules['"+modelPackage() + "."+ moduleName+"']";
|
||||
return modelImport;
|
||||
}
|
||||
|
||||
private String getPythonClassName(String name) {
|
||||
// name looks like cat.Cat or Cat
|
||||
String[] pieces = name.split("\\.");
|
||||
if (pieces.length == 1) {
|
||||
return pieces[0];
|
||||
}
|
||||
return pieces[1];
|
||||
}
|
||||
|
||||
private void fixOperationImports(Set<String> imports) {
|
||||
if (imports.size() == 0) {
|
||||
return;
|
||||
}
|
||||
ArrayList myModel = (ArrayList) referencedModel.get("models");
|
||||
HashMap modelData = (HashMap) myModel.get(0);
|
||||
String importPath = (String) modelData.get("importPath");
|
||||
// only add importPath to parameters if it isn't in importPaths
|
||||
if (!cm.imports.contains(importPath)) {
|
||||
cm.imports.add(importPath);
|
||||
String[] modelNames = imports.toArray(new String[0]);
|
||||
imports.clear();
|
||||
// loops through imports and converts them all from 'module.Class' to 'from models.module import module'
|
||||
for (String modelName : modelNames) {
|
||||
// if a modelName lacks the module (Pet) then we convert it to pet.Pet
|
||||
if (modelName.indexOf(".") == -1) {
|
||||
modelName = toModelName(modelName);
|
||||
}
|
||||
imports.add(toModelImport(modelName));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("static-method")
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
|
||||
HashMap<String, Object> val = (HashMap<String, Object>)objs.get("operations");
|
||||
ArrayList<CodegenOperation> operations = (ArrayList<CodegenOperation>) val.get("operation");
|
||||
ArrayList<HashMap<String, String>> imports = (ArrayList<HashMap<String, String>>)objs.get("imports");
|
||||
imports.clear();
|
||||
for (CodegenOperation operation : operations) {
|
||||
fixOperationImports(operation.imports);
|
||||
for (String thisImport : operation.imports) {
|
||||
HashMap<String, String> higherImport = new HashMap<String, String>();
|
||||
higherImport.put("import", thisImport);
|
||||
if (!imports.contains(higherImport)) {
|
||||
imports.add(higherImport);
|
||||
}
|
||||
}
|
||||
}
|
||||
return objs;
|
||||
}
|
||||
|
||||
private void fixModelImports(Set<String> imports) {
|
||||
// loops through imports and converts them all from 'module.Class' to 'import models.module as module'
|
||||
if (imports.size() == 0) {
|
||||
return;
|
||||
}
|
||||
String[] modelNames = imports.toArray(new String[0]);
|
||||
imports.clear();
|
||||
for (String modelName : modelNames) {
|
||||
imports.add(robustImport(modelName));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -241,40 +325,30 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
for (Map<String, Object> mo : models) {
|
||||
CodegenModel cm = (CodegenModel) mo.get("model");
|
||||
|
||||
// fix the imports that each model has, change them to absolute
|
||||
// imports
|
||||
// clear out imports so we will only include full path imports
|
||||
cm.imports.clear();
|
||||
// make sure discrimonator models are included in imports
|
||||
CodegenDiscriminator discriminator = cm.discriminator;
|
||||
if (discriminator != null) {
|
||||
Set<CodegenDiscriminator.MappedModel> mappedModels = discriminator.getMappedModels();
|
||||
for (CodegenDiscriminator.MappedModel mappedModel : mappedModels) {
|
||||
String otherModelName = mappedModel.getModelName();
|
||||
addModelImport(objs, cm, otherModelName);
|
||||
cm.imports.add(otherModelName);
|
||||
}
|
||||
}
|
||||
ArrayList<List<CodegenProperty>> listOfLists= new ArrayList<List<CodegenProperty>>();
|
||||
listOfLists.add(cm.allVars);
|
||||
listOfLists.add(cm.requiredVars);
|
||||
listOfLists.add(cm.optionalVars);
|
||||
listOfLists.add(cm.vars);
|
||||
for (List<CodegenProperty> varList : listOfLists) {
|
||||
for (CodegenProperty cp : varList) {
|
||||
String otherModelName = null;
|
||||
if (cp.complexType != null) {
|
||||
otherModelName = cp.complexType;
|
||||
}
|
||||
if (cp.mostInnerItems != null) {
|
||||
if (cp.mostInnerItems.complexType != null) {
|
||||
otherModelName = cp.mostInnerItems.complexType;
|
||||
}
|
||||
}
|
||||
if (otherModelName != null) {
|
||||
addModelImport(objs, cm, otherModelName);
|
||||
}
|
||||
}
|
||||
|
||||
// add imports for anyOf, allOf, oneOf
|
||||
ArrayList<Set<String>> composedSchemaSets = new ArrayList<Set<String>>();
|
||||
composedSchemaSets.add(cm.allOf);
|
||||
composedSchemaSets.add(cm.anyOf);
|
||||
composedSchemaSets.add(cm.oneOf);
|
||||
for (Set<String> importSet : composedSchemaSets) {
|
||||
for (String otherModelName : importSet) {
|
||||
cm.imports.add(otherModelName);
|
||||
}
|
||||
}
|
||||
|
||||
// fix the imports that each model has, change them to absolute
|
||||
fixModelImports(cm.imports);
|
||||
|
||||
Schema modelSchema = ModelUtils.getSchema(this.openAPI, cm.name);
|
||||
CodegenProperty modelProperty = fromProperty("value", modelSchema);
|
||||
if (cm.isEnum || cm.isAlias) {
|
||||
@@ -396,17 +470,20 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
CodegenProperty modelProp = fromProperty("body", realSchema);
|
||||
if (modelProp.isPrimitiveType && (modelProp.hasValidation || modelProp.isEnum)) {
|
||||
String simpleDataType = result.dataType;
|
||||
result.isPrimitiveType = false;
|
||||
result.isModel = true;
|
||||
result.dataType = modelName;
|
||||
imports.add(modelName);
|
||||
result.dataType = toModelName(modelName);
|
||||
result.baseType = getPythonClassName(result.dataType);
|
||||
imports.remove(modelName);
|
||||
imports.add(result.dataType);
|
||||
// set the example value
|
||||
if (modelProp.isEnum) {
|
||||
String value = modelProp._enum.get(0).toString();
|
||||
result.example = modelName + "(" + toEnumValue(value, simpleDataType) + ")";
|
||||
result.example = this.packageName + "." + result.baseType + "(" + toEnumValue(value, simpleDataType) + ")";
|
||||
} else {
|
||||
result.example = modelName + "(" + result.example + ")";
|
||||
result.example = this.packageName + "." + result.baseType + "(" + result.example + ")";
|
||||
}
|
||||
} else if (!result.isPrimitiveType) {
|
||||
// fix the baseType for the api docs so the .md link to the class's documentation file is correct
|
||||
result.baseType = getPythonClassName(result.baseType);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -421,7 +498,7 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
@Override
|
||||
public CodegenResponse fromResponse(String responseCode, ApiResponse response) {
|
||||
// if a response points at a model whose type != object and it has validations and/or enums, then we will
|
||||
// generate the model, and the response.isModel must be changed to true and response.baseType must be the name
|
||||
// generate the model, and response.baseType must be the name
|
||||
// of the model. Point responses at models if the model is python class type ModelSimple
|
||||
// When we serialize/deserialize ModelSimple models, validations and enums will be checked.
|
||||
Schema responseSchema;
|
||||
@@ -435,13 +512,13 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
if (responseSchema != null) {
|
||||
CodegenProperty cp = fromProperty("response", responseSchema);
|
||||
if (cp.complexType != null) {
|
||||
// check the referenced schema to see if it is an type=object model
|
||||
Schema modelSchema = ModelUtils.getSchema(this.openAPI, cp.complexType);
|
||||
String modelName = getPythonClassName(cp.complexType);
|
||||
Schema modelSchema = ModelUtils.getSchema(this.openAPI, modelName);
|
||||
if (modelSchema != null && !"object".equals(modelSchema.getType())) {
|
||||
CodegenProperty modelProp = fromProperty("response", modelSchema);
|
||||
if (modelProp.isEnum == true || modelProp.hasValidation == true) {
|
||||
// this model has validations and/or enums so we will generate it
|
||||
newBaseType = cp.complexType;
|
||||
newBaseType = modelName;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -455,9 +532,12 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
|
||||
CodegenResponse result = super.fromResponse(responseCode, response);
|
||||
if (newBaseType != null) {
|
||||
result.isModel = true;
|
||||
result.baseType = newBaseType;
|
||||
result.dataType = newBaseType;
|
||||
result.dataType = toModelName(newBaseType);
|
||||
// baseType is used to set the link to the model .md documentation
|
||||
result.baseType = getPythonClassName(newBaseType);
|
||||
} else if (!result.primitiveType) {
|
||||
// fix the baseType for the api docs so the .md link to the class's documentation file is correct
|
||||
result.baseType = getPythonClassName(result.baseType);
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -553,6 +633,31 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessModelProperty(CodegenModel model, CodegenProperty p) {
|
||||
postProcessPattern(p.pattern, p.vendorExtensions);
|
||||
// set property.complexType so the model docs will link to the ClassName.md
|
||||
if (p.complexType != null && !languageSpecificPrimitives.contains(p.complexType)) {
|
||||
p.complexType = getPythonClassName(p.complexType);
|
||||
} else if (p.isListContainer && p.mostInnerItems.complexType != null && !languageSpecificPrimitives.contains(p.mostInnerItems.complexType)) {
|
||||
// fix ListContainers
|
||||
p.complexType = getPythonClassName(p.mostInnerItems.complexType);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessParameter(CodegenParameter p) {
|
||||
postProcessPattern(p.pattern, p.vendorExtensions);
|
||||
// set baseType to null so the api docs will not point to a model for languageSpecificPrimitives
|
||||
if (p.baseType != null && languageSpecificPrimitives.contains(p.baseType)){
|
||||
p.baseType = null;
|
||||
} else if (p.isListContainer && p.mostInnerItems.complexType != null && !languageSpecificPrimitives.contains(p.mostInnerItems.complexType)) {
|
||||
// fix ListContainers
|
||||
p.baseType = getPythonClassName(p.mostInnerItems.complexType);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert OAS Model object to Codegen Model object
|
||||
*
|
||||
@@ -588,10 +693,15 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
continue;
|
||||
}
|
||||
String modelName = ModelUtils.getSimpleRef(ref);
|
||||
propertyToModelName.put(pythonPropertyName, modelName);
|
||||
propertyToModelName.put(pythonPropertyName, toModelName(modelName));
|
||||
}
|
||||
}
|
||||
CodegenModel result = super.fromModel(name, schema);
|
||||
// use this to store the model name like Cat
|
||||
// we can't use result.name because that is used to lookup models in the spec
|
||||
// we can't use result.classname because that stores cat.Cat
|
||||
// we can't use result.classVarName because that stores the variable for making example instances
|
||||
result.unescapedDescription = simpleModelName(name);
|
||||
|
||||
// make non-object type models have one property so we can use it to store enums and validations
|
||||
if (result.isAlias || result.isEnum) {
|
||||
@@ -636,10 +746,11 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
}
|
||||
cp.isPrimitiveType = false;
|
||||
String modelName = propertyToModelName.get(cp.name);
|
||||
cp.complexType = modelName;
|
||||
cp.complexType = getPythonClassName(modelName);
|
||||
cp.dataType = modelName;
|
||||
cp.isEnum = false;
|
||||
cp.hasValidation = false;
|
||||
result.imports.add(modelName);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -671,7 +782,7 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
if (ModelUtils.isFreeFormObject(p) && ModelUtils.getAdditionalProperties(p) == null) {
|
||||
return prefix + "bool, date, datetime, dict, float, int, list, str" + fullSuffix;
|
||||
}
|
||||
if (ModelUtils.isMapSchema(p)) {
|
||||
if ((ModelUtils.isMapSchema(p) || p.getType() == "object") && ModelUtils.getAdditionalProperties(p) != null) {
|
||||
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||
return prefix + "{str: " + getTypeString(inner, "(", ")") + "}" + fullSuffix;
|
||||
} else if (ModelUtils.isArraySchema(p)) {
|
||||
@@ -679,10 +790,10 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
Schema inner = ap.getItems();
|
||||
return prefix + "[" + getTypeString(inner, "", "") + "]" + fullSuffix;
|
||||
}
|
||||
String baseType = getSimpleTypeDeclaration(p);
|
||||
if (ModelUtils.isFileSchema(p)) {
|
||||
baseType = "file_type";
|
||||
return prefix + "file_type" + fullSuffix;
|
||||
}
|
||||
String baseType = getSimpleTypeDeclaration(p);
|
||||
return prefix + baseType + fullSuffix;
|
||||
}
|
||||
|
||||
@@ -772,8 +883,8 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
}
|
||||
example = "'" + escapeText(example) + "'";
|
||||
} else if (!languageSpecificPrimitives.contains(type)) {
|
||||
// type is a model class, e.g. User
|
||||
example = this.packageName + "." + type + "()";
|
||||
// type is a model class, e.g. user.User
|
||||
example = this.packageName + "." + getPythonClassName(type) + "()";
|
||||
} else {
|
||||
LOGGER.warn("Type " + type + " not handled properly in setParameterExampleValue");
|
||||
}
|
||||
@@ -788,4 +899,55 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
|
||||
p.example = example;
|
||||
}
|
||||
|
||||
private String simpleModelName(String name) {
|
||||
// this returns a model name like Cat
|
||||
String modelName = sanitizeName(name);
|
||||
// remove dollar sign
|
||||
modelName = modelName.replaceAll("$", "");
|
||||
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(modelName)) {
|
||||
LOGGER.warn(modelName + " (reserved word) cannot be used as model name. Renamed to " + camelize("model_" + modelName));
|
||||
modelName = "model_" + modelName; // e.g. return => ModelReturn (after camelize)
|
||||
}
|
||||
|
||||
// model name starts with number
|
||||
if (modelName.matches("^\\d.*")) {
|
||||
LOGGER.warn(modelName + " (model name starts with number) cannot be used as model name. Renamed to " + camelize("model_" + modelName));
|
||||
modelName = "model_" + modelName; // e.g. 200Response => Model200Response (after camelize)
|
||||
}
|
||||
|
||||
if (!StringUtils.isEmpty(modelNamePrefix)) {
|
||||
modelName = modelNamePrefix + "_" + modelName;
|
||||
}
|
||||
|
||||
if (!StringUtils.isEmpty(modelNameSuffix)) {
|
||||
modelName = modelName + "_" + modelNameSuffix;
|
||||
}
|
||||
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
return camelize(modelName);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toModelFilename(String name) {
|
||||
// underscore the model file name
|
||||
// PhoneNumber => phone_number
|
||||
return underscore(dropDots(simpleModelName(name)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelName(String name) {
|
||||
// we have a custom version of this function so we can support circular references in python 2 and 3
|
||||
return toModelFilename(name)+"."+simpleModelName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelDocFilename(String name) {
|
||||
// this is used to generate the model's .md documentation file
|
||||
return simpleModelName(name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ pip install git+https://{{gitHost}}/{{{gitUserId}}}/{{{gitRepoId}}}.git
|
||||
|
||||
Then import the package:
|
||||
```python
|
||||
import {{{packageName}}}
|
||||
import {{{packageName}}}
|
||||
```
|
||||
|
||||
### Setuptools
|
||||
|
||||
55
modules/openapi-generator/src/main/resources/python/python-experimental/README.mustache
vendored
Normal file
55
modules/openapi-generator/src/main/resources/python/python-experimental/README.mustache
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
# {{{projectName}}}
|
||||
{{#appDescription}}
|
||||
{{{appDescription}}}
|
||||
{{/appDescription}}
|
||||
|
||||
This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
|
||||
|
||||
- API version: {{appVersion}}
|
||||
- Package version: {{packageVersion}}
|
||||
{{^hideGenerationTimestamp}}
|
||||
- Build date: {{generatedDate}}
|
||||
{{/hideGenerationTimestamp}}
|
||||
- Build package: {{generatorClass}}
|
||||
{{#infoUrl}}
|
||||
For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
|
||||
{{/infoUrl}}
|
||||
|
||||
## Requirements.
|
||||
|
||||
Python 2.7 and 3.4+
|
||||
|
||||
## Installation & Usage
|
||||
### pip install
|
||||
|
||||
If the python package is hosted on a repository, you can install directly using:
|
||||
|
||||
```sh
|
||||
pip install git+https://{{gitHost}}/{{{gitUserId}}}/{{{gitRepoId}}}.git
|
||||
```
|
||||
(you may need to run `pip` with root permission: `sudo pip install git+https://{{gitHost}}/{{{gitUserId}}}/{{{gitRepoId}}}.git`)
|
||||
|
||||
Then import the package:
|
||||
```python
|
||||
import {{{packageName}}}
|
||||
```
|
||||
|
||||
### Setuptools
|
||||
|
||||
Install via [Setuptools](http://pypi.python.org/pypi/setuptools).
|
||||
|
||||
```sh
|
||||
python setup.py install --user
|
||||
```
|
||||
(or `sudo python setup.py install` to install the package for all users)
|
||||
|
||||
Then import the package:
|
||||
```python
|
||||
import {{{packageName}}}
|
||||
```
|
||||
|
||||
## Getting Started
|
||||
|
||||
Please follow the [installation procedure](#installation--usage) and then run the following:
|
||||
|
||||
{{> python-experimental/README_common }}
|
||||
74
modules/openapi-generator/src/main/resources/python/python-experimental/README_common.mustache
vendored
Normal file
74
modules/openapi-generator/src/main/resources/python/python-experimental/README_common.mustache
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
```python
|
||||
from __future__ import print_function
|
||||
import time
|
||||
import {{{packageName}}}
|
||||
from pprint import pprint
|
||||
{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}}
|
||||
{{> python_doc_auth_partial}}
|
||||
# Defining host is optional and default to {{{basePath}}}
|
||||
configuration.host = "{{{basePath}}}"
|
||||
# Create an instance of the API class
|
||||
api_instance = {{{packageName}}}.{{{classname}}}({{{packageName}}}.ApiClient(configuration))
|
||||
{{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
|
||||
{{/allParams}}
|
||||
|
||||
try:
|
||||
{{#summary}} # {{{.}}}
|
||||
{{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{#returnType}}
|
||||
pprint(api_response){{/returnType}}
|
||||
except {{{packageName}}}.ApiException as e:
|
||||
print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e)
|
||||
{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}}
|
||||
```
|
||||
|
||||
## Documentation for API Endpoints
|
||||
|
||||
All URIs are relative to *{{basePath}}*
|
||||
|
||||
Class | Method | HTTP request | Description
|
||||
------------ | ------------- | ------------- | -------------
|
||||
{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}}
|
||||
{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
|
||||
|
||||
## Documentation For Models
|
||||
|
||||
{{#models}}{{#model}} - [{{{classname}}}]({{modelDocPath}}{{{unescapedDescription}}}.md)
|
||||
{{/model}}{{/models}}
|
||||
|
||||
## Documentation For Authorization
|
||||
|
||||
{{^authMethods}}
|
||||
All endpoints do not require authorization.
|
||||
{{/authMethods}}
|
||||
{{#authMethods}}
|
||||
{{#last}} Authentication schemes defined for the API:{{/last}}
|
||||
## {{{name}}}
|
||||
|
||||
{{#isApiKey}}
|
||||
- **Type**: API key
|
||||
- **API key parameter name**: {{{keyParamName}}}
|
||||
- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}}
|
||||
{{/isApiKey}}
|
||||
{{#isBasic}}
|
||||
{{^isBasicBearer}}
|
||||
- **Type**: HTTP basic authentication
|
||||
{{/isBasicBearer}}
|
||||
{{#isBasicBearer}}
|
||||
- **Type**: Bearer authentication{{#bearerFormat}} ({{{.}}}){{/bearerFormat}}
|
||||
{{/isBasicBearer}}
|
||||
{{/isBasic}}
|
||||
{{#isOAuth}}
|
||||
- **Type**: OAuth
|
||||
- **Flow**: {{{flow}}}
|
||||
- **Authorization URL**: {{{authorizationUrl}}}
|
||||
- **Scopes**: {{^scopes}}N/A{{/scopes}}
|
||||
{{#scopes}} - **{{{scope}}}**: {{{description}}}
|
||||
{{/scopes}}
|
||||
{{/isOAuth}}
|
||||
|
||||
{{/authMethods}}
|
||||
|
||||
## Author
|
||||
|
||||
{{#apiInfo}}{{#apis}}{{^hasMore}}{{infoEmail}}
|
||||
{{/hasMore}}{{/apis}}{{/apiInfo}}
|
||||
@@ -0,0 +1,44 @@
|
||||
# {{{projectName}}}
|
||||
{{#appDescription}}
|
||||
{{{appDescription}}}
|
||||
{{/appDescription}}
|
||||
|
||||
The `{{packageName}}` package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
|
||||
|
||||
- API version: {{appVersion}}
|
||||
- Package version: {{packageVersion}}
|
||||
{{^hideGenerationTimestamp}}
|
||||
- Build date: {{generatedDate}}
|
||||
{{/hideGenerationTimestamp}}
|
||||
- Build package: {{generatorClass}}
|
||||
{{#infoUrl}}
|
||||
For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
|
||||
{{/infoUrl}}
|
||||
|
||||
## Requirements.
|
||||
|
||||
Python 2.7 and 3.4+
|
||||
|
||||
## Installation & Usage
|
||||
|
||||
This python library package is generated without supporting files like setup.py or requirements files
|
||||
|
||||
To be able to use it, you will need these dependencies in your own package that uses this library:
|
||||
|
||||
* urllib3 >= 1.15
|
||||
* six >= 1.10
|
||||
* certifi
|
||||
* python-dateutil
|
||||
{{#asyncio}}
|
||||
* aiohttp
|
||||
{{/asyncio}}
|
||||
{{#tornado}}
|
||||
* tornado>=4.2,<5
|
||||
{{/tornado}}
|
||||
|
||||
## Getting Started
|
||||
|
||||
In your own code, to use this library to connect and interact with {{{projectName}}},
|
||||
you can run the following:
|
||||
|
||||
{{> python-experimental/README_common }}
|
||||
@@ -0,0 +1,7 @@
|
||||
# coding: utf-8
|
||||
|
||||
# flake8: noqa
|
||||
{{>partial_header}}
|
||||
|
||||
# we can not import model classes here because that would create a circular
|
||||
# reference which would not work in python2
|
||||
36
modules/openapi-generator/src/main/resources/python/python-experimental/__init__package.mustache
vendored
Normal file
36
modules/openapi-generator/src/main/resources/python/python-experimental/__init__package.mustache
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
# coding: utf-8
|
||||
|
||||
# flake8: noqa
|
||||
|
||||
{{>partial_header}}
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
__version__ = "{{packageVersion}}"
|
||||
|
||||
# import apis into sdk package
|
||||
{{#apiInfo}}
|
||||
{{#apis}}
|
||||
from {{apiPackage}}.{{classVarName}} import {{classname}}
|
||||
{{/apis}}
|
||||
{{/apiInfo}}
|
||||
|
||||
# import ApiClient
|
||||
from {{packageName}}.api_client import ApiClient
|
||||
|
||||
# import Configuration
|
||||
from {{packageName}}.configuration import Configuration
|
||||
|
||||
# import exceptions
|
||||
from {{packageName}}.exceptions import OpenApiException
|
||||
from {{packageName}}.exceptions import ApiTypeError
|
||||
from {{packageName}}.exceptions import ApiValueError
|
||||
from {{packageName}}.exceptions import ApiKeyError
|
||||
from {{packageName}}.exceptions import ApiException
|
||||
|
||||
# import models into sdk package
|
||||
{{#models}}
|
||||
{{#model}}
|
||||
from {{modelPackage}}.{{classFilename}} import {{unescapedDescription}}
|
||||
{{/model}}
|
||||
{{/models}}
|
||||
@@ -5,6 +5,7 @@
|
||||
from __future__ import absolute_import
|
||||
|
||||
import re # noqa: F401
|
||||
import sys # noqa: F401
|
||||
|
||||
# python 2 and python 3 compatibility library
|
||||
import six
|
||||
|
||||
@@ -35,19 +35,16 @@ Method | HTTP request | Description
|
||||
{{#isOAuth}}
|
||||
* OAuth Authentication ({{name}}):
|
||||
{{/isOAuth }}
|
||||
{{> api_doc_example }}
|
||||
{{/authMethods}}
|
||||
{{/hasAuthMethods}}
|
||||
{{^hasAuthMethods}}
|
||||
{{> api_doc_example }}
|
||||
{{/hasAuthMethods}}
|
||||
{{> python-experimental/api_doc_example }}
|
||||
### Parameters
|
||||
{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}}
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}}
|
||||
{{#requiredParams}}{{^defaultValue}} **{{paramName}}** | {{#isFile}}**{{dataType}}**{{/isFile}}{{^isFile}}{{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{baseType}}.md){{/isPrimitiveType}}{{/isFile}}| {{description}} |
|
||||
{{/defaultValue}}{{/requiredParams}}{{#requiredParams}}{{#defaultValue}} **{{paramName}}** | {{#isFile}}**{{dataType}}**{{/isFile}}{{^isFile}}{{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{baseType}}.md){{/isPrimitiveType}}{{/isFile}}| {{description}} | defaults to {{{.}}}
|
||||
{{/defaultValue}}{{/requiredParams}}{{#optionalParams}} **{{paramName}}** | {{#isFile}}**{{dataType}}**{{/isFile}}{{^isFile}}{{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{baseType}}.md){{/isPrimitiveType}}{{/isFile}}| {{description}} | [optional]{{#defaultValue}} if omitted the server will use the default value of {{{.}}}{{/defaultValue}}
|
||||
{{#requiredParams}}{{^defaultValue}} **{{paramName}}** | {{^baseType}}**{{dataType}}**{{/baseType}}{{#baseType}}[**{{dataType}}**]({{baseType}}.md){{/baseType}}| {{description}} |
|
||||
{{/defaultValue}}{{/requiredParams}}{{#requiredParams}}{{#defaultValue}} **{{paramName}}** | {{^baseType}}**{{dataType}}**{{/baseType}}{{#baseType}}[**{{dataType}}**]({{baseType}}.md){{/baseType}}| {{description}} | defaults to {{{.}}}
|
||||
{{/defaultValue}}{{/requiredParams}}{{#optionalParams}} **{{paramName}}** | {{^baseType}}**{{dataType}}**{{/baseType}}{{#baseType}}[**{{dataType}}**]({{baseType}}.md){{/baseType}}| {{description}} | [optional]{{#defaultValue}} if omitted the server will use the default value of {{{.}}}{{/defaultValue}}
|
||||
{{/optionalParams}}
|
||||
|
||||
### Return type
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
from __future__ import print_function
|
||||
import time
|
||||
import {{{packageName}}}
|
||||
from {{{packageName}}}.rest import ApiException
|
||||
from pprint import pprint
|
||||
{{> python_doc_auth_partial}}
|
||||
{{#hasAuthMethods}}
|
||||
@@ -18,40 +17,40 @@ api_instance = {{{packageName}}}.{{{classname}}}()
|
||||
{{#requiredParams}}{{^defaultValue}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}
|
||||
{{/defaultValue}}{{/requiredParams}}{{#optionalParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}}
|
||||
{{/optionalParams}}
|
||||
|
||||
{{#requiredParams}}
|
||||
{{^hasMore}}
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
try:
|
||||
{{#summary}} # {{{.}}}
|
||||
{{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#requiredParams}}{{^defaultValue}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/defaultValue}}{{/requiredParams}}){{#returnType}}
|
||||
pprint(api_response){{/returnType}}
|
||||
except ApiException as e:
|
||||
except {{{packageName}}}.ApiException as e:
|
||||
print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e)
|
||||
{{/hasMore}}
|
||||
{{/requiredParams}}
|
||||
|
||||
{{#optionalParams}}
|
||||
{{^hasMore}}
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
# and optional values
|
||||
try:
|
||||
{{#summary}} # {{{.}}}
|
||||
{{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#requiredParams}}{{^defaultValue}}{{paramName}}, {{/defaultValue}}{{/requiredParams}}{{#optionalParams}}{{paramName}}={{paramName}}{{#hasMore}}, {{/hasMore}}{{/optionalParams}}){{#returnType}}
|
||||
pprint(api_response){{/returnType}}
|
||||
except ApiException as e:
|
||||
except {{{packageName}}}.ApiException as e:
|
||||
print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e)
|
||||
{{/hasMore}}
|
||||
{{/optionalParams}}
|
||||
|
||||
{{^requiredParams}}
|
||||
{{^optionalParams}}
|
||||
|
||||
# example, this endpoint has no required or optional parameters
|
||||
try:
|
||||
{{#summary}} # {{{.}}}
|
||||
{{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}(){{#returnType}}
|
||||
pprint(api_response){{/returnType}}
|
||||
except ApiException as e:
|
||||
except {{{packageName}}}.ApiException as e:
|
||||
print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e)
|
||||
{{/optionalParams}}
|
||||
{{/requiredParams}}
|
||||
|
||||
@@ -2,37 +2,31 @@
|
||||
|
||||
{{>partial_header}}
|
||||
|
||||
import pprint # noqa: F401
|
||||
from __future__ import absolute_import
|
||||
import re # noqa: F401
|
||||
import sys # noqa: F401
|
||||
|
||||
import six # noqa: F401
|
||||
|
||||
from {{packageName}}.exceptions import ( # noqa: F401
|
||||
ApiKeyError,
|
||||
ApiTypeError,
|
||||
ApiValueError,
|
||||
)
|
||||
from {{packageName}}.model_utils import ( # noqa: F401
|
||||
ModelComposed,
|
||||
ModelNormal,
|
||||
ModelSimple,
|
||||
check_allowed_values,
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
get_simple_class,
|
||||
int,
|
||||
model_to_dict,
|
||||
none_type,
|
||||
str,
|
||||
type_error_message,
|
||||
validate_and_convert_types
|
||||
validate_get_composed_info,
|
||||
)
|
||||
{{#models}}{{#model}}{{#imports}}{{.}}
|
||||
{{/imports}}{{/model}}{{/models}}
|
||||
|
||||
{{#models}}
|
||||
{{#model}}
|
||||
{{#imports}}
|
||||
{{{.}}}
|
||||
{{/imports}}
|
||||
|
||||
|
||||
{{^interfaces}}
|
||||
{{#isAlias}}
|
||||
{{> python-experimental/model_templates/model_simple }}
|
||||
@@ -43,7 +37,7 @@ from {{packageName}}.model_utils import ( # noqa: F401
|
||||
{{/interfaces}}
|
||||
{{#interfaces}}
|
||||
{{#-last}}
|
||||
{{> python-experimental/model_templates/model_normal }}
|
||||
{{> python-experimental/model_templates/model_composed }}
|
||||
{{/-last}}
|
||||
{{/interfaces}}
|
||||
{{/model}}
|
||||
|
||||
@@ -7,16 +7,16 @@ Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
{{#requiredVars}}
|
||||
{{^defaultValue}}
|
||||
**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{#isReadOnly}}[readonly] {{/isReadOnly}}
|
||||
**{{name}}** | {{^complexType}}**{{dataType}}**{{/complexType}}{{#complexType}}[**{{dataType}}**]({{complexType}}.md){{/complexType}} | {{description}} | {{#isReadOnly}}[readonly] {{/isReadOnly}}
|
||||
{{/defaultValue}}
|
||||
{{/requiredVars}}
|
||||
{{#requiredVars}}
|
||||
{{#defaultValue}}
|
||||
**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}}defaults to {{{.}}}{{/defaultValue}}
|
||||
**{{name}}** | {{^complexType}}**{{dataType}}**{{/complexType}}{{#complexType}}[**{{dataType}}**]({{complexType}}.md){{/complexType}} | {{description}} | {{^required}}[optional] {{/required}}{{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}}defaults to {{{.}}}{{/defaultValue}}
|
||||
{{/defaultValue}}
|
||||
{{/requiredVars}}
|
||||
{{#optionalVars}}
|
||||
**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | [optional] {{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}} if omitted the server will use the default value of {{{.}}}{{/defaultValue}}
|
||||
**{{name}}** | {{^complexType}}**{{dataType}}**{{/complexType}}{{#complexType}}[**{{dataType}}**]({{complexType}}.md){{/complexType}} | {{description}} | [optional] {{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}} if omitted the server will use the default value of {{{.}}}{{/defaultValue}}
|
||||
{{/optionalVars}}
|
||||
{{#additionalPropertiesType}}
|
||||
**any string name** | **{{additionalPropertiesType}}** | any string name can be used but the value must be the correct type | [optional]
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
allowed_values = {
|
||||
{{#allVars}}
|
||||
{{#isEnum}}
|
||||
('{{name}}',): {
|
||||
{{#isNullable}}
|
||||
'None': None,
|
||||
{{/isNullable}}
|
||||
{{#allowableValues}}
|
||||
{{#enumVars}}
|
||||
'{{name}}': {{{value}}},
|
||||
{{/enumVars}}
|
||||
{{/allowableValues}}
|
||||
},
|
||||
{{/isEnum}}
|
||||
{{/allVars}}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
openapi_types = {
|
||||
{{#allVars}}
|
||||
'{{name}}': ({{{dataType}}},), # noqa: E501
|
||||
{{/allVars}}
|
||||
}
|
||||
|
||||
validations = {
|
||||
{{#allVars}}
|
||||
{{#hasValidation}}
|
||||
('{{name}}',): {
|
||||
{{#maxLength}}
|
||||
'max_length': {{maxLength}},
|
||||
{{/maxLength}}
|
||||
{{#minLength}}
|
||||
'min_length': {{minLength}},
|
||||
{{/minLength}}
|
||||
{{#maxItems}}
|
||||
'max_items': {{maxItems}},
|
||||
{{/maxItems}}
|
||||
{{#minItems}}
|
||||
'min_items': {{minItems}},
|
||||
{{/minItems}}
|
||||
{{#maximum}}
|
||||
{{#exclusiveMaximum}}'exclusive_maximum'{{/exclusiveMaximum}}'inclusive_maximum'{{^exclusiveMaximum}}{{/exclusiveMaximum}}: {{maximum}},
|
||||
{{/maximum}}
|
||||
{{#minimum}}
|
||||
{{#exclusiveMinimum}}'exclusive_minimum'{{/exclusiveMinimum}}'inclusive_minimum'{{^exclusiveMinimum}}{{/exclusiveMinimum}}: {{minimum}},
|
||||
{{/minimum}}
|
||||
{{#pattern}}
|
||||
'regex': {
|
||||
'pattern': r'{{{vendorExtensions.x-regex}}}', # noqa: E501{{#vendorExtensions.x-modifiers}}
|
||||
{{#-first}}'flags': (re.{{.}}{{/-first}}{{^-first}} re.{{.}}{{/-first}}{{^-last}} | {{/-last}}{{#-last}}){{/-last}}{{/vendorExtensions.x-modifiers}}
|
||||
},
|
||||
{{/pattern}}
|
||||
},
|
||||
{{/hasValidation}}
|
||||
{{/allVars}}
|
||||
}
|
||||
|
||||
additional_properties_type = {{#additionalPropertiesType}}({{{additionalPropertiesType}}},) # noqa: E501{{/additionalPropertiesType}}{{^additionalPropertiesType}}None{{/additionalPropertiesType}}
|
||||
|
||||
discriminator = {{#discriminator}}'{{{discriminatorName}}}'{{/discriminator}}{{^discriminator}}None{{/discriminator}}
|
||||
@@ -0,0 +1,119 @@
|
||||
allowed_values = {
|
||||
{{#requiredVars}}
|
||||
{{#isEnum}}
|
||||
('{{name}}',): {
|
||||
{{#isNullable}}
|
||||
'None': None,
|
||||
{{/isNullable}}
|
||||
{{#allowableValues}}
|
||||
{{#enumVars}}
|
||||
'{{name}}': {{{value}}},
|
||||
{{/enumVars}}
|
||||
{{/allowableValues}}
|
||||
},
|
||||
{{/isEnum}}
|
||||
{{/requiredVars}}
|
||||
{{#optionalVars}}
|
||||
{{#isEnum}}
|
||||
('{{name}}',): {
|
||||
{{#isNullable}}
|
||||
'None': None,
|
||||
{{/isNullable}}
|
||||
{{#allowableValues}}
|
||||
{{#enumVars}}
|
||||
'{{name}}': {{{value}}},
|
||||
{{/enumVars}}
|
||||
{{/allowableValues}}
|
||||
},
|
||||
{{/isEnum}}
|
||||
{{/optionalVars}}
|
||||
}
|
||||
|
||||
openapi_types = {
|
||||
{{#requiredVars}}
|
||||
'{{name}}': ({{{dataType}}},), # noqa: E501
|
||||
{{/requiredVars}}
|
||||
{{#optionalVars}}
|
||||
'{{name}}': ({{{dataType}}},), # noqa: E501
|
||||
{{/optionalVars}}
|
||||
}
|
||||
|
||||
validations = {
|
||||
{{#requiredVars}}
|
||||
{{#hasValidation}}
|
||||
('{{name}}',): {
|
||||
{{#maxLength}}
|
||||
'max_length': {{maxLength}},
|
||||
{{/maxLength}}
|
||||
{{#minLength}}
|
||||
'min_length': {{minLength}},
|
||||
{{/minLength}}
|
||||
{{#maxItems}}
|
||||
'max_items': {{maxItems}},
|
||||
{{/maxItems}}
|
||||
{{#minItems}}
|
||||
'min_items': {{minItems}},
|
||||
{{/minItems}}
|
||||
{{#maximum}}
|
||||
{{#exclusiveMaximum}}'exclusive_maximum'{{/exclusiveMaximum}}'inclusive_maximum'{{^exclusiveMaximum}}{{/exclusiveMaximum}}: {{maximum}},
|
||||
{{/maximum}}
|
||||
{{#minimum}}
|
||||
{{#exclusiveMinimum}}'exclusive_minimum'{{/exclusiveMinimum}}'inclusive_minimum'{{^exclusiveMinimum}}{{/exclusiveMinimum}}: {{minimum}},
|
||||
{{/minimum}}
|
||||
{{#pattern}}
|
||||
'regex': {
|
||||
'pattern': r'{{{vendorExtensions.x-regex}}}', # noqa: E501{{#vendorExtensions.x-modifiers}}
|
||||
{{#-first}}'flags': (re.{{.}}{{/-first}}{{^-first}} re.{{.}}{{/-first}}{{^-last}} | {{/-last}}{{#-last}}){{/-last}}{{/vendorExtensions.x-modifiers}}
|
||||
},
|
||||
{{/pattern}}
|
||||
},
|
||||
{{/hasValidation}}
|
||||
{{/requiredVars}}
|
||||
{{#optionalVars}}
|
||||
{{#hasValidation}}
|
||||
('{{name}}',): {
|
||||
{{#maxLength}}
|
||||
'max_length': {{maxLength}},
|
||||
{{/maxLength}}
|
||||
{{#minLength}}
|
||||
'min_length': {{minLength}},
|
||||
{{/minLength}}
|
||||
{{#maxItems}}
|
||||
'max_items': {{maxItems}},
|
||||
{{/maxItems}}
|
||||
{{#minItems}}
|
||||
'min_items': {{minItems}},
|
||||
{{/minItems}}
|
||||
{{#maximum}}
|
||||
{{#exclusiveMaximum}}'exclusive_maximum'{{/exclusiveMaximum}}'inclusive_maximum'{{^exclusiveMaximum}}{{/exclusiveMaximum}}: {{maximum}},
|
||||
{{/maximum}}
|
||||
{{#minimum}}
|
||||
{{#exclusiveMinimum}}'exclusive_minimum'{{/exclusiveMinimum}}'inclusive_minimum'{{^exclusiveMinimum}}{{/exclusiveMinimum}}: {{minimum}},
|
||||
{{/minimum}}
|
||||
{{#pattern}}
|
||||
'regex': {
|
||||
'pattern': r'{{{vendorExtensions.x-regex}}}', # noqa: E501{{#vendorExtensions.x-modifiers}}
|
||||
{{#-first}}'flags': (re.{{.}}{{/-first}}{{^-first}} re.{{.}}{{/-first}}{{^-last}} | {{/-last}}{{#-last}}){{/-last}}{{/vendorExtensions.x-modifiers}}
|
||||
},
|
||||
{{/pattern}}
|
||||
},
|
||||
{{/hasValidation}}
|
||||
{{/optionalVars}}
|
||||
}
|
||||
|
||||
additional_properties_type = {{#additionalPropertiesType}}({{{additionalPropertiesType}}},) # noqa: E501{{/additionalPropertiesType}}{{^additionalPropertiesType}}None{{/additionalPropertiesType}}
|
||||
|
||||
@staticmethod
|
||||
def discriminator():
|
||||
return {{^discriminator}}None{{/discriminator}}{{#discriminator}}{
|
||||
'{{{discriminatorName}}}': {
|
||||
{{#children}}
|
||||
'{{^vendorExtensions.x-discriminator-value}}{{name}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}': {{{classname}}},
|
||||
{{/children}}
|
||||
{{^children}}
|
||||
{{#mappedModels}}
|
||||
'{{mappingName}}': {{{modelName}}},
|
||||
{{/mappedModels}}
|
||||
{{/children}}
|
||||
},
|
||||
}{{/discriminator}}
|
||||
@@ -0,0 +1,12 @@
|
||||
@classmethod
|
||||
def get_discriminator_class(cls, from_server, data):
|
||||
"""Returns the child class specified by the discriminator"""
|
||||
discriminator = cls.discriminator()
|
||||
discr_propertyname_py = list(discriminator.keys())[0]
|
||||
discr_propertyname_js = cls.attribute_map[discr_propertyname_py]
|
||||
if from_server:
|
||||
class_name = data[discr_propertyname_js]
|
||||
else:
|
||||
class_name = data[discr_propertyname_py]
|
||||
class_name_to_discr_class = discriminator[discr_propertyname_py]
|
||||
return class_name_to_discr_class.get(class_name)
|
||||
@@ -0,0 +1,42 @@
|
||||
required_properties = set([
|
||||
'_data_store',
|
||||
'_check_type',
|
||||
'_from_server',
|
||||
'_path_to_item',
|
||||
'_configuration',
|
||||
'_composed_instances',
|
||||
'_var_name_to_model_instances',
|
||||
'_additional_properties_model_instances',
|
||||
])
|
||||
|
||||
{{> python-experimental/model_templates/method_init_shared }}
|
||||
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
constant_args = {
|
||||
'_check_type': _check_type,
|
||||
'_path_to_item': _path_to_item,
|
||||
'_from_server': _from_server,
|
||||
'_configuration': _configuration,
|
||||
}
|
||||
model_args = {
|
||||
{{#requiredVars}}
|
||||
'{{name}}': {{name}},
|
||||
{{/requiredVars}}
|
||||
}
|
||||
model_args.update(kwargs)
|
||||
composed_info = validate_get_composed_info(
|
||||
constant_args, model_args, self)
|
||||
self._composed_instances = composed_info[0]
|
||||
self._var_name_to_model_instances = composed_info[1]
|
||||
self._additional_properties_model_instances = composed_info[2]
|
||||
|
||||
{{#requiredVars}}
|
||||
self.{{name}} = {{name}}
|
||||
{{/requiredVars}}
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
setattr(self, var_name, var_value)
|
||||
@@ -0,0 +1,21 @@
|
||||
required_properties = set([
|
||||
'_data_store',
|
||||
'_check_type',
|
||||
'_from_server',
|
||||
'_path_to_item',
|
||||
'_configuration',
|
||||
])
|
||||
|
||||
{{> python-experimental/model_templates/method_init_shared }}
|
||||
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
{{#requiredVars}}
|
||||
self.{{name}} = {{name}}
|
||||
{{/requiredVars}}
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
setattr(self, var_name, var_value)
|
||||
@@ -0,0 +1,23 @@
|
||||
def __init__(self{{#requiredVars}}{{^defaultValue}}, {{name}}{{/defaultValue}}{{/requiredVars}}{{#requiredVars}}{{#defaultValue}}, {{name}}={{{defaultValue}}}{{/defaultValue}}{{/requiredVars}}, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501
|
||||
"""{{classname}} - a model defined in OpenAPI
|
||||
|
||||
{{#requiredVars}}{{^hasMore}} Args:{{/hasMore}}{{/requiredVars}}{{#requiredVars}}{{^defaultValue}}
|
||||
{{name}} ({{{dataType}}}):{{#description}} {{description}}{{/description}}{{/defaultValue}}{{/requiredVars}}{{#requiredVars}}{{^hasMore}}
|
||||
{{/hasMore}}{{/requiredVars}}
|
||||
Keyword Args:{{#requiredVars}}{{#defaultValue}}
|
||||
{{name}} ({{{dataType}}}):{{#description}} {{description}}.{{/description}} defaults to {{{defaultValue}}}, must be one of [{{{defaultValue}}}] # noqa: E501{{/defaultValue}}{{/requiredVars}}
|
||||
_check_type (bool): if True, values for parameters in openapi_types
|
||||
will be type checked and a TypeError will be
|
||||
raised if the wrong type is input.
|
||||
Defaults to True
|
||||
_path_to_item (tuple/list): This is a list of keys or values to
|
||||
drill down to the model in received_data
|
||||
when deserializing a response
|
||||
_from_server (bool): True if the data is from the server
|
||||
False if the data is from the client (default)
|
||||
_configuration (Configuration): the instance to use when
|
||||
deserializing a file_type parameter.
|
||||
If passed, type conversion is attempted
|
||||
If omitted no type conversion is done.{{#optionalVars}}
|
||||
{{name}} ({{{dataType}}}):{{#description}} {{description}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}} # noqa: E501{{/optionalVars}}
|
||||
"""
|
||||
@@ -0,0 +1,49 @@
|
||||
def set_attribute(self, name, value):
|
||||
# this is only used to set properties on self
|
||||
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
|
||||
if name in self.openapi_types:
|
||||
required_types_mixed = self.openapi_types[name]
|
||||
elif self.additional_properties_type is None:
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
path_to_item
|
||||
)
|
||||
elif self.additional_properties_type is not None:
|
||||
required_types_mixed = self.additional_properties_type
|
||||
|
||||
if get_simple_class(name) != str:
|
||||
error_msg = type_error_message(
|
||||
var_name=name,
|
||||
var_value=name,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
raise ApiTypeError(
|
||||
error_msg,
|
||||
path_to_item=path_to_item,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
|
||||
if self._check_type:
|
||||
value = validate_and_convert_types(
|
||||
value, required_types_mixed, path_to_item, self._from_server,
|
||||
self._check_type, configuration=self._configuration)
|
||||
if (name,) in self.allowed_values:
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
if (name,) in self.validations:
|
||||
check_validations(
|
||||
self.validations,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
self.__dict__['_data_store'][name] = value
|
||||
@@ -1,126 +0,0 @@
|
||||
def __init__(self{{#requiredVars}}{{^defaultValue}}, {{name}}{{/defaultValue}}{{/requiredVars}}{{#requiredVars}}{{#defaultValue}}, {{name}}={{{defaultValue}}}{{/defaultValue}}{{/requiredVars}}, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501
|
||||
"""{{classname}} - a model defined in OpenAPI
|
||||
|
||||
{{#requiredVars}}{{^hasMore}} Args:{{/hasMore}}{{/requiredVars}}{{#requiredVars}}{{^defaultValue}}
|
||||
{{name}} ({{{dataType}}}):{{#description}} {{description}}{{/description}}{{/defaultValue}}{{/requiredVars}}{{#requiredVars}}{{^hasMore}}
|
||||
{{/hasMore}}{{/requiredVars}}
|
||||
Keyword Args:{{#requiredVars}}{{#defaultValue}}
|
||||
{{name}} ({{{dataType}}}):{{#description}} {{description}}.{{/description}} defaults to {{{defaultValue}}}, must be one of [{{{defaultValue}}}] # noqa: E501{{/defaultValue}}{{/requiredVars}}
|
||||
_check_type (bool): if True, values for parameters in openapi_types
|
||||
will be type checked and a TypeError will be
|
||||
raised if the wrong type is input.
|
||||
Defaults to True
|
||||
_path_to_item (tuple/list): This is a list of keys or values to
|
||||
drill down to the model in received_data
|
||||
when deserializing a response
|
||||
_from_server (bool): True if the data is from the server
|
||||
False if the data is from the client (default)
|
||||
_configuration (Configuration): the instance to use when
|
||||
deserializing a file_type parameter.
|
||||
If passed, type conversion is attempted
|
||||
If omitted no type conversion is done.{{#optionalVars}}
|
||||
{{name}} ({{{dataType}}}):{{#description}} {{description}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}} # noqa: E501{{/optionalVars}}
|
||||
"""
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
{{#requiredVars}}
|
||||
self.__set_item('{{name}}', {{name}})
|
||||
{{/requiredVars}}
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
self.__set_item(var_name, var_value)
|
||||
|
||||
def __set_item(self, name, value):
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
|
||||
if name in self.openapi_types:
|
||||
required_types_mixed = self.openapi_types[name]
|
||||
elif self.additional_properties_type is None:
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
path_to_item
|
||||
)
|
||||
elif self.additional_properties_type is not None:
|
||||
required_types_mixed = self.additional_properties_type
|
||||
|
||||
if get_simple_class(name) != str:
|
||||
error_msg = type_error_message(
|
||||
var_name=name,
|
||||
var_value=name,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
raise ApiTypeError(
|
||||
error_msg,
|
||||
path_to_item=path_to_item,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
|
||||
if self._check_type:
|
||||
value = validate_and_convert_types(
|
||||
value, required_types_mixed, path_to_item, self._from_server,
|
||||
self._check_type, configuration=self._configuration)
|
||||
if (name,) in self.allowed_values:
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
if (name,) in self.validations:
|
||||
check_validations(
|
||||
self.validations,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
self._data_store[name] = value
|
||||
|
||||
def __get_item(self, name):
|
||||
if name in self._data_store:
|
||||
return self._data_store[name]
|
||||
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
[name]
|
||||
)
|
||||
|
||||
def __setitem__(self, name, value):
|
||||
"""this allows us to set values with instance[field_name] = val"""
|
||||
self.__set_item(name, value)
|
||||
|
||||
def __getitem__(self, name):
|
||||
"""this allows us to get a value with val = instance[field_name]"""
|
||||
return self.__get_item(name)
|
||||
{{#allVars}}
|
||||
|
||||
@property
|
||||
def {{name}}(self):
|
||||
"""Gets the {{name}} of this {{classname}}. # noqa: E501
|
||||
{{#description}}
|
||||
{{{description}}} # noqa: E501
|
||||
{{/description}}
|
||||
|
||||
Returns:
|
||||
({{{dataType}}}): The {{name}} of this {{classname}}. # noqa: E501
|
||||
"""
|
||||
return self.__get_item('{{name}}')
|
||||
|
||||
@{{name}}.setter
|
||||
def {{name}}(self, value):
|
||||
"""Sets the {{name}} of this {{classname}}. # noqa: E501
|
||||
{{#description}}
|
||||
{{{description}}} # noqa: E501
|
||||
{{/description}}
|
||||
"""
|
||||
return self.__set_item('{{name}}', value)
|
||||
{{/allVars}}
|
||||
@@ -0,0 +1,61 @@
|
||||
def __setattr__(self, name, value):
|
||||
"""this allows us to set a value with instance.field_name = val"""
|
||||
if name in self.required_properties:
|
||||
self.__dict__[name] = value
|
||||
return
|
||||
|
||||
# set the attribute on the correct instance
|
||||
model_instances = self._var_name_to_model_instances.get(
|
||||
name, self._additional_properties_model_instances)
|
||||
if model_instances:
|
||||
for model_instance in model_instances:
|
||||
if model_instance == self:
|
||||
self.set_attribute(name, value)
|
||||
else:
|
||||
setattr(model_instance, name, value)
|
||||
if name not in self._var_name_to_model_instances:
|
||||
# we assigned an additional property
|
||||
self.__dict__['_var_name_to_model_instances'][name] = (
|
||||
model_instance
|
||||
)
|
||||
return None
|
||||
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
path_to_item
|
||||
)
|
||||
|
||||
def __getattr__(self, name):
|
||||
"""this allows us to get a value with val = instance.field_name"""
|
||||
if name in self.required_properties:
|
||||
return self.__dict__[name]
|
||||
|
||||
# get the attribute from the correct instance
|
||||
model_instances = self._var_name_to_model_instances.get(
|
||||
name, self._additional_properties_model_instances)
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
if model_instances:
|
||||
values = set()
|
||||
for model_instance in model_instances:
|
||||
if name in model_instance._data_store:
|
||||
values.add(model_instance._data_store[name])
|
||||
if len(values) == 1:
|
||||
return list(values)[0]
|
||||
raise ApiValueError(
|
||||
"Values stored for property {0} in {1} difffer when looking "
|
||||
"at self and self's composed instances. All values must be "
|
||||
"the same".format(name, type(self).__name__),
|
||||
path_to_item
|
||||
)
|
||||
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
path_to_item
|
||||
)
|
||||
@@ -0,0 +1,24 @@
|
||||
def __setattr__(self, name, value):
|
||||
"""this allows us to set a value with instance.field_name = val"""
|
||||
if name in self.required_properties:
|
||||
self.__dict__[name] = value
|
||||
return
|
||||
|
||||
self.set_attribute(name, value)
|
||||
|
||||
def __getattr__(self, name):
|
||||
"""this allows us to get a value with val = instance.field_name"""
|
||||
if name in self.required_properties:
|
||||
return self.__dict__[name]
|
||||
|
||||
if name in self.__dict__['_data_store']:
|
||||
return self.__dict__['_data_store'][name]
|
||||
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
[name]
|
||||
)
|
||||
@@ -0,0 +1,15 @@
|
||||
def __setitem__(self, name, value):
|
||||
"""this allows us to set values with instance[field_name] = val"""
|
||||
self.__setattr__(name, value)
|
||||
|
||||
def __getitem__(self, name):
|
||||
"""this allows us to get a value with val = instance[field_name]"""
|
||||
return self.__getattr__(name)
|
||||
|
||||
def __repr__(self):
|
||||
"""For `print` and `pprint`"""
|
||||
return self.to_str()
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
return not self == other
|
||||
@@ -0,0 +1,29 @@
|
||||
def to_dict(self):
|
||||
"""Returns the model properties as a dict"""
|
||||
return model_to_dict(self, serialize=False)
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
return pprint.pformat(self.to_dict())
|
||||
|
||||
def __eq__(self, other):
|
||||
"""Returns true if both objects are equal"""
|
||||
if not isinstance(other, self.__class__):
|
||||
return False
|
||||
|
||||
if not set(self._data_store.keys()) == set(other._data_store.keys()):
|
||||
return False
|
||||
for _var_name, this_val in six.iteritems(self._data_store):
|
||||
that_val = other._data_store[_var_name]
|
||||
types = set()
|
||||
types.add(this_val.__class__)
|
||||
types.add(that_val.__class__)
|
||||
vals_equal = this_val == that_val
|
||||
if (not six.PY3 and
|
||||
len(types) == 2 and unicode in types): # noqa: F821
|
||||
vals_equal = (
|
||||
this_val.encode('utf-8') == that_val.encode('utf-8')
|
||||
)
|
||||
if not vals_equal:
|
||||
return False
|
||||
return True
|
||||
@@ -0,0 +1,22 @@
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
return str(self.value)
|
||||
|
||||
def __eq__(self, other):
|
||||
"""Returns true if both objects are equal"""
|
||||
if not isinstance(other, self.__class__):
|
||||
return False
|
||||
|
||||
this_val = self._data_store['value']
|
||||
that_val = other._data_store['value']
|
||||
types = set()
|
||||
types.add(this_val.__class__)
|
||||
types.add(that_val.__class__)
|
||||
vals_equal = this_val == that_val
|
||||
if not six.PY3 and len(types) == 2 and unicode in types: # noqa: F821
|
||||
vals_equal = (
|
||||
this_val.encode('utf-8') == that_val.encode('utf-8')
|
||||
)
|
||||
if not vals_equal:
|
||||
return False
|
||||
return True
|
||||
@@ -0,0 +1,56 @@
|
||||
class {{unescapedDescription}}(ModelComposed):
|
||||
"""NOTE: This class is auto generated by OpenAPI Generator.
|
||||
Ref: https://openapi-generator.tech
|
||||
|
||||
Do not edit the class manually.
|
||||
|
||||
Attributes:
|
||||
{{> python-experimental/model_templates/docstring_allowed }}
|
||||
attribute_map (dict): The key is attribute name
|
||||
and the value is json key in definition.
|
||||
discriminator_value_class_map (dict): A dict to go from the discriminator
|
||||
variable value to the discriminator class name.
|
||||
{{> python-experimental/model_templates/docstring_openapi_validations }}
|
||||
"""
|
||||
|
||||
{{> python-experimental/model_templates/classvars }}
|
||||
|
||||
attribute_map = {
|
||||
{{#requiredVars}}
|
||||
'{{name}}': '{{baseName}}', # noqa: E501
|
||||
{{/requiredVars}}
|
||||
{{#optionalVars}}
|
||||
'{{name}}': '{{baseName}}', # noqa: E501
|
||||
{{/optionalVars}}
|
||||
}
|
||||
|
||||
{{> python-experimental/model_templates/method_init_composed }}
|
||||
|
||||
@staticmethod
|
||||
def _composed_schemas():
|
||||
# we need this here to make our import statements work
|
||||
# we must store _composed_schemas in here so the code is only run
|
||||
# when we invoke this method. If we kept this at the class
|
||||
# level we would get an error beause the class level
|
||||
# code would be run when this module is imported, and these composed
|
||||
# classes don't exist yet because their module has not finished
|
||||
# loading
|
||||
return {
|
||||
'anyOf': [
|
||||
{{#anyOf}}
|
||||
{{{.}}},
|
||||
{{/anyOf}}
|
||||
],
|
||||
'allOf': [
|
||||
{{#allOf}}
|
||||
{{{.}}},
|
||||
{{/allOf}}
|
||||
],
|
||||
'oneOf': [
|
||||
{{#oneOf}}
|
||||
{{{.}}},
|
||||
{{/oneOf}}
|
||||
],
|
||||
}{{#discriminator}}
|
||||
|
||||
{{> python-experimental/model_templates/method_discriminator }}{{/discriminator}}
|
||||
@@ -1,4 +1,4 @@
|
||||
class {{classname}}(ModelNormal):
|
||||
class {{unescapedDescription}}(ModelNormal):
|
||||
"""NOTE: This class is auto generated by OpenAPI Generator.
|
||||
Ref: https://openapi-generator.tech
|
||||
|
||||
@@ -13,69 +13,21 @@ class {{classname}}(ModelNormal):
|
||||
{{> python-experimental/model_templates/docstring_openapi_validations }}
|
||||
"""
|
||||
|
||||
{{> python-experimental/model_templates/classvar_allowed }}
|
||||
{{> python-experimental/model_templates/classvars }}
|
||||
|
||||
attribute_map = {
|
||||
{{#allVars}}
|
||||
'{{name}}': '{{baseName}}'{{#hasMore}},{{/hasMore}} # noqa: E501
|
||||
{{/allVars}}
|
||||
{{#requiredVars}}
|
||||
'{{name}}': '{{baseName}}', # noqa: E501
|
||||
{{/requiredVars}}
|
||||
{{#optionalVars}}
|
||||
'{{name}}': '{{baseName}}', # noqa: E501
|
||||
{{/optionalVars}}
|
||||
}
|
||||
{{#discriminator}}
|
||||
|
||||
discriminator_value_class_map = {
|
||||
{{#children}}'{{^vendorExtensions.x-discriminator-value}}{{name}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}': {{{classname}}}{{^-last}},
|
||||
{{/-last}}{{/children}}
|
||||
}
|
||||
{{/discriminator}}
|
||||
@staticmethod
|
||||
def _composed_schemas():
|
||||
return None
|
||||
|
||||
{{> python-experimental/model_templates/classvar_openapi_validations }}
|
||||
{{> python-experimental/model_templates/method_init_normal}}{{#discriminator}}
|
||||
|
||||
{{> python-experimental/model_templates/methods_init_properties }}
|
||||
{{#discriminator}}
|
||||
@classmethod
|
||||
def get_real_child_model(cls, data):
|
||||
"""Returns the real base class specified by the discriminator
|
||||
We assume that data has javascript keys
|
||||
"""
|
||||
discriminator_key = cls.attribute_map[cls.discriminator]
|
||||
discriminator_value = data[discriminator_key]
|
||||
return cls.discriminator_value_class_map.get(discriminator_value)
|
||||
|
||||
{{/discriminator}}
|
||||
def to_dict(self):
|
||||
"""Returns the model properties as a dict"""
|
||||
return model_to_dict(self, serialize=False)
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
return pprint.pformat(self.to_dict())
|
||||
|
||||
def __repr__(self):
|
||||
"""For `print` and `pprint`"""
|
||||
return self.to_str()
|
||||
|
||||
def __eq__(self, other):
|
||||
"""Returns true if both objects are equal"""
|
||||
if not isinstance(other, {{classname}}):
|
||||
return False
|
||||
|
||||
if not set(self._data_store.keys()) == set(other._data_store.keys()):
|
||||
return False
|
||||
for _var_name, this_val in six.iteritems(self._data_store):
|
||||
that_val = other._data_store[_var_name]
|
||||
types = set()
|
||||
types.add(this_val.__class__)
|
||||
types.add(that_val.__class__)
|
||||
vals_equal = this_val == that_val
|
||||
if (not six.PY3 and
|
||||
len(types) == 2 and unicode in types): # noqa: F821
|
||||
vals_equal = (
|
||||
this_val.encode('utf-8') == that_val.encode('utf-8')
|
||||
)
|
||||
if not vals_equal:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
return not self == other
|
||||
{{> python-experimental/model_templates/method_discriminator }}{{/discriminator}}
|
||||
@@ -1,4 +1,4 @@
|
||||
class {{classname}}(ModelSimple):
|
||||
class {{unescapedDescription}}(ModelSimple):
|
||||
"""NOTE: This class is auto generated by OpenAPI Generator.
|
||||
Ref: https://openapi-generator.tech
|
||||
|
||||
@@ -9,38 +9,10 @@ class {{classname}}(ModelSimple):
|
||||
{{> python-experimental/model_templates/docstring_openapi_validations }}
|
||||
"""
|
||||
|
||||
{{> python-experimental/model_templates/classvar_allowed }}
|
||||
{{> python-experimental/model_templates/classvars }}
|
||||
|
||||
{{> python-experimental/model_templates/classvar_openapi_validations }}
|
||||
@staticmethod
|
||||
def _composed_schemas():
|
||||
return None
|
||||
|
||||
{{> python-experimental/model_templates/methods_init_properties }}
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
return str(self.value)
|
||||
|
||||
def __repr__(self):
|
||||
"""For `print` and `pprint`"""
|
||||
return self.to_str()
|
||||
|
||||
def __eq__(self, other):
|
||||
"""Returns true if both objects are equal"""
|
||||
if not isinstance(other, {{classname}}):
|
||||
return False
|
||||
|
||||
this_val = self._data_store['value']
|
||||
that_val = other._data_store['value']
|
||||
types = set()
|
||||
types.add(this_val.__class__)
|
||||
types.add(that_val.__class__)
|
||||
vals_equal = this_val == that_val
|
||||
if not six.PY3 and len(types) == 2 and unicode in types: # noqa: F821
|
||||
vals_equal = (
|
||||
this_val.encode('utf-8') == that_val.encode('utf-8')
|
||||
)
|
||||
if not vals_equal:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
return not self == other
|
||||
{{> python-experimental/model_templates/method_init_normal}}
|
||||
33
modules/openapi-generator/src/main/resources/python/python-experimental/model_test.mustache
vendored
Normal file
33
modules/openapi-generator/src/main/resources/python/python-experimental/model_test.mustache
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
# coding: utf-8
|
||||
|
||||
{{>partial_header}}
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import unittest
|
||||
|
||||
{{#models}}
|
||||
{{#model}}
|
||||
import {{packageName}}
|
||||
|
||||
|
||||
class Test{{unescapedDescription}}(unittest.TestCase):
|
||||
"""{{unescapedDescription}} unit test stubs"""
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def test{{unescapedDescription}}(self):
|
||||
"""Test {{unescapedDescription}}"""
|
||||
# FIXME: construct object with mandatory attributes with example values
|
||||
# model = {{packageName}}.{{unescapedDescription}}() # noqa: E501
|
||||
pass
|
||||
|
||||
{{/model}}
|
||||
{{/models}}
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
{{>partial_header}}
|
||||
|
||||
import copy
|
||||
from datetime import date, datetime # noqa: F401
|
||||
import inspect
|
||||
import os
|
||||
import pprint
|
||||
import re
|
||||
import tempfile
|
||||
|
||||
@@ -38,30 +38,52 @@ else:
|
||||
class OpenApiModel(object):
|
||||
"""The base class for all OpenAPIModels"""
|
||||
|
||||
{{> python-experimental/model_templates/method_set_attribute }}
|
||||
|
||||
{{> python-experimental/model_templates/methods_shared }}
|
||||
|
||||
|
||||
class ModelSimple(OpenApiModel):
|
||||
"""the parent class of models whose type != object in their
|
||||
swagger/openapi"""
|
||||
|
||||
{{> python-experimental/model_templates/methods_setattr_getattr_normal }}
|
||||
|
||||
{{> python-experimental/model_templates/methods_tostr_eq_simple }}
|
||||
|
||||
|
||||
class ModelNormal(OpenApiModel):
|
||||
"""the parent class of models whose type == object in their
|
||||
swagger/openapi"""
|
||||
|
||||
{{> python-experimental/model_templates/methods_setattr_getattr_normal }}
|
||||
|
||||
{{> python-experimental/model_templates/methods_todict_tostr_eq_shared}}
|
||||
|
||||
|
||||
class ModelComposed(OpenApiModel):
|
||||
"""the parent class of models whose type == object in their
|
||||
swagger/openapi and have oneOf/allOf/anyOf"""
|
||||
|
||||
{{> python-experimental/model_templates/methods_setattr_getattr_composed }}
|
||||
|
||||
{{> python-experimental/model_templates/methods_todict_tostr_eq_shared}}
|
||||
|
||||
|
||||
COERCION_INDEX_BY_TYPE = {
|
||||
ModelNormal: 0,
|
||||
ModelSimple: 1,
|
||||
none_type: 2,
|
||||
list: 3,
|
||||
dict: 4,
|
||||
float: 5,
|
||||
int: 6,
|
||||
bool: 7,
|
||||
datetime: 8,
|
||||
date: 9,
|
||||
str: 10,
|
||||
file_type: 11,
|
||||
ModelComposed: 0,
|
||||
ModelNormal: 1,
|
||||
ModelSimple: 2,
|
||||
none_type: 3,
|
||||
list: 4,
|
||||
dict: 5,
|
||||
float: 6,
|
||||
int: 7,
|
||||
bool: 8,
|
||||
datetime: 9,
|
||||
date: 10,
|
||||
str: 11,
|
||||
file_type: 12,
|
||||
}
|
||||
|
||||
# these are used to limit what type conversions we try to do
|
||||
@@ -70,6 +92,8 @@ COERCION_INDEX_BY_TYPE = {
|
||||
UPCONVERSION_TYPE_PAIRS = (
|
||||
(str, datetime),
|
||||
(str, date),
|
||||
(list, ModelComposed),
|
||||
(dict, ModelComposed),
|
||||
(list, ModelNormal),
|
||||
(dict, ModelNormal),
|
||||
(str, ModelSimple),
|
||||
@@ -80,6 +104,8 @@ UPCONVERSION_TYPE_PAIRS = (
|
||||
|
||||
COERCIBLE_TYPE_PAIRS = {
|
||||
False: ( # client instantiation of a model with client data
|
||||
# (dict, ModelComposed),
|
||||
# (list, ModelComposed),
|
||||
# (dict, ModelNormal),
|
||||
# (list, ModelNormal),
|
||||
# (str, ModelSimple),
|
||||
@@ -94,6 +120,8 @@ COERCIBLE_TYPE_PAIRS = {
|
||||
# (float, str),
|
||||
),
|
||||
True: ( # server -> client data
|
||||
(dict, ModelComposed),
|
||||
(list, ModelComposed),
|
||||
(dict, ModelNormal),
|
||||
(list, ModelNormal),
|
||||
(str, ModelSimple),
|
||||
@@ -336,6 +364,9 @@ def order_response_types(required_types):
|
||||
return COERCION_INDEX_BY_TYPE[list]
|
||||
elif isinstance(class_or_instance, dict):
|
||||
return COERCION_INDEX_BY_TYPE[dict]
|
||||
elif (inspect.isclass(class_or_instance)
|
||||
and issubclass(class_or_instance, ModelComposed)):
|
||||
return COERCION_INDEX_BY_TYPE[ModelComposed]
|
||||
elif (inspect.isclass(class_or_instance)
|
||||
and issubclass(class_or_instance, ModelNormal)):
|
||||
return COERCION_INDEX_BY_TYPE[ModelNormal]
|
||||
@@ -377,7 +408,9 @@ def remove_uncoercible(required_types_classes, current_item, from_server,
|
||||
# convert our models to OpenApiModel
|
||||
required_type_class_simplified = required_type_class
|
||||
if isinstance(required_type_class_simplified, type):
|
||||
if issubclass(required_type_class_simplified, ModelNormal):
|
||||
if issubclass(required_type_class_simplified, ModelComposed):
|
||||
required_type_class_simplified = ModelComposed
|
||||
elif issubclass(required_type_class_simplified, ModelNormal):
|
||||
required_type_class_simplified = ModelNormal
|
||||
elif issubclass(required_type_class_simplified, ModelSimple):
|
||||
required_type_class_simplified = ModelSimple
|
||||
@@ -514,6 +547,21 @@ def deserialize_primitive(data, klass, path_to_item):
|
||||
)
|
||||
|
||||
|
||||
def fix_model_input_data(model_data, model_class):
|
||||
# this is only called on classes where the input data is a dict
|
||||
fixed_model_data = change_keys_js_to_python(
|
||||
model_data,
|
||||
model_class
|
||||
)
|
||||
if model_class._composed_schemas() is not None:
|
||||
for allof_class in model_class._composed_schemas()['allOf']:
|
||||
fixed_model_data = change_keys_js_to_python(
|
||||
fixed_model_data,
|
||||
allof_class
|
||||
)
|
||||
return fixed_model_data
|
||||
|
||||
|
||||
def deserialize_model(model_data, model_class, path_to_item, check_type,
|
||||
configuration, from_server):
|
||||
"""Deserializes model_data to model instance.
|
||||
@@ -536,42 +584,29 @@ def deserialize_model(model_data, model_class, path_to_item, check_type,
|
||||
ApiValueError
|
||||
ApiKeyError
|
||||
"""
|
||||
fixed_model_data = copy.deepcopy(model_data)
|
||||
|
||||
if isinstance(fixed_model_data, dict):
|
||||
fixed_model_data = change_keys_js_to_python(fixed_model_data,
|
||||
model_class)
|
||||
|
||||
kw_args = dict(_check_type=check_type,
|
||||
_path_to_item=path_to_item,
|
||||
_configuration=configuration,
|
||||
_from_server=from_server)
|
||||
|
||||
if hasattr(model_class, 'get_real_child_model'):
|
||||
# discriminator case
|
||||
discriminator_class = model_class.get_real_child_model(model_data)
|
||||
if discriminator_class:
|
||||
if isinstance(model_data, list):
|
||||
instance = discriminator_class(*model_data, **kw_args)
|
||||
elif isinstance(model_data, dict):
|
||||
fixed_model_data = change_keys_js_to_python(
|
||||
fixed_model_data,
|
||||
discriminator_class
|
||||
)
|
||||
kw_args.update(fixed_model_data)
|
||||
instance = discriminator_class(**kw_args)
|
||||
else:
|
||||
# all other cases
|
||||
if isinstance(model_data, list):
|
||||
instance = model_class(*model_data, **kw_args)
|
||||
if isinstance(model_data, dict):
|
||||
fixed_model_data = change_keys_js_to_python(fixed_model_data,
|
||||
model_class)
|
||||
kw_args.update(fixed_model_data)
|
||||
instance = model_class(**kw_args)
|
||||
else:
|
||||
instance = model_class(model_data, **kw_args)
|
||||
used_model_class = model_class
|
||||
if model_class.discriminator() is not None:
|
||||
used_model_class = model_class.get_discriminator_class(
|
||||
from_server, model_data)
|
||||
|
||||
if issubclass(used_model_class, ModelSimple):
|
||||
instance = used_model_class(value=model_data, **kw_args)
|
||||
return instance
|
||||
if isinstance(model_data, list):
|
||||
instance = used_model_class(*model_data, **kw_args)
|
||||
if isinstance(model_data, dict):
|
||||
fixed_model_data = change_keys_js_to_python(
|
||||
model_data,
|
||||
used_model_class
|
||||
)
|
||||
kw_args.update(fixed_model_data)
|
||||
instance = used_model_class(**kw_args)
|
||||
return instance
|
||||
|
||||
|
||||
@@ -626,7 +661,7 @@ def attempt_convert_item(input_value, valid_classes, path_to_item,
|
||||
key_type (bool): if True we need to convert a key type (not supported)
|
||||
must_convert (bool): if True we must convert
|
||||
check_type (bool): if True we check the type or the returned data in
|
||||
ModelNormal and ModelSimple instances
|
||||
ModelComposed/ModelNormal/ModelSimple instances
|
||||
|
||||
Returns:
|
||||
instance (any) the fixed item
|
||||
@@ -790,27 +825,31 @@ def model_to_dict(model_instance, serialize=True):
|
||||
"""
|
||||
result = {}
|
||||
|
||||
for attr, value in six.iteritems(model_instance._data_store):
|
||||
if serialize:
|
||||
# we use get here because additional property key names do not
|
||||
# exist in attribute_map
|
||||
attr = model_instance.attribute_map.get(attr, attr)
|
||||
if isinstance(value, list):
|
||||
result[attr] = list(map(
|
||||
lambda x: model_to_dict(x, serialize=serialize)
|
||||
if hasattr(x, '_data_store') else x, value
|
||||
))
|
||||
elif isinstance(value, dict):
|
||||
result[attr] = dict(map(
|
||||
lambda item: (item[0],
|
||||
model_to_dict(item[1], serialize=serialize))
|
||||
if hasattr(item[1], '_data_store') else item,
|
||||
value.items()
|
||||
))
|
||||
elif hasattr(value, '_data_store'):
|
||||
result[attr] = model_to_dict(value, serialize=serialize)
|
||||
else:
|
||||
result[attr] = value
|
||||
model_instances = [model_instance]
|
||||
if model_instance._composed_schemas() is not None:
|
||||
model_instances = model_instance._composed_instances
|
||||
for model_instance in model_instances:
|
||||
for attr, value in six.iteritems(model_instance._data_store):
|
||||
if serialize:
|
||||
# we use get here because additional property key names do not
|
||||
# exist in attribute_map
|
||||
attr = model_instance.attribute_map.get(attr, attr)
|
||||
if isinstance(value, list):
|
||||
result[attr] = list(map(
|
||||
lambda x: model_to_dict(x, serialize=serialize)
|
||||
if hasattr(x, '_data_store') else x, value
|
||||
))
|
||||
elif isinstance(value, dict):
|
||||
result[attr] = dict(map(
|
||||
lambda item: (item[0],
|
||||
model_to_dict(item[1], serialize=serialize))
|
||||
if hasattr(item[1], '_data_store') else item,
|
||||
value.items()
|
||||
))
|
||||
elif hasattr(value, '_data_store'):
|
||||
result[attr] = model_to_dict(value, serialize=serialize)
|
||||
else:
|
||||
result[attr] = value
|
||||
|
||||
return result
|
||||
|
||||
@@ -866,3 +905,235 @@ def get_py3_class_name(input_class):
|
||||
elif input_class == int:
|
||||
return 'int'
|
||||
return input_class.__name__
|
||||
|
||||
|
||||
def get_allof_instances(self, model_args, constant_args):
|
||||
"""
|
||||
Args:
|
||||
self: the class we are handling
|
||||
model_args (dict): var_name to var_value
|
||||
used to make instances
|
||||
constant_args (dict): var_name to var_value
|
||||
used to make instances
|
||||
|
||||
Returns
|
||||
composed_instances (list)
|
||||
"""
|
||||
composed_instances = []
|
||||
for allof_class in self._composed_schemas()['allOf']:
|
||||
|
||||
# transform js keys to python keys in fixed_model_args
|
||||
fixed_model_args = change_keys_js_to_python(
|
||||
model_args, allof_class)
|
||||
|
||||
# extract a dict of only required keys from fixed_model_args
|
||||
kwargs = {}
|
||||
var_names = set(allof_class.openapi_types.keys())
|
||||
for var_name in var_names:
|
||||
if var_name in fixed_model_args:
|
||||
kwargs[var_name] = fixed_model_args[var_name]
|
||||
|
||||
# and use it to make the instance
|
||||
kwargs.update(constant_args)
|
||||
allof_instance = allof_class(**kwargs)
|
||||
composed_instances.append(allof_instance)
|
||||
return composed_instances
|
||||
|
||||
|
||||
def get_oneof_instance(self, model_args, constant_args):
|
||||
"""
|
||||
Args:
|
||||
self: the class we are handling
|
||||
model_args (dict): var_name to var_value
|
||||
used to make instances
|
||||
constant_args (dict): var_name to var_value
|
||||
used to make instances
|
||||
|
||||
Returns
|
||||
oneof_instance (instance)
|
||||
"""
|
||||
oneof_instance = None
|
||||
if len(self._composed_schemas()['oneOf']) == 0:
|
||||
return oneof_instance
|
||||
|
||||
for oneof_class in self._composed_schemas()['oneOf']:
|
||||
# transform js keys to python keys in fixed_model_args
|
||||
fixed_model_args = change_keys_js_to_python(
|
||||
model_args, oneof_class)
|
||||
|
||||
# extract a dict of only required keys from fixed_model_args
|
||||
kwargs = {}
|
||||
var_names = set(oneof_class.openapi_types.keys())
|
||||
for var_name in var_names:
|
||||
if var_name in fixed_model_args:
|
||||
kwargs[var_name] = fixed_model_args[var_name]
|
||||
|
||||
# and use it to make the instance
|
||||
kwargs.update(constant_args)
|
||||
try:
|
||||
oneof_instance = oneof_class(**kwargs)
|
||||
break
|
||||
except Exception:
|
||||
pass
|
||||
if oneof_instance is None:
|
||||
raise ApiValueError(
|
||||
"Invalid inputs given to generate an instance of %s. Unable to "
|
||||
"make any instances of the classes in oneOf definition." %
|
||||
self.__class__.__name__
|
||||
)
|
||||
return oneof_instance
|
||||
|
||||
|
||||
def get_anyof_instances(self, model_args, constant_args):
|
||||
"""
|
||||
Args:
|
||||
self: the class we are handling
|
||||
model_args (dict): var_name to var_value
|
||||
used to make instances
|
||||
constant_args (dict): var_name to var_value
|
||||
used to make instances
|
||||
|
||||
Returns
|
||||
anyof_instances (list)
|
||||
"""
|
||||
anyof_instances = []
|
||||
if len(self._composed_schemas()['anyOf']) == 0:
|
||||
return anyof_instances
|
||||
|
||||
for anyof_class in self._composed_schemas()['anyOf']:
|
||||
# transform js keys to python keys in fixed_model_args
|
||||
fixed_model_args = change_keys_js_to_python(model_args, anyof_class)
|
||||
|
||||
# extract a dict of only required keys from these_model_vars
|
||||
kwargs = {}
|
||||
var_names = set(anyof_class.openapi_types.keys())
|
||||
for var_name in var_names:
|
||||
if var_name in fixed_model_args:
|
||||
kwargs[var_name] = fixed_model_args[var_name]
|
||||
|
||||
# and use it to make the instance
|
||||
kwargs.update(constant_args)
|
||||
try:
|
||||
anyof_instance = anyof_class(**kwargs)
|
||||
anyof_instances.append(anyof_instance)
|
||||
except Exception:
|
||||
pass
|
||||
if len(anyof_instances) == 0:
|
||||
raise ApiValueError(
|
||||
"Invalid inputs given to generate an instance of %s. Unable to "
|
||||
"make any instances of the classes in anyOf definition." %
|
||||
self.__class__.__name__
|
||||
)
|
||||
return anyof_instances
|
||||
|
||||
|
||||
def get_additional_properties_model_instances(
|
||||
composed_instances, self):
|
||||
additional_properties_model_instances = []
|
||||
all_instances = [self]
|
||||
all_instances.extend(composed_instances)
|
||||
for instance in all_instances:
|
||||
if instance.additional_properties_type is not None:
|
||||
additional_properties_model_instances.append(instance)
|
||||
return additional_properties_model_instances
|
||||
|
||||
|
||||
def get_var_name_to_model_instances(self, composed_instances):
|
||||
var_name_to_model_instances = {}
|
||||
all_instances = [self]
|
||||
all_instances.extend(composed_instances)
|
||||
for instance in all_instances:
|
||||
for var_name in instance.openapi_types:
|
||||
if var_name not in var_name_to_model_instances:
|
||||
var_name_to_model_instances[var_name] = [instance]
|
||||
else:
|
||||
var_name_to_model_instances[var_name].append(instance)
|
||||
return var_name_to_model_instances
|
||||
|
||||
|
||||
def get_unused_args(self, composed_instances, model_args):
|
||||
unused_args = dict(model_args)
|
||||
# arguments apssed to self were already converted to python names
|
||||
# before __init__ was called
|
||||
for var_name_py in self.attribute_map:
|
||||
if var_name_py in unused_args:
|
||||
del unused_args[var_name_py]
|
||||
for instance in composed_instances:
|
||||
if instance.__class__ in self._composed_schemas()['allOf']:
|
||||
for var_name_py in instance.attribute_map:
|
||||
if var_name_py in unused_args:
|
||||
del unused_args[var_name_py]
|
||||
else:
|
||||
for var_name_js in instance.attribute_map.values():
|
||||
if var_name_js in unused_args:
|
||||
del unused_args[var_name_js]
|
||||
return unused_args
|
||||
|
||||
|
||||
def validate_get_composed_info(constant_args, model_args, self):
|
||||
"""
|
||||
For composed schemas/classes, validates the classes to make sure that
|
||||
they do not share any of the same parameters. If there is no collision
|
||||
then composed model instances are created and returned tot the calling
|
||||
self model
|
||||
|
||||
Args:
|
||||
constant_args (dict): these are the args that every model requires
|
||||
model_args (dict): these are the required and optional spec args that
|
||||
were passed in to make this model
|
||||
self (class): the class that we are instantiating
|
||||
This class contains self._composed_schemas()
|
||||
|
||||
Returns:
|
||||
composed_info (list): length three
|
||||
composed_instances (list): the composed instances which are not
|
||||
self
|
||||
var_name_to_model_instances (dict): a dict going from var_name
|
||||
to the model_instance which holds that var_name
|
||||
the model_instance may be self or an instance of one of the
|
||||
classes in self.composed_instances()
|
||||
additional_properties_model_instances (list): a list of the
|
||||
model instances which have the property
|
||||
additional_properties_type. This list can include self
|
||||
"""
|
||||
# create composed_instances
|
||||
composed_instances = []
|
||||
allof_instances = get_allof_instances(self, model_args, constant_args)
|
||||
composed_instances.extend(allof_instances)
|
||||
oneof_instance = get_oneof_instance(self, model_args, constant_args)
|
||||
if oneof_instance is not None:
|
||||
composed_instances.append(oneof_instance)
|
||||
anyof_instances = get_anyof_instances(self, model_args, constant_args)
|
||||
composed_instances.extend(anyof_instances)
|
||||
|
||||
# map variable names to composed_instances
|
||||
var_name_to_model_instances = get_var_name_to_model_instances(
|
||||
self, composed_instances)
|
||||
|
||||
# set additional_properties_model_instances
|
||||
additional_properties_model_instances = (
|
||||
get_additional_properties_model_instances(composed_instances, self)
|
||||
)
|
||||
|
||||
# set any remaining values
|
||||
unused_args = get_unused_args(self, composed_instances, model_args)
|
||||
if len(unused_args) > 0:
|
||||
if len(additional_properties_model_instances) == 0:
|
||||
raise ApiValueError(
|
||||
"Invalid input arguments input when making an instance of "
|
||||
"class %s. Not all inputs were used. The unused input data "
|
||||
"is %s" % (self.__class__.__name__, unused_args)
|
||||
)
|
||||
for var_name, var_value in six.iteritems(unused_args):
|
||||
for instance in additional_properties_model_instances:
|
||||
setattr(instance, var_name, var_value)
|
||||
# no need to add additional_properties to var_name_to_model_instances here
|
||||
# because additional_properties_model_instances will direct us to that
|
||||
# instance when we use getattr or setattr
|
||||
# and we update var_name_to_model_instances in setattr
|
||||
|
||||
return [
|
||||
composed_instances,
|
||||
var_name_to_model_instances,
|
||||
additional_properties_model_instances
|
||||
]
|
||||
|
||||
@@ -38,19 +38,19 @@ public class PythonClientExperimentalTest {
|
||||
codegen.setOpenAPI(openAPI);
|
||||
final CodegenModel simpleName = codegen.fromModel("v1beta3.Binding", openAPI.getComponents().getSchemas().get("v1beta3.Binding"));
|
||||
Assert.assertEquals(simpleName.name, "v1beta3.Binding");
|
||||
Assert.assertEquals(simpleName.classname, "V1beta3Binding");
|
||||
Assert.assertEquals(simpleName.classname, "v1beta3_binding.V1beta3Binding");
|
||||
Assert.assertEquals(simpleName.classVarName, "v1beta3_binding");
|
||||
|
||||
codegen.setOpenAPI(openAPI);
|
||||
final CodegenModel compoundName = codegen.fromModel("v1beta3.ComponentStatus", openAPI.getComponents().getSchemas().get("v1beta3.ComponentStatus"));
|
||||
Assert.assertEquals(compoundName.name, "v1beta3.ComponentStatus");
|
||||
Assert.assertEquals(compoundName.classname, "V1beta3ComponentStatus");
|
||||
Assert.assertEquals(compoundName.classname, "v1beta3_component_status.V1beta3ComponentStatus");
|
||||
Assert.assertEquals(compoundName.classVarName, "v1beta3_component_status");
|
||||
|
||||
final String path = "/api/v1beta3/namespaces/{namespaces}/bindings";
|
||||
final Operation operation = openAPI.getPaths().get(path).getPost();
|
||||
final CodegenOperation codegenOperation = codegen.fromOperation(path, "get", operation, null);
|
||||
Assert.assertEquals(codegenOperation.returnType, "V1beta3Binding");
|
||||
Assert.assertEquals(codegenOperation.returnType, "v1beta3_binding.V1beta3Binding");
|
||||
Assert.assertEquals(codegenOperation.returnBaseType, "V1beta3Binding");
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ public class PythonClientExperimentalTest {
|
||||
final CodegenModel cm = codegen.fromModel("sample", schema);
|
||||
|
||||
Assert.assertEquals(cm.name, "sample");
|
||||
Assert.assertEquals(cm.classname, "Sample");
|
||||
Assert.assertEquals(cm.classname, "sample.Sample");
|
||||
Assert.assertEquals(cm.description, "a sample model");
|
||||
Assert.assertEquals(cm.vars.size(), 3);
|
||||
|
||||
@@ -117,7 +117,7 @@ public class PythonClientExperimentalTest {
|
||||
final CodegenModel cm = codegen.fromModel("sample", model);
|
||||
|
||||
Assert.assertEquals(cm.name, "sample");
|
||||
Assert.assertEquals(cm.classname, "Sample");
|
||||
Assert.assertEquals(cm.classname, "sample.Sample");
|
||||
Assert.assertEquals(cm.description, "a sample model");
|
||||
Assert.assertEquals(cm.vars.size(), 2);
|
||||
|
||||
@@ -157,7 +157,7 @@ public class PythonClientExperimentalTest {
|
||||
final CodegenModel cm = codegen.fromModel("sample", model);
|
||||
|
||||
Assert.assertEquals(cm.name, "sample");
|
||||
Assert.assertEquals(cm.classname, "Sample");
|
||||
Assert.assertEquals(cm.classname, "sample.Sample");
|
||||
Assert.assertEquals(cm.description, "a sample model");
|
||||
Assert.assertEquals(cm.vars.size(), 1);
|
||||
|
||||
@@ -183,15 +183,15 @@ public class PythonClientExperimentalTest {
|
||||
final CodegenModel cm = codegen.fromModel("sample", model);
|
||||
|
||||
Assert.assertEquals(cm.name, "sample");
|
||||
Assert.assertEquals(cm.classname, "Sample");
|
||||
Assert.assertEquals(cm.classname, "sample.Sample");
|
||||
Assert.assertEquals(cm.description, "a sample model");
|
||||
Assert.assertEquals(cm.vars.size(), 1);
|
||||
|
||||
final CodegenProperty property1 = cm.vars.get(0);
|
||||
Assert.assertEquals(property1.baseName, "children");
|
||||
Assert.assertEquals(property1.dataType, "Children");
|
||||
Assert.assertEquals(property1.dataType, "children.Children");
|
||||
Assert.assertEquals(property1.name, "children");
|
||||
Assert.assertEquals(property1.baseType, "Children");
|
||||
Assert.assertEquals(property1.baseType, "children.Children");
|
||||
Assert.assertFalse(property1.required);
|
||||
Assert.assertFalse(property1.isContainer);
|
||||
}
|
||||
@@ -208,14 +208,14 @@ public class PythonClientExperimentalTest {
|
||||
final CodegenModel cm = codegen.fromModel("sample", model);
|
||||
|
||||
Assert.assertEquals(cm.name, "sample");
|
||||
Assert.assertEquals(cm.classname, "Sample");
|
||||
Assert.assertEquals(cm.classname, "sample.Sample");
|
||||
Assert.assertEquals(cm.description, "a sample model");
|
||||
Assert.assertEquals(cm.vars.size(), 1);
|
||||
|
||||
final CodegenProperty property1 = cm.vars.get(0);
|
||||
Assert.assertEquals(property1.baseName, "children");
|
||||
Assert.assertEquals(property1.complexType, "Children");
|
||||
Assert.assertEquals(property1.dataType, "[Children]");
|
||||
Assert.assertEquals(property1.dataType, "[children.Children]");
|
||||
Assert.assertEquals(property1.name, "children");
|
||||
Assert.assertEquals(property1.baseType, "list");
|
||||
Assert.assertEquals(property1.containerType, "array");
|
||||
@@ -235,15 +235,15 @@ public class PythonClientExperimentalTest {
|
||||
final CodegenModel cm = codegen.fromModel("sample", model);
|
||||
|
||||
Assert.assertEquals(cm.name, "sample");
|
||||
Assert.assertEquals(cm.classname, "Sample");
|
||||
Assert.assertEquals(cm.classname, "sample.Sample");
|
||||
Assert.assertEquals(cm.description, "a sample model");
|
||||
Assert.assertEquals(cm.vars.size(), 1);
|
||||
Assert.assertEquals(Sets.intersection(cm.imports, Sets.newHashSet("Children")).size(), 1);
|
||||
Assert.assertEquals(Sets.intersection(cm.imports, Sets.newHashSet("children.Children")).size(), 1);
|
||||
|
||||
final CodegenProperty property1 = cm.vars.get(0);
|
||||
Assert.assertEquals(property1.baseName, "children");
|
||||
Assert.assertEquals(property1.complexType, "Children");
|
||||
Assert.assertEquals(property1.dataType, "{str: (Children,)}");
|
||||
Assert.assertEquals(property1.dataType, "{str: (children.Children,)}");
|
||||
Assert.assertEquals(property1.name, "children");
|
||||
Assert.assertEquals(property1.baseType, "dict");
|
||||
Assert.assertEquals(property1.containerType, "map");
|
||||
@@ -265,12 +265,13 @@ public class PythonClientExperimentalTest {
|
||||
final CodegenModel cm = codegen.fromModel("sample", model);
|
||||
|
||||
Assert.assertEquals(cm.name, "sample");
|
||||
Assert.assertEquals(cm.classname, "Sample");
|
||||
Assert.assertEquals(cm.classname, "sample.Sample");
|
||||
Assert.assertEquals(cm.classVarName, "sample");
|
||||
Assert.assertEquals(cm.description, "an array model");
|
||||
Assert.assertEquals(cm.vars.size(), 0);
|
||||
Assert.assertEquals(cm.parent, "list");
|
||||
Assert.assertEquals(cm.imports.size(), 1);
|
||||
Assert.assertEquals(Sets.intersection(cm.imports, Sets.newHashSet("Children")).size(), 1);
|
||||
Assert.assertEquals(Sets.intersection(cm.imports, Sets.newHashSet("children.Children")).size(), 1);
|
||||
}
|
||||
|
||||
// should not start with 'null'. need help from the community to investigate further
|
||||
@@ -285,12 +286,12 @@ public class PythonClientExperimentalTest {
|
||||
final CodegenModel cm = codegen.fromModel("sample", model);
|
||||
|
||||
Assert.assertEquals(cm.name, "sample");
|
||||
Assert.assertEquals(cm.classname, "Sample");
|
||||
Assert.assertEquals(cm.classname, "sample.Sample");
|
||||
Assert.assertEquals(cm.description, "a map model");
|
||||
Assert.assertEquals(cm.vars.size(), 0);
|
||||
Assert.assertEquals(cm.parent, "dict");
|
||||
Assert.assertEquals(cm.imports.size(), 1);
|
||||
Assert.assertEquals(Sets.intersection(cm.imports, Sets.newHashSet("Children")).size(), 1);
|
||||
Assert.assertEquals(Sets.intersection(cm.imports, Sets.newHashSet("children.Children")).size(), 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1238,6 +1238,10 @@ definitions:
|
||||
format: int64
|
||||
name:
|
||||
type: string
|
||||
# we added fullName to make sure that serialization/deserialization
|
||||
# works for a submodel of Pet that also uses js variable names
|
||||
fullName:
|
||||
type: string
|
||||
xml:
|
||||
name: Tag
|
||||
Pet:
|
||||
@@ -2038,4 +2042,57 @@ definitions:
|
||||
type: integer
|
||||
xml:
|
||||
namespace: http://g.com/schema
|
||||
prefix: g
|
||||
prefix: g
|
||||
Grandparent:
|
||||
type: object
|
||||
properties:
|
||||
radioWaves:
|
||||
type: boolean
|
||||
Parent:
|
||||
allOf:
|
||||
- $ref: '#/definitions/Grandparent'
|
||||
- type: object
|
||||
properties:
|
||||
teleVision:
|
||||
type: boolean
|
||||
Child:
|
||||
allOf:
|
||||
- $ref: '#/definitions/Parent'
|
||||
- type: object
|
||||
properties:
|
||||
interNet:
|
||||
type: boolean
|
||||
GrandparentAnimal:
|
||||
type: object
|
||||
required:
|
||||
- pet_type
|
||||
properties:
|
||||
pet_type:
|
||||
type: string
|
||||
ParentPet:
|
||||
type: object
|
||||
allOf:
|
||||
- $ref: '#/definitions/GrandparentAnimal'
|
||||
- type: object
|
||||
discriminator: pet_type
|
||||
ChildCat:
|
||||
allOf:
|
||||
- $ref: '#/definitions/ParentPet'
|
||||
- type: object
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
ChildDog:
|
||||
allOf:
|
||||
- $ref: '#/definitions/ParentPet'
|
||||
- type: object
|
||||
properties:
|
||||
bark:
|
||||
type: string
|
||||
ChildLizard:
|
||||
allOf:
|
||||
- $ref: '#/definitions/ParentPet'
|
||||
- type: object
|
||||
properties:
|
||||
lovesRocks:
|
||||
type: boolean
|
||||
@@ -23,7 +23,7 @@ pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git
|
||||
|
||||
Then import the package:
|
||||
```python
|
||||
import petstore_api
|
||||
import petstore_api
|
||||
```
|
||||
|
||||
### Setuptools
|
||||
|
||||
@@ -23,7 +23,7 @@ pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git
|
||||
|
||||
Then import the package:
|
||||
```python
|
||||
import petstore_api
|
||||
import petstore_api
|
||||
```
|
||||
|
||||
### Setuptools
|
||||
@@ -48,7 +48,6 @@ Please follow the [installation procedure](#installation--usage) and then run th
|
||||
from __future__ import print_function
|
||||
import time
|
||||
import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
|
||||
@@ -56,13 +55,13 @@ from pprint import pprint
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.AnotherFakeApi(petstore_api.ApiClient(configuration))
|
||||
body = petstore_api.Client() # Client | client model
|
||||
body = petstore_api.Client() # client.Client | client model
|
||||
|
||||
try:
|
||||
# To test special tags
|
||||
api_response = api_instance.call_123_test_special_tags(body)
|
||||
pprint(api_response)
|
||||
except ApiException as e:
|
||||
except petstore_api.ApiException as e:
|
||||
print("Exception when calling AnotherFakeApi->call_123_test_special_tags: %s\n" % e)
|
||||
|
||||
```
|
||||
@@ -115,54 +114,67 @@ Class | Method | HTTP request | Description
|
||||
|
||||
## Documentation For Models
|
||||
|
||||
- [AdditionalPropertiesAnyType](docs/AdditionalPropertiesAnyType.md)
|
||||
- [AdditionalPropertiesArray](docs/AdditionalPropertiesArray.md)
|
||||
- [AdditionalPropertiesBoolean](docs/AdditionalPropertiesBoolean.md)
|
||||
- [AdditionalPropertiesClass](docs/AdditionalPropertiesClass.md)
|
||||
- [AdditionalPropertiesInteger](docs/AdditionalPropertiesInteger.md)
|
||||
- [AdditionalPropertiesNumber](docs/AdditionalPropertiesNumber.md)
|
||||
- [AdditionalPropertiesObject](docs/AdditionalPropertiesObject.md)
|
||||
- [AdditionalPropertiesString](docs/AdditionalPropertiesString.md)
|
||||
- [Animal](docs/Animal.md)
|
||||
- [ApiResponse](docs/ApiResponse.md)
|
||||
- [ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md)
|
||||
- [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md)
|
||||
- [ArrayTest](docs/ArrayTest.md)
|
||||
- [Capitalization](docs/Capitalization.md)
|
||||
- [Cat](docs/Cat.md)
|
||||
- [CatAllOf](docs/CatAllOf.md)
|
||||
- [Category](docs/Category.md)
|
||||
- [ClassModel](docs/ClassModel.md)
|
||||
- [Client](docs/Client.md)
|
||||
- [Dog](docs/Dog.md)
|
||||
- [DogAllOf](docs/DogAllOf.md)
|
||||
- [EnumArrays](docs/EnumArrays.md)
|
||||
- [EnumClass](docs/EnumClass.md)
|
||||
- [EnumTest](docs/EnumTest.md)
|
||||
- [File](docs/File.md)
|
||||
- [FileSchemaTestClass](docs/FileSchemaTestClass.md)
|
||||
- [FormatTest](docs/FormatTest.md)
|
||||
- [HasOnlyReadOnly](docs/HasOnlyReadOnly.md)
|
||||
- [List](docs/List.md)
|
||||
- [MapTest](docs/MapTest.md)
|
||||
- [MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md)
|
||||
- [Model200Response](docs/Model200Response.md)
|
||||
- [ModelReturn](docs/ModelReturn.md)
|
||||
- [Name](docs/Name.md)
|
||||
- [NumberOnly](docs/NumberOnly.md)
|
||||
- [Order](docs/Order.md)
|
||||
- [OuterComposite](docs/OuterComposite.md)
|
||||
- [OuterEnum](docs/OuterEnum.md)
|
||||
- [OuterNumber](docs/OuterNumber.md)
|
||||
- [Pet](docs/Pet.md)
|
||||
- [ReadOnlyFirst](docs/ReadOnlyFirst.md)
|
||||
- [SpecialModelName](docs/SpecialModelName.md)
|
||||
- [StringBooleanMap](docs/StringBooleanMap.md)
|
||||
- [Tag](docs/Tag.md)
|
||||
- [TypeHolderDefault](docs/TypeHolderDefault.md)
|
||||
- [TypeHolderExample](docs/TypeHolderExample.md)
|
||||
- [User](docs/User.md)
|
||||
- [XmlItem](docs/XmlItem.md)
|
||||
- [additional_properties_any_type.AdditionalPropertiesAnyType](docs/AdditionalPropertiesAnyType.md)
|
||||
- [additional_properties_array.AdditionalPropertiesArray](docs/AdditionalPropertiesArray.md)
|
||||
- [additional_properties_boolean.AdditionalPropertiesBoolean](docs/AdditionalPropertiesBoolean.md)
|
||||
- [additional_properties_class.AdditionalPropertiesClass](docs/AdditionalPropertiesClass.md)
|
||||
- [additional_properties_integer.AdditionalPropertiesInteger](docs/AdditionalPropertiesInteger.md)
|
||||
- [additional_properties_number.AdditionalPropertiesNumber](docs/AdditionalPropertiesNumber.md)
|
||||
- [additional_properties_object.AdditionalPropertiesObject](docs/AdditionalPropertiesObject.md)
|
||||
- [additional_properties_string.AdditionalPropertiesString](docs/AdditionalPropertiesString.md)
|
||||
- [animal.Animal](docs/Animal.md)
|
||||
- [api_response.ApiResponse](docs/ApiResponse.md)
|
||||
- [array_of_array_of_number_only.ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md)
|
||||
- [array_of_number_only.ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md)
|
||||
- [array_test.ArrayTest](docs/ArrayTest.md)
|
||||
- [capitalization.Capitalization](docs/Capitalization.md)
|
||||
- [cat.Cat](docs/Cat.md)
|
||||
- [cat_all_of.CatAllOf](docs/CatAllOf.md)
|
||||
- [category.Category](docs/Category.md)
|
||||
- [child.Child](docs/Child.md)
|
||||
- [child_all_of.ChildAllOf](docs/ChildAllOf.md)
|
||||
- [child_cat.ChildCat](docs/ChildCat.md)
|
||||
- [child_cat_all_of.ChildCatAllOf](docs/ChildCatAllOf.md)
|
||||
- [child_dog.ChildDog](docs/ChildDog.md)
|
||||
- [child_dog_all_of.ChildDogAllOf](docs/ChildDogAllOf.md)
|
||||
- [child_lizard.ChildLizard](docs/ChildLizard.md)
|
||||
- [child_lizard_all_of.ChildLizardAllOf](docs/ChildLizardAllOf.md)
|
||||
- [class_model.ClassModel](docs/ClassModel.md)
|
||||
- [client.Client](docs/Client.md)
|
||||
- [dog.Dog](docs/Dog.md)
|
||||
- [dog_all_of.DogAllOf](docs/DogAllOf.md)
|
||||
- [enum_arrays.EnumArrays](docs/EnumArrays.md)
|
||||
- [enum_class.EnumClass](docs/EnumClass.md)
|
||||
- [enum_test.EnumTest](docs/EnumTest.md)
|
||||
- [file.File](docs/File.md)
|
||||
- [file_schema_test_class.FileSchemaTestClass](docs/FileSchemaTestClass.md)
|
||||
- [format_test.FormatTest](docs/FormatTest.md)
|
||||
- [grandparent.Grandparent](docs/Grandparent.md)
|
||||
- [grandparent_animal.GrandparentAnimal](docs/GrandparentAnimal.md)
|
||||
- [has_only_read_only.HasOnlyReadOnly](docs/HasOnlyReadOnly.md)
|
||||
- [list.List](docs/List.md)
|
||||
- [map_test.MapTest](docs/MapTest.md)
|
||||
- [mixed_properties_and_additional_properties_class.MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md)
|
||||
- [model200_response.Model200Response](docs/Model200Response.md)
|
||||
- [model_return.ModelReturn](docs/ModelReturn.md)
|
||||
- [name.Name](docs/Name.md)
|
||||
- [number_only.NumberOnly](docs/NumberOnly.md)
|
||||
- [order.Order](docs/Order.md)
|
||||
- [outer_composite.OuterComposite](docs/OuterComposite.md)
|
||||
- [outer_enum.OuterEnum](docs/OuterEnum.md)
|
||||
- [outer_number.OuterNumber](docs/OuterNumber.md)
|
||||
- [parent.Parent](docs/Parent.md)
|
||||
- [parent_all_of.ParentAllOf](docs/ParentAllOf.md)
|
||||
- [parent_pet.ParentPet](docs/ParentPet.md)
|
||||
- [pet.Pet](docs/Pet.md)
|
||||
- [read_only_first.ReadOnlyFirst](docs/ReadOnlyFirst.md)
|
||||
- [special_model_name.SpecialModelName](docs/SpecialModelName.md)
|
||||
- [string_boolean_map.StringBooleanMap](docs/StringBooleanMap.md)
|
||||
- [tag.Tag](docs/Tag.md)
|
||||
- [type_holder_default.TypeHolderDefault](docs/TypeHolderDefault.md)
|
||||
- [type_holder_example.TypeHolderExample](docs/TypeHolderExample.md)
|
||||
- [user.User](docs/User.md)
|
||||
- [xml_item.XmlItem](docs/XmlItem.md)
|
||||
|
||||
|
||||
## Documentation For Authorization
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# AdditionalPropertiesAnyType
|
||||
# additional_properties_any_type.AdditionalPropertiesAnyType
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# AdditionalPropertiesArray
|
||||
# additional_properties_array.AdditionalPropertiesArray
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# AdditionalPropertiesBoolean
|
||||
# additional_properties_boolean.AdditionalPropertiesBoolean
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# AdditionalPropertiesClass
|
||||
# additional_properties_class.AdditionalPropertiesClass
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
@@ -11,9 +11,9 @@ Name | Type | Description | Notes
|
||||
**map_array_anytype** | **{str: ([bool, date, datetime, dict, float, int, list, str],)}** | | [optional]
|
||||
**map_map_string** | **{str: ({str: (str,)},)}** | | [optional]
|
||||
**map_map_anytype** | **{str: ({str: (bool, date, datetime, dict, float, int, list, str,)},)}** | | [optional]
|
||||
**anytype_1** | [**bool, date, datetime, dict, float, int, list, str**](.md) | | [optional]
|
||||
**anytype_2** | [**bool, date, datetime, dict, float, int, list, str**](.md) | | [optional]
|
||||
**anytype_3** | [**bool, date, datetime, dict, float, int, list, str**](.md) | | [optional]
|
||||
**anytype_1** | **bool, date, datetime, dict, float, int, list, str** | | [optional]
|
||||
**anytype_2** | **bool, date, datetime, dict, float, int, list, str** | | [optional]
|
||||
**anytype_3** | **bool, date, datetime, dict, float, int, list, str** | | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# AdditionalPropertiesInteger
|
||||
# additional_properties_integer.AdditionalPropertiesInteger
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# AdditionalPropertiesNumber
|
||||
# additional_properties_number.AdditionalPropertiesNumber
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# AdditionalPropertiesObject
|
||||
# additional_properties_object.AdditionalPropertiesObject
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# AdditionalPropertiesString
|
||||
# additional_properties_string.AdditionalPropertiesString
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Animal
|
||||
# animal.Animal
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
|
||||
@@ -8,7 +8,7 @@ Method | HTTP request | Description
|
||||
|
||||
|
||||
# **call_123_test_special_tags**
|
||||
> Client call_123_test_special_tags(body)
|
||||
> client.Client call_123_test_special_tags(body)
|
||||
|
||||
To test special tags
|
||||
|
||||
@@ -20,18 +20,18 @@ To test special tags and operation ID starting with number
|
||||
from __future__ import print_function
|
||||
import time
|
||||
import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.AnotherFakeApi()
|
||||
body = petstore_api.Client() # Client | client model
|
||||
body = petstore_api.Client() # client.Client | client model
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
try:
|
||||
# To test special tags
|
||||
api_response = api_instance.call_123_test_special_tags(body)
|
||||
pprint(api_response)
|
||||
except ApiException as e:
|
||||
except petstore_api.ApiException as e:
|
||||
print("Exception when calling AnotherFakeApi->call_123_test_special_tags: %s\n" % e)
|
||||
```
|
||||
|
||||
@@ -39,11 +39,11 @@ except ApiException as e:
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | [**Client**](Client.md)| client model |
|
||||
**body** | [**client.Client**](Client.md)| client model |
|
||||
|
||||
### Return type
|
||||
|
||||
[**Client**](Client.md)
|
||||
[**client.Client**](Client.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# ApiResponse
|
||||
# api_response.ApiResponse
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# ArrayOfArrayOfNumberOnly
|
||||
# array_of_array_of_number_only.ArrayOfArrayOfNumberOnly
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# ArrayOfNumberOnly
|
||||
# array_of_number_only.ArrayOfNumberOnly
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
# ArrayTest
|
||||
# array_test.ArrayTest
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**array_of_string** | **[str]** | | [optional]
|
||||
**array_array_of_integer** | **[[int]]** | | [optional]
|
||||
**array_array_of_model** | **[[ReadOnlyFirst]]** | | [optional]
|
||||
**array_array_of_model** | [**[[read_only_first.ReadOnlyFirst]]**](ReadOnlyFirst.md) | | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Capitalization
|
||||
# capitalization.Capitalization
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Cat
|
||||
# cat.Cat
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# CatAllOf
|
||||
# cat_all_of.CatAllOf
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Category
|
||||
# category.Category
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
|
||||
12
samples/client/petstore/python-experimental/docs/Child.md
Normal file
12
samples/client/petstore/python-experimental/docs/Child.md
Normal file
@@ -0,0 +1,12 @@
|
||||
# child.Child
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**radio_waves** | **bool** | | [optional]
|
||||
**tele_vision** | **bool** | | [optional]
|
||||
**inter_net** | **bool** | | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
# child_all_of.ChildAllOf
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**inter_net** | **bool** | | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
11
samples/client/petstore/python-experimental/docs/ChildCat.md
Normal file
11
samples/client/petstore/python-experimental/docs/ChildCat.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# child_cat.ChildCat
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**pet_type** | **str** | |
|
||||
**name** | **str** | | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
# child_cat_all_of.ChildCatAllOf
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**name** | **str** | | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
11
samples/client/petstore/python-experimental/docs/ChildDog.md
Normal file
11
samples/client/petstore/python-experimental/docs/ChildDog.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# child_dog.ChildDog
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**pet_type** | **str** | |
|
||||
**bark** | **str** | | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
# child_dog_all_of.ChildDogAllOf
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**bark** | **str** | | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
# child_lizard.ChildLizard
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**pet_type** | **str** | |
|
||||
**loves_rocks** | **bool** | | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
# child_lizard_all_of.ChildLizardAllOf
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**loves_rocks** | **bool** | | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# ClassModel
|
||||
# class_model.ClassModel
|
||||
|
||||
Model for testing model with \"_class\" property
|
||||
## Properties
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Client
|
||||
# client.Client
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Dog
|
||||
# dog.Dog
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# DogAllOf
|
||||
# dog_all_of.DogAllOf
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# EnumArrays
|
||||
# enum_arrays.EnumArrays
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# EnumClass
|
||||
# enum_class.EnumClass
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# EnumTest
|
||||
# enum_test.EnumTest
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
@@ -7,7 +7,7 @@ Name | Type | Description | Notes
|
||||
**enum_string** | **str** | | [optional]
|
||||
**enum_integer** | **int** | | [optional]
|
||||
**enum_number** | **float** | | [optional]
|
||||
**outer_enum** | [**OuterEnum**](OuterEnum.md) | | [optional]
|
||||
**outer_enum** | [**outer_enum.OuterEnum**](OuterEnum.md) | | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -34,17 +34,17 @@ this route creates an XmlItem
|
||||
from __future__ import print_function
|
||||
import time
|
||||
import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
xml_item = petstore_api.XmlItem() # XmlItem | XmlItem Body
|
||||
xml_item = petstore_api.XmlItem() # xml_item.XmlItem | XmlItem Body
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
try:
|
||||
# creates an XmlItem
|
||||
api_instance.create_xml_item(xml_item)
|
||||
except ApiException as e:
|
||||
except petstore_api.ApiException as e:
|
||||
print("Exception when calling FakeApi->create_xml_item: %s\n" % e)
|
||||
```
|
||||
|
||||
@@ -52,7 +52,7 @@ except ApiException as e:
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**xml_item** | [**XmlItem**](XmlItem.md)| XmlItem Body |
|
||||
**xml_item** | [**xml_item.XmlItem**](XmlItem.md)| XmlItem Body |
|
||||
|
||||
### Return type
|
||||
|
||||
@@ -87,17 +87,18 @@ Test serialization of outer boolean types
|
||||
from __future__ import print_function
|
||||
import time
|
||||
import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
body = True # bool | Input boolean as post body (optional)
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
# and optional values
|
||||
try:
|
||||
api_response = api_instance.fake_outer_boolean_serialize(body=body)
|
||||
pprint(api_response)
|
||||
except ApiException as e:
|
||||
except petstore_api.ApiException as e:
|
||||
print("Exception when calling FakeApi->fake_outer_boolean_serialize: %s\n" % e)
|
||||
```
|
||||
|
||||
@@ -128,7 +129,7 @@ No authorization required
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **fake_outer_composite_serialize**
|
||||
> OuterComposite fake_outer_composite_serialize()
|
||||
> outer_composite.OuterComposite fake_outer_composite_serialize()
|
||||
|
||||
|
||||
|
||||
@@ -140,17 +141,18 @@ Test serialization of object with outer number type
|
||||
from __future__ import print_function
|
||||
import time
|
||||
import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
body = petstore_api.OuterComposite() # OuterComposite | Input composite as post body (optional)
|
||||
body = petstore_api.OuterComposite() # outer_composite.OuterComposite | Input composite as post body (optional)
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
# and optional values
|
||||
try:
|
||||
api_response = api_instance.fake_outer_composite_serialize(body=body)
|
||||
pprint(api_response)
|
||||
except ApiException as e:
|
||||
except petstore_api.ApiException as e:
|
||||
print("Exception when calling FakeApi->fake_outer_composite_serialize: %s\n" % e)
|
||||
```
|
||||
|
||||
@@ -158,11 +160,11 @@ except ApiException as e:
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | [**OuterComposite**](OuterComposite.md)| Input composite as post body | [optional]
|
||||
**body** | [**outer_composite.OuterComposite**](OuterComposite.md)| Input composite as post body | [optional]
|
||||
|
||||
### Return type
|
||||
|
||||
[**OuterComposite**](OuterComposite.md)
|
||||
[**outer_composite.OuterComposite**](OuterComposite.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
@@ -181,7 +183,7 @@ No authorization required
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **fake_outer_enum_serialize**
|
||||
> OuterEnum fake_outer_enum_serialize()
|
||||
> outer_enum.OuterEnum fake_outer_enum_serialize()
|
||||
|
||||
|
||||
|
||||
@@ -193,17 +195,18 @@ Test serialization of outer enum
|
||||
from __future__ import print_function
|
||||
import time
|
||||
import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
body = OuterEnum("placed") # OuterEnum | Input enum as post body (optional)
|
||||
body = petstore_api.OuterEnum("placed") # outer_enum.OuterEnum | Input enum as post body (optional)
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
# and optional values
|
||||
try:
|
||||
api_response = api_instance.fake_outer_enum_serialize(body=body)
|
||||
pprint(api_response)
|
||||
except ApiException as e:
|
||||
except petstore_api.ApiException as e:
|
||||
print("Exception when calling FakeApi->fake_outer_enum_serialize: %s\n" % e)
|
||||
```
|
||||
|
||||
@@ -211,11 +214,11 @@ except ApiException as e:
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | [**OuterEnum**](str.md)| Input enum as post body | [optional]
|
||||
**body** | [**outer_enum.OuterEnum**](OuterEnum.md)| Input enum as post body | [optional]
|
||||
|
||||
### Return type
|
||||
|
||||
[**OuterEnum**](OuterEnum.md)
|
||||
[**outer_enum.OuterEnum**](OuterEnum.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
@@ -234,7 +237,7 @@ No authorization required
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **fake_outer_number_serialize**
|
||||
> OuterNumber fake_outer_number_serialize()
|
||||
> outer_number.OuterNumber fake_outer_number_serialize()
|
||||
|
||||
|
||||
|
||||
@@ -246,17 +249,18 @@ Test serialization of outer number types
|
||||
from __future__ import print_function
|
||||
import time
|
||||
import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
body = OuterNumber(3.4) # OuterNumber | Input number as post body (optional)
|
||||
body = petstore_api.OuterNumber(3.4) # outer_number.OuterNumber | Input number as post body (optional)
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
# and optional values
|
||||
try:
|
||||
api_response = api_instance.fake_outer_number_serialize(body=body)
|
||||
pprint(api_response)
|
||||
except ApiException as e:
|
||||
except petstore_api.ApiException as e:
|
||||
print("Exception when calling FakeApi->fake_outer_number_serialize: %s\n" % e)
|
||||
```
|
||||
|
||||
@@ -264,11 +268,11 @@ except ApiException as e:
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | [**OuterNumber**](float.md)| Input number as post body | [optional]
|
||||
**body** | [**outer_number.OuterNumber**](OuterNumber.md)| Input number as post body | [optional]
|
||||
|
||||
### Return type
|
||||
|
||||
[**OuterNumber**](OuterNumber.md)
|
||||
[**outer_number.OuterNumber**](OuterNumber.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
@@ -299,17 +303,18 @@ Test serialization of outer string types
|
||||
from __future__ import print_function
|
||||
import time
|
||||
import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
body = 'body_example' # str | Input string as post body (optional)
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
# and optional values
|
||||
try:
|
||||
api_response = api_instance.fake_outer_string_serialize(body=body)
|
||||
pprint(api_response)
|
||||
except ApiException as e:
|
||||
except petstore_api.ApiException as e:
|
||||
print("Exception when calling FakeApi->fake_outer_string_serialize: %s\n" % e)
|
||||
```
|
||||
|
||||
@@ -352,16 +357,16 @@ For this test, the body for this request much reference a schema named `File`.
|
||||
from __future__ import print_function
|
||||
import time
|
||||
import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
body = petstore_api.FileSchemaTestClass() # FileSchemaTestClass |
|
||||
body = petstore_api.FileSchemaTestClass() # file_schema_test_class.FileSchemaTestClass |
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
try:
|
||||
api_instance.test_body_with_file_schema(body)
|
||||
except ApiException as e:
|
||||
except petstore_api.ApiException as e:
|
||||
print("Exception when calling FakeApi->test_body_with_file_schema: %s\n" % e)
|
||||
```
|
||||
|
||||
@@ -369,7 +374,7 @@ except ApiException as e:
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | [**FileSchemaTestClass**](FileSchemaTestClass.md)| |
|
||||
**body** | [**file_schema_test_class.FileSchemaTestClass**](FileSchemaTestClass.md)| |
|
||||
|
||||
### Return type
|
||||
|
||||
@@ -402,17 +407,17 @@ No authorization required
|
||||
from __future__ import print_function
|
||||
import time
|
||||
import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
query = 'query_example' # str |
|
||||
body = petstore_api.User() # User |
|
||||
body = petstore_api.User() # user.User |
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
try:
|
||||
api_instance.test_body_with_query_params(query, body)
|
||||
except ApiException as e:
|
||||
except petstore_api.ApiException as e:
|
||||
print("Exception when calling FakeApi->test_body_with_query_params: %s\n" % e)
|
||||
```
|
||||
|
||||
@@ -421,7 +426,7 @@ except ApiException as e:
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**query** | **str**| |
|
||||
**body** | [**User**](User.md)| |
|
||||
**body** | [**user.User**](User.md)| |
|
||||
|
||||
### Return type
|
||||
|
||||
@@ -444,7 +449,7 @@ No authorization required
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **test_client_model**
|
||||
> Client test_client_model(body)
|
||||
> client.Client test_client_model(body)
|
||||
|
||||
To test \"client\" model
|
||||
|
||||
@@ -456,18 +461,18 @@ To test \"client\" model
|
||||
from __future__ import print_function
|
||||
import time
|
||||
import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
body = petstore_api.Client() # Client | client model
|
||||
body = petstore_api.Client() # client.Client | client model
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
try:
|
||||
# To test \"client\" model
|
||||
api_response = api_instance.test_client_model(body)
|
||||
pprint(api_response)
|
||||
except ApiException as e:
|
||||
except petstore_api.ApiException as e:
|
||||
print("Exception when calling FakeApi->test_client_model: %s\n" % e)
|
||||
```
|
||||
|
||||
@@ -475,11 +480,11 @@ except ApiException as e:
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | [**Client**](Client.md)| client model |
|
||||
**body** | [**client.Client**](Client.md)| client model |
|
||||
|
||||
### Return type
|
||||
|
||||
[**Client**](Client.md)
|
||||
[**client.Client**](Client.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
@@ -510,20 +515,15 @@ This route has required values with enums of 1
|
||||
from __future__ import print_function
|
||||
import time
|
||||
import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
query_integer = 3 # int | (default to 3)
|
||||
query_string = 'brillig' # str | (default to 'brillig')
|
||||
path_string = 'hello' # str | (default to 'hello')
|
||||
path_integer = 34 # int | (default to 34)
|
||||
header_number = 1.234 # float | (default to 1.234)
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
try:
|
||||
api_instance.test_endpoint_enums_length_one(query_integer, query_string, path_string, path_integer, header_number)
|
||||
except ApiException as e:
|
||||
api_instance.test_endpoint_enums_length_one()
|
||||
except petstore_api.ApiException as e:
|
||||
print("Exception when calling FakeApi->test_endpoint_enums_length_one: %s\n" % e)
|
||||
```
|
||||
|
||||
@@ -571,7 +571,6 @@ Fake endpoint for testing various parameters 假端點 偽のエンドポイン
|
||||
from __future__ import print_function
|
||||
import time
|
||||
import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
configuration = petstore_api.Configuration()
|
||||
# Configure HTTP basic authorization: http_basic_test
|
||||
@@ -597,10 +596,19 @@ date_time = '2013-10-20T19:20:30+01:00' # datetime | None (optional)
|
||||
password = 'password_example' # str | None (optional)
|
||||
param_callback = 'param_callback_example' # str | None (optional)
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
try:
|
||||
# Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
api_instance.test_endpoint_parameters(number, double, pattern_without_delimiter, byte)
|
||||
except petstore_api.ApiException as e:
|
||||
print("Exception when calling FakeApi->test_endpoint_parameters: %s\n" % e)
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
# and optional values
|
||||
try:
|
||||
# Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
api_instance.test_endpoint_parameters(number, double, pattern_without_delimiter, byte, integer=integer, int32=int32, int64=int64, float=float, string=string, binary=binary, date=date, date_time=date_time, password=password, param_callback=param_callback)
|
||||
except ApiException as e:
|
||||
except petstore_api.ApiException as e:
|
||||
print("Exception when calling FakeApi->test_endpoint_parameters: %s\n" % e)
|
||||
```
|
||||
|
||||
@@ -657,24 +665,25 @@ To test enum parameters
|
||||
from __future__ import print_function
|
||||
import time
|
||||
import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
enum_header_string_array = ['enum_header_string_array_example'] # [str] | Header parameter enum test (string array) (optional)
|
||||
enum_header_string = '-efg' # str | Header parameter enum test (string) (optional) (default to '-efg')
|
||||
enum_header_string = '-efg' # str | Header parameter enum test (string) (optional) if omitted the server will use the default value of '-efg'
|
||||
enum_query_string_array = ['enum_query_string_array_example'] # [str] | Query parameter enum test (string array) (optional)
|
||||
enum_query_string = '-efg' # str | Query parameter enum test (string) (optional) (default to '-efg')
|
||||
enum_query_string = '-efg' # str | Query parameter enum test (string) (optional) if omitted the server will use the default value of '-efg'
|
||||
enum_query_integer = 56 # int | Query parameter enum test (double) (optional)
|
||||
enum_query_double = 3.4 # float | Query parameter enum test (double) (optional)
|
||||
enum_form_string_array = '$' # [str] | Form parameter enum test (string array) (optional) (default to '$')
|
||||
enum_form_string = '-efg' # str | Form parameter enum test (string) (optional) (default to '-efg')
|
||||
enum_form_string_array = '$' # [str] | Form parameter enum test (string array) (optional) if omitted the server will use the default value of '$'
|
||||
enum_form_string = '-efg' # str | Form parameter enum test (string) (optional) if omitted the server will use the default value of '-efg'
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
# and optional values
|
||||
try:
|
||||
# To test enum parameters
|
||||
api_instance.test_enum_parameters(enum_header_string_array=enum_header_string_array, enum_header_string=enum_header_string, enum_query_string_array=enum_query_string_array, enum_query_string=enum_query_string, enum_query_integer=enum_query_integer, enum_query_double=enum_query_double, enum_form_string_array=enum_form_string_array, enum_form_string=enum_form_string)
|
||||
except ApiException as e:
|
||||
except petstore_api.ApiException as e:
|
||||
print("Exception when calling FakeApi->test_enum_parameters: %s\n" % e)
|
||||
```
|
||||
|
||||
@@ -682,13 +691,13 @@ except ApiException as e:
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**enum_header_string_array** | [**[str]**](str.md)| Header parameter enum test (string array) | [optional]
|
||||
**enum_header_string_array** | **[str]**| Header parameter enum test (string array) | [optional]
|
||||
**enum_header_string** | **str**| Header parameter enum test (string) | [optional] if omitted the server will use the default value of '-efg'
|
||||
**enum_query_string_array** | [**[str]**](str.md)| Query parameter enum test (string array) | [optional]
|
||||
**enum_query_string_array** | **[str]**| Query parameter enum test (string array) | [optional]
|
||||
**enum_query_string** | **str**| Query parameter enum test (string) | [optional] if omitted the server will use the default value of '-efg'
|
||||
**enum_query_integer** | **int**| Query parameter enum test (double) | [optional]
|
||||
**enum_query_double** | **float**| Query parameter enum test (double) | [optional]
|
||||
**enum_form_string_array** | [**[str]**](str.md)| Form parameter enum test (string array) | [optional] if omitted the server will use the default value of '$'
|
||||
**enum_form_string_array** | **[str]**| Form parameter enum test (string array) | [optional] if omitted the server will use the default value of '$'
|
||||
**enum_form_string** | **str**| Form parameter enum test (string) | [optional] if omitted the server will use the default value of '-efg'
|
||||
|
||||
### Return type
|
||||
@@ -725,7 +734,6 @@ Fake endpoint to test group parameters (optional)
|
||||
from __future__ import print_function
|
||||
import time
|
||||
import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Create an instance of the API class
|
||||
@@ -737,10 +745,19 @@ string_group = 56 # int | String in group parameters (optional)
|
||||
boolean_group = True # bool | Boolean in group parameters (optional)
|
||||
int64_group = 56 # int | Integer in group parameters (optional)
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
try:
|
||||
# Fake endpoint to test group parameters (optional)
|
||||
api_instance.test_group_parameters(required_string_group, required_boolean_group, required_int64_group)
|
||||
except petstore_api.ApiException as e:
|
||||
print("Exception when calling FakeApi->test_group_parameters: %s\n" % e)
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
# and optional values
|
||||
try:
|
||||
# Fake endpoint to test group parameters (optional)
|
||||
api_instance.test_group_parameters(required_string_group, required_boolean_group, required_int64_group, string_group=string_group, boolean_group=boolean_group, int64_group=int64_group)
|
||||
except ApiException as e:
|
||||
except petstore_api.ApiException as e:
|
||||
print("Exception when calling FakeApi->test_group_parameters: %s\n" % e)
|
||||
```
|
||||
|
||||
@@ -786,17 +803,17 @@ test inline additionalProperties
|
||||
from __future__ import print_function
|
||||
import time
|
||||
import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
param = {'key': 'param_example'} # {str: (str,)} | request body
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
try:
|
||||
# test inline additionalProperties
|
||||
api_instance.test_inline_additional_properties(param)
|
||||
except ApiException as e:
|
||||
except petstore_api.ApiException as e:
|
||||
print("Exception when calling FakeApi->test_inline_additional_properties: %s\n" % e)
|
||||
```
|
||||
|
||||
@@ -804,7 +821,7 @@ except ApiException as e:
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**param** | [**{str: (str,)}**](str.md)| request body |
|
||||
**param** | **{str: (str,)}**| request body |
|
||||
|
||||
### Return type
|
||||
|
||||
@@ -837,7 +854,6 @@ test json serialization of form data
|
||||
from __future__ import print_function
|
||||
import time
|
||||
import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Create an instance of the API class
|
||||
@@ -845,10 +861,11 @@ api_instance = petstore_api.FakeApi()
|
||||
param = 'param_example' # str | field1
|
||||
param2 = 'param2_example' # str | field2
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
try:
|
||||
# test json serialization of form data
|
||||
api_instance.test_json_form_data(param, param2)
|
||||
except ApiException as e:
|
||||
except petstore_api.ApiException as e:
|
||||
print("Exception when calling FakeApi->test_json_form_data: %s\n" % e)
|
||||
```
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ Method | HTTP request | Description
|
||||
|
||||
|
||||
# **test_classname**
|
||||
> Client test_classname(body)
|
||||
> client.Client test_classname(body)
|
||||
|
||||
To test class name in snake case
|
||||
|
||||
@@ -21,7 +21,6 @@ To test class name in snake case
|
||||
from __future__ import print_function
|
||||
import time
|
||||
import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
configuration = petstore_api.Configuration()
|
||||
# Configure API key authorization: api_key_query
|
||||
@@ -33,13 +32,14 @@ configuration.api_key['api_key_query'] = 'YOUR_API_KEY'
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeClassnameTags123Api(petstore_api.ApiClient(configuration))
|
||||
body = petstore_api.Client() # Client | client model
|
||||
body = petstore_api.Client() # client.Client | client model
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
try:
|
||||
# To test class name in snake case
|
||||
api_response = api_instance.test_classname(body)
|
||||
pprint(api_response)
|
||||
except ApiException as e:
|
||||
except petstore_api.ApiException as e:
|
||||
print("Exception when calling FakeClassnameTags123Api->test_classname: %s\n" % e)
|
||||
```
|
||||
|
||||
@@ -47,11 +47,11 @@ except ApiException as e:
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | [**Client**](Client.md)| client model |
|
||||
**body** | [**client.Client**](Client.md)| client model |
|
||||
|
||||
### Return type
|
||||
|
||||
[**Client**](Client.md)
|
||||
[**client.Client**](Client.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# File
|
||||
# file.File
|
||||
|
||||
Must be named `File` for test.
|
||||
## Properties
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
# FileSchemaTestClass
|
||||
# file_schema_test_class.FileSchemaTestClass
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**file** | [**File**](File.md) | | [optional]
|
||||
**files** | [**[File]**](File.md) | | [optional]
|
||||
**file** | [**file.File**](File.md) | | [optional]
|
||||
**files** | [**[file.File]**](File.md) | | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# FormatTest
|
||||
# format_test.FormatTest
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
# grandparent.Grandparent
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**radio_waves** | **bool** | | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
# grandparent_animal.GrandparentAnimal
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**pet_type** | **str** | |
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# HasOnlyReadOnly
|
||||
# has_only_read_only.HasOnlyReadOnly
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# List
|
||||
# list.List
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# MapTest
|
||||
# map_test.MapTest
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
@@ -6,7 +6,7 @@ Name | Type | Description | Notes
|
||||
**map_map_of_string** | **{str: ({str: (str,)},)}** | | [optional]
|
||||
**map_of_enum_string** | **{str: (str,)}** | | [optional]
|
||||
**direct_map** | **{str: (bool,)}** | | [optional]
|
||||
**indirect_map** | [**StringBooleanMap**](StringBooleanMap.md) | | [optional]
|
||||
**indirect_map** | [**string_boolean_map.StringBooleanMap**](StringBooleanMap.md) | | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
# MixedPropertiesAndAdditionalPropertiesClass
|
||||
# mixed_properties_and_additional_properties_class.MixedPropertiesAndAdditionalPropertiesClass
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**uuid** | **str** | | [optional]
|
||||
**date_time** | **datetime** | | [optional]
|
||||
**map** | [**{str: (Animal,)}**](Animal.md) | | [optional]
|
||||
**map** | [**{str: (animal.Animal,)}**](Animal.md) | | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Model200Response
|
||||
# model200_response.Model200Response
|
||||
|
||||
Model for testing model name starting with number
|
||||
## Properties
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# ModelReturn
|
||||
# model_return.ModelReturn
|
||||
|
||||
Model for testing reserved words
|
||||
## Properties
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Name
|
||||
# name.Name
|
||||
|
||||
Model for testing model name same as property name
|
||||
## Properties
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# NumberOnly
|
||||
# number_only.NumberOnly
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Order
|
||||
# order.Order
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
# OuterComposite
|
||||
# outer_composite.OuterComposite
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**my_number** | [**OuterNumber**](OuterNumber.md) | | [optional]
|
||||
**my_number** | [**outer_number.OuterNumber**](OuterNumber.md) | | [optional]
|
||||
**my_string** | **str** | | [optional]
|
||||
**my_boolean** | **bool** | | [optional]
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# OuterEnum
|
||||
# outer_enum.OuterEnum
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# OuterNumber
|
||||
# outer_number.OuterNumber
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
|
||||
11
samples/client/petstore/python-experimental/docs/Parent.md
Normal file
11
samples/client/petstore/python-experimental/docs/Parent.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# parent.Parent
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**radio_waves** | **bool** | | [optional]
|
||||
**tele_vision** | **bool** | | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
# parent_all_of.ParentAllOf
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**tele_vision** | **bool** | | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
# parent_pet.ParentPet
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**pet_type** | **str** | |
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Pet
|
||||
# pet.Pet
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
@@ -6,8 +6,8 @@ Name | Type | Description | Notes
|
||||
**name** | **str** | |
|
||||
**photo_urls** | **[str]** | |
|
||||
**id** | **int** | | [optional]
|
||||
**category** | [**Category**](Category.md) | | [optional]
|
||||
**tags** | [**[Tag]**](Tag.md) | | [optional]
|
||||
**category** | [**category.Category**](Category.md) | | [optional]
|
||||
**tags** | [**[tag.Tag]**](Tag.md) | | [optional]
|
||||
**status** | **str** | pet status in the store | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
@@ -27,7 +27,6 @@ Add a new pet to the store
|
||||
from __future__ import print_function
|
||||
import time
|
||||
import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
configuration = petstore_api.Configuration()
|
||||
# Configure OAuth2 access token for authorization: petstore_auth
|
||||
@@ -37,12 +36,13 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
body = petstore_api.Pet() # Pet | Pet object that needs to be added to the store
|
||||
body = petstore_api.Pet() # pet.Pet | Pet object that needs to be added to the store
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
try:
|
||||
# Add a new pet to the store
|
||||
api_instance.add_pet(body)
|
||||
except ApiException as e:
|
||||
except petstore_api.ApiException as e:
|
||||
print("Exception when calling PetApi->add_pet: %s\n" % e)
|
||||
```
|
||||
|
||||
@@ -50,7 +50,7 @@ except ApiException as e:
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
|
||||
**body** | [**pet.Pet**](Pet.md)| Pet object that needs to be added to the store |
|
||||
|
||||
### Return type
|
||||
|
||||
@@ -85,7 +85,6 @@ Deletes a pet
|
||||
from __future__ import print_function
|
||||
import time
|
||||
import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
configuration = petstore_api.Configuration()
|
||||
# Configure OAuth2 access token for authorization: petstore_auth
|
||||
@@ -98,10 +97,19 @@ api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
pet_id = 56 # int | Pet id to delete
|
||||
api_key = 'api_key_example' # str | (optional)
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
try:
|
||||
# Deletes a pet
|
||||
api_instance.delete_pet(pet_id)
|
||||
except petstore_api.ApiException as e:
|
||||
print("Exception when calling PetApi->delete_pet: %s\n" % e)
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
# and optional values
|
||||
try:
|
||||
# Deletes a pet
|
||||
api_instance.delete_pet(pet_id, api_key=api_key)
|
||||
except ApiException as e:
|
||||
except petstore_api.ApiException as e:
|
||||
print("Exception when calling PetApi->delete_pet: %s\n" % e)
|
||||
```
|
||||
|
||||
@@ -134,7 +142,7 @@ void (empty response body)
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **find_pets_by_status**
|
||||
> [Pet] find_pets_by_status(status)
|
||||
> [pet.Pet] find_pets_by_status(status)
|
||||
|
||||
Finds Pets by status
|
||||
|
||||
@@ -147,7 +155,6 @@ Multiple status values can be provided with comma separated strings
|
||||
from __future__ import print_function
|
||||
import time
|
||||
import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
configuration = petstore_api.Configuration()
|
||||
# Configure OAuth2 access token for authorization: petstore_auth
|
||||
@@ -159,11 +166,12 @@ configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
status = ['status_example'] # [str] | Status values that need to be considered for filter
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
try:
|
||||
# Finds Pets by status
|
||||
api_response = api_instance.find_pets_by_status(status)
|
||||
pprint(api_response)
|
||||
except ApiException as e:
|
||||
except petstore_api.ApiException as e:
|
||||
print("Exception when calling PetApi->find_pets_by_status: %s\n" % e)
|
||||
```
|
||||
|
||||
@@ -171,11 +179,11 @@ except ApiException as e:
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**status** | [**[str]**](str.md)| Status values that need to be considered for filter |
|
||||
**status** | **[str]**| Status values that need to be considered for filter |
|
||||
|
||||
### Return type
|
||||
|
||||
[**[Pet]**](Pet.md)
|
||||
[**[pet.Pet]**](Pet.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
@@ -195,7 +203,7 @@ Name | Type | Description | Notes
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **find_pets_by_tags**
|
||||
> [Pet] find_pets_by_tags(tags)
|
||||
> [pet.Pet] find_pets_by_tags(tags)
|
||||
|
||||
Finds Pets by tags
|
||||
|
||||
@@ -208,7 +216,6 @@ Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3
|
||||
from __future__ import print_function
|
||||
import time
|
||||
import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
configuration = petstore_api.Configuration()
|
||||
# Configure OAuth2 access token for authorization: petstore_auth
|
||||
@@ -220,11 +227,12 @@ configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
tags = ['tags_example'] # [str] | Tags to filter by
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
try:
|
||||
# Finds Pets by tags
|
||||
api_response = api_instance.find_pets_by_tags(tags)
|
||||
pprint(api_response)
|
||||
except ApiException as e:
|
||||
except petstore_api.ApiException as e:
|
||||
print("Exception when calling PetApi->find_pets_by_tags: %s\n" % e)
|
||||
```
|
||||
|
||||
@@ -232,11 +240,11 @@ except ApiException as e:
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**tags** | [**[str]**](str.md)| Tags to filter by |
|
||||
**tags** | **[str]**| Tags to filter by |
|
||||
|
||||
### Return type
|
||||
|
||||
[**[Pet]**](Pet.md)
|
||||
[**[pet.Pet]**](Pet.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
@@ -256,7 +264,7 @@ Name | Type | Description | Notes
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **get_pet_by_id**
|
||||
> Pet get_pet_by_id(pet_id)
|
||||
> pet.Pet get_pet_by_id(pet_id)
|
||||
|
||||
Find pet by ID
|
||||
|
||||
@@ -269,7 +277,6 @@ Returns a single pet
|
||||
from __future__ import print_function
|
||||
import time
|
||||
import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
configuration = petstore_api.Configuration()
|
||||
# Configure API key authorization: api_key
|
||||
@@ -283,11 +290,12 @@ configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
pet_id = 56 # int | ID of pet to return
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
try:
|
||||
# Find pet by ID
|
||||
api_response = api_instance.get_pet_by_id(pet_id)
|
||||
pprint(api_response)
|
||||
except ApiException as e:
|
||||
except petstore_api.ApiException as e:
|
||||
print("Exception when calling PetApi->get_pet_by_id: %s\n" % e)
|
||||
```
|
||||
|
||||
@@ -299,7 +307,7 @@ Name | Type | Description | Notes
|
||||
|
||||
### Return type
|
||||
|
||||
[**Pet**](Pet.md)
|
||||
[**pet.Pet**](Pet.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
@@ -331,7 +339,6 @@ Update an existing pet
|
||||
from __future__ import print_function
|
||||
import time
|
||||
import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
configuration = petstore_api.Configuration()
|
||||
# Configure OAuth2 access token for authorization: petstore_auth
|
||||
@@ -341,12 +348,13 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
body = petstore_api.Pet() # Pet | Pet object that needs to be added to the store
|
||||
body = petstore_api.Pet() # pet.Pet | Pet object that needs to be added to the store
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
try:
|
||||
# Update an existing pet
|
||||
api_instance.update_pet(body)
|
||||
except ApiException as e:
|
||||
except petstore_api.ApiException as e:
|
||||
print("Exception when calling PetApi->update_pet: %s\n" % e)
|
||||
```
|
||||
|
||||
@@ -354,7 +362,7 @@ except ApiException as e:
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
|
||||
**body** | [**pet.Pet**](Pet.md)| Pet object that needs to be added to the store |
|
||||
|
||||
### Return type
|
||||
|
||||
@@ -391,7 +399,6 @@ Updates a pet in the store with form data
|
||||
from __future__ import print_function
|
||||
import time
|
||||
import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
configuration = petstore_api.Configuration()
|
||||
# Configure OAuth2 access token for authorization: petstore_auth
|
||||
@@ -405,10 +412,19 @@ pet_id = 56 # int | ID of pet that needs to be updated
|
||||
name = 'name_example' # str | Updated name of the pet (optional)
|
||||
status = 'status_example' # str | Updated status of the pet (optional)
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
try:
|
||||
# Updates a pet in the store with form data
|
||||
api_instance.update_pet_with_form(pet_id)
|
||||
except petstore_api.ApiException as e:
|
||||
print("Exception when calling PetApi->update_pet_with_form: %s\n" % e)
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
# and optional values
|
||||
try:
|
||||
# Updates a pet in the store with form data
|
||||
api_instance.update_pet_with_form(pet_id, name=name, status=status)
|
||||
except ApiException as e:
|
||||
except petstore_api.ApiException as e:
|
||||
print("Exception when calling PetApi->update_pet_with_form: %s\n" % e)
|
||||
```
|
||||
|
||||
@@ -441,7 +457,7 @@ void (empty response body)
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **upload_file**
|
||||
> ApiResponse upload_file(pet_id)
|
||||
> api_response.ApiResponse upload_file(pet_id)
|
||||
|
||||
uploads an image
|
||||
|
||||
@@ -452,7 +468,6 @@ uploads an image
|
||||
from __future__ import print_function
|
||||
import time
|
||||
import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
configuration = petstore_api.Configuration()
|
||||
# Configure OAuth2 access token for authorization: petstore_auth
|
||||
@@ -467,11 +482,21 @@ additional_metadata = 'additional_metadata_example' # str | Additional data to p
|
||||
file = open('/path/to/file', 'rb') # file_type | file to upload (optional)
|
||||
files = open('/path/to/file', 'rb') # [file_type] | files to upload (optional)
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
try:
|
||||
# uploads an image
|
||||
api_response = api_instance.upload_file(pet_id)
|
||||
pprint(api_response)
|
||||
except petstore_api.ApiException as e:
|
||||
print("Exception when calling PetApi->upload_file: %s\n" % e)
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
# and optional values
|
||||
try:
|
||||
# uploads an image
|
||||
api_response = api_instance.upload_file(pet_id, additional_metadata=additional_metadata, file=file, files=files)
|
||||
pprint(api_response)
|
||||
except ApiException as e:
|
||||
except petstore_api.ApiException as e:
|
||||
print("Exception when calling PetApi->upload_file: %s\n" % e)
|
||||
```
|
||||
|
||||
@@ -482,11 +507,11 @@ Name | Type | Description | Notes
|
||||
**pet_id** | **int**| ID of pet to update |
|
||||
**additional_metadata** | **str**| Additional data to pass to server | [optional]
|
||||
**file** | **file_type**| file to upload | [optional]
|
||||
**files** | [**[file_type]**](file_type.md)| files to upload | [optional]
|
||||
**files** | **[file_type]**| files to upload | [optional]
|
||||
|
||||
### Return type
|
||||
|
||||
[**ApiResponse**](ApiResponse.md)
|
||||
[**api_response.ApiResponse**](ApiResponse.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
@@ -505,7 +530,7 @@ Name | Type | Description | Notes
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **upload_file_with_required_file**
|
||||
> ApiResponse upload_file_with_required_file(pet_id, required_file)
|
||||
> api_response.ApiResponse upload_file_with_required_file(pet_id, required_file)
|
||||
|
||||
uploads an image (required)
|
||||
|
||||
@@ -516,7 +541,6 @@ uploads an image (required)
|
||||
from __future__ import print_function
|
||||
import time
|
||||
import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
configuration = petstore_api.Configuration()
|
||||
# Configure OAuth2 access token for authorization: petstore_auth
|
||||
@@ -530,11 +554,21 @@ pet_id = 56 # int | ID of pet to update
|
||||
required_file = open('/path/to/file', 'rb') # file_type | file to upload
|
||||
additional_metadata = 'additional_metadata_example' # str | Additional data to pass to server (optional)
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
try:
|
||||
# uploads an image (required)
|
||||
api_response = api_instance.upload_file_with_required_file(pet_id, required_file)
|
||||
pprint(api_response)
|
||||
except petstore_api.ApiException as e:
|
||||
print("Exception when calling PetApi->upload_file_with_required_file: %s\n" % e)
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
# and optional values
|
||||
try:
|
||||
# uploads an image (required)
|
||||
api_response = api_instance.upload_file_with_required_file(pet_id, required_file, additional_metadata=additional_metadata)
|
||||
pprint(api_response)
|
||||
except ApiException as e:
|
||||
except petstore_api.ApiException as e:
|
||||
print("Exception when calling PetApi->upload_file_with_required_file: %s\n" % e)
|
||||
```
|
||||
|
||||
@@ -548,7 +582,7 @@ Name | Type | Description | Notes
|
||||
|
||||
### Return type
|
||||
|
||||
[**ApiResponse**](ApiResponse.md)
|
||||
[**api_response.ApiResponse**](ApiResponse.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# ReadOnlyFirst
|
||||
# read_only_first.ReadOnlyFirst
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# SpecialModelName
|
||||
# special_model_name.SpecialModelName
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
|
||||
@@ -23,17 +23,17 @@ For valid response try integer IDs with value < 1000. Anything above 1000 or non
|
||||
from __future__ import print_function
|
||||
import time
|
||||
import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.StoreApi()
|
||||
order_id = 'order_id_example' # str | ID of the order that needs to be deleted
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
try:
|
||||
# Delete purchase order by ID
|
||||
api_instance.delete_order(order_id)
|
||||
except ApiException as e:
|
||||
except petstore_api.ApiException as e:
|
||||
print("Exception when calling StoreApi->delete_order: %s\n" % e)
|
||||
```
|
||||
|
||||
@@ -78,7 +78,6 @@ Returns a map of status codes to quantities
|
||||
from __future__ import print_function
|
||||
import time
|
||||
import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
configuration = petstore_api.Configuration()
|
||||
# Configure API key authorization: api_key
|
||||
@@ -91,11 +90,12 @@ configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.StoreApi(petstore_api.ApiClient(configuration))
|
||||
|
||||
# example, this endpoint has no required or optional parameters
|
||||
try:
|
||||
# Returns pet inventories by status
|
||||
api_response = api_instance.get_inventory()
|
||||
pprint(api_response)
|
||||
except ApiException as e:
|
||||
except petstore_api.ApiException as e:
|
||||
print("Exception when calling StoreApi->get_inventory: %s\n" % e)
|
||||
```
|
||||
|
||||
@@ -123,7 +123,7 @@ This endpoint does not need any parameter.
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **get_order_by_id**
|
||||
> Order get_order_by_id(order_id)
|
||||
> order.Order get_order_by_id(order_id)
|
||||
|
||||
Find purchase order by ID
|
||||
|
||||
@@ -135,18 +135,18 @@ For valid response try integer IDs with value <= 5 or > 10. Other values will ge
|
||||
from __future__ import print_function
|
||||
import time
|
||||
import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.StoreApi()
|
||||
order_id = 56 # int | ID of pet that needs to be fetched
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
try:
|
||||
# Find purchase order by ID
|
||||
api_response = api_instance.get_order_by_id(order_id)
|
||||
pprint(api_response)
|
||||
except ApiException as e:
|
||||
except petstore_api.ApiException as e:
|
||||
print("Exception when calling StoreApi->get_order_by_id: %s\n" % e)
|
||||
```
|
||||
|
||||
@@ -158,7 +158,7 @@ Name | Type | Description | Notes
|
||||
|
||||
### Return type
|
||||
|
||||
[**Order**](Order.md)
|
||||
[**order.Order**](Order.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
@@ -179,7 +179,7 @@ No authorization required
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **place_order**
|
||||
> Order place_order(body)
|
||||
> order.Order place_order(body)
|
||||
|
||||
Place an order for a pet
|
||||
|
||||
@@ -189,18 +189,18 @@ Place an order for a pet
|
||||
from __future__ import print_function
|
||||
import time
|
||||
import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.StoreApi()
|
||||
body = petstore_api.Order() # Order | order placed for purchasing the pet
|
||||
body = petstore_api.Order() # order.Order | order placed for purchasing the pet
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
try:
|
||||
# Place an order for a pet
|
||||
api_response = api_instance.place_order(body)
|
||||
pprint(api_response)
|
||||
except ApiException as e:
|
||||
except petstore_api.ApiException as e:
|
||||
print("Exception when calling StoreApi->place_order: %s\n" % e)
|
||||
```
|
||||
|
||||
@@ -208,11 +208,11 @@ except ApiException as e:
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | [**Order**](Order.md)| order placed for purchasing the pet |
|
||||
**body** | [**order.Order**](Order.md)| order placed for purchasing the pet |
|
||||
|
||||
### Return type
|
||||
|
||||
[**Order**](Order.md)
|
||||
[**order.Order**](Order.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# StringBooleanMap
|
||||
# string_boolean_map.StringBooleanMap
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
# Tag
|
||||
# tag.Tag
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**id** | **int** | | [optional]
|
||||
**name** | **str** | | [optional]
|
||||
**full_name** | **str** | | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user