Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
5bc9540
Adds additionalproperties feature in python
spacether Feb 4, 2019
64d5444
Adds ensure-up-to-date updates
spacether Feb 4, 2019
ec73f56
Adds docstring description of the model argument inputs
spacether Feb 4, 2019
5cdfe51
Adds ensure up to date oepnapi3 python updates
spacether Feb 4, 2019
0a52027
Adds test fix
spacether Feb 4, 2019
8be21b0
Adds fix for Shippable, gives the additionalProperties CodegenParamet…
spacether Feb 4, 2019
ba7ea49
Adds function to set freeform types to string of all types
spacether Feb 7, 2019
88f8197
Adds postProcessAllModels function which processes and fixes dataType…
spacether Feb 7, 2019
0590d05
Adds models with additionalproperties of each type and model tests
spacether Feb 9, 2019
372ae60
Adds _check_type parameter to model, adds additionalproperties tests
spacether Feb 11, 2019
5b4f108
Creates utils module, adds additionalproperties map for serialization
spacether Feb 12, 2019
2e33cf1
Removes additional_properties_map, creates model_to_dict function to …
spacether Feb 13, 2019
983f570
Improves docstring for model_to_dict
spacether Feb 14, 2019
f218ed5
Adds class type definition in models
spacether Feb 17, 2019
7656756
Adds datetime and date type classes, adds general OpenApiException, r…
spacether Feb 18, 2019
7ac9285
Adds class imports to models, python generator uses dataType for docs…
spacether Feb 20, 2019
67dbb9c
Model discriminator now stores classes, adds __deserialize_model in a…
spacether Feb 22, 2019
9680dfd
Creates exceptions module, all deserialization tests in py2 except 1 …
spacether Feb 23, 2019
05fe1aa
Adds validate_and_convert_types, python 2.0 tests pass except for tes…
spacether Feb 25, 2019
e8f97fa
Adds anytype deserialization tests in python swagger client
spacether Feb 28, 2019
59b2d4c
Fixes typos
spacether Feb 28, 2019
e158601
Adds file deserialization test
spacether Mar 2, 2019
7d84ef2
Updates all v2 and v3 python samples
spacether Mar 3, 2019
b2446cf
Removes dubug flag, reverts readme, in python generator tweaks suppor…
spacether Mar 3, 2019
9e9b94e
Adds dict instantiationType back in
spacether Mar 3, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Model discriminator now stores classes, adds __deserialize_model in a…
…pi_client, tests not passing yet
  • Loading branch information
spacether committed Mar 2, 2019
commit 67dbb9c307dbe35d4d6022f1658cd3617b7eace6
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,18 @@ public void postProcessModelProperty(CodegenModel model, CodegenProperty propert
postProcessPattern(property.pattern, property.vendorExtensions);
}

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);
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);
}
}

// override with any special post-processing for all models
@SuppressWarnings({"static-method", "unchecked"})
public Map<String, Object> postProcessAllModels(Map<String, Object> objs) {
Expand All @@ -312,6 +324,14 @@ public Map<String, Object> postProcessAllModels(Map<String, Object> objs) {
CodegenModel cm = (CodegenModel) mo.get("model");
// clear out imports so we will only include full path imports
cm.imports.clear();
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);
}
}
ArrayList<List<CodegenProperty>> listOfLists= new ArrayList<List<CodegenProperty>>();
listOfLists.add(cm.allVars);
listOfLists.add(cm.requiredVars);
Expand All @@ -329,14 +349,7 @@ public Map<String, Object> postProcessAllModels(Map<String, Object> objs) {
}
}
if (otherModelName != null) {
HashMap referencedModel = (HashMap) objs.get(otherModelName);
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);
}
addModelImport(objs, cm, otherModelName);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ class {{classname}}(object):
body=body_params,
post_params=form_params,
files=local_var_files,
response_types={{#returnType}}[{{{returnType}}}]{{/returnType}}{{^returnType}}None{{/returnType}}, # noqa: E501
response_types_mixed={{#returnType}}[{{{returnType}}}]{{/returnType}}{{^returnType}}None{{/returnType}}, # noqa: E501
auth_settings=auth_settings,
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
Expand Down
Loading