Skip to content
This repository was archived by the owner on Dec 25, 2024. It is now read-only.

v2 includes module name in ref class #63

Merged
merged 23 commits into from
Oct 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
f4aa30e
Uses new fromProperty, passes sourceJsonPath
spacether Oct 24, 2022
2bdcbe7
Samples regenerated
spacether Oct 27, 2022
67342f2
Adds toRefClass for python, updates toModelDocFilename for python
spacether Oct 27, 2022
c622bf9
Petstore regenerated, component doc filenames updated
spacether Oct 27, 2022
8432944
Self references updated
spacether Oct 27, 2022
6a534c0
Fixes readme links to models
spacether Oct 28, 2022
166a146
Fixes model doc links for self references
spacether Oct 28, 2022
a15aa91
Adds two self referenicng models
spacether Oct 28, 2022
959d812
Updates toModelImport to use refClass
spacether Oct 29, 2022
885aff3
Updates discriminator and example code to handle complexType values i…
spacether Oct 30, 2022
471c05a
Adds import generation back in
spacether Oct 30, 2022
a33d55f
Makes java variable
spacether Oct 30, 2022
496a025
Petstore regen, fixes contains check for period
spacether Oct 30, 2022
7d9bf4e
Uses complexClass in endpoint docs for inputs
spacether Oct 31, 2022
2ba8a08
Fixes tests in PythonClinteTest
spacether Oct 31, 2022
f0e7271
FIxes more java tests
spacether Oct 31, 2022
1d93abe
Fixes $refs in ObjectModelWithRefProps
spacether Oct 31, 2022
a12e1bd
Removes broken java defaultCodegen test
spacether Oct 31, 2022
9e0364f
Adds TestSelfReferencingObjectModel
spacether Oct 31, 2022
c39a468
Adds TestSelfReferencingArrayModel
spacether Oct 31, 2022
c4f5065
Fixes some java tests
spacether Oct 31, 2022
081263c
Fixes remaining java tests
spacether Oct 31, 2022
91cbf2a
Samples regenerated
spacether Oct 31, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public interface CodegenConfig {

String toModelDocFilename(String name);

String toModelImport(String name);
String toModelImport(String refClass);

Map<String, String> toModelImportMap(String name);

Expand Down Expand Up @@ -330,4 +330,6 @@ public interface CodegenConfig {
boolean getUseInlineModelResolver();

boolean getAddSuffixToDuplicateOperationNicknames();

String toRefClass(String ref, String sourceJsonPath);
}
Original file line number Diff line number Diff line change
Expand Up @@ -1214,7 +1214,8 @@ public void addDiscriminatorMappedModelsImports() {
}
for (CodegenDiscriminator.MappedModel mm : discriminator.getMappedModels()) {
if (!"".equals(mm.getModelName())) {
imports.add(mm.getModelName());
String complexType = mm.getModelName();
imports.add(complexType);
}
}
}
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -1283,26 +1283,29 @@ private ModelsMap processModels(CodegenConfig config, Map<String, Schema> defini
List<ModelMap> modelMaps = new ArrayList<>();
Set<String> allImports = new LinkedHashSet<>();
for (Map.Entry<String, Schema> definitionsEntry : definitions.entrySet()) {
String key = definitionsEntry.getKey();
String schemaName = definitionsEntry.getKey();
Schema schema = definitionsEntry.getValue();
if (schema == null)
throw new RuntimeException("schema cannot be null in processModels");
CodegenModel cm = config.fromModel(key, schema);
CodegenModel cm = config.fromModel(schemaName, schema);
ModelMap mo = new ModelMap();
mo.setModel(cm);
mo.put("importPath", config.toModelImport(cm.classname));
mo.put("importPath", config.toModelImport(config.toRefClass("#/components/schemas/"+schemaName, "")));
modelMaps.add(mo);

cm.removeSelfReferenceImport();

if (cm.imports == null || cm.imports.size() == 0) {
continue;
}
allImports.addAll(cm.imports);
}
objs.setModels(modelMaps);
Set<String> importSet = new ConcurrentSkipListSet<>();
for (String nextImport : allImports) {
String mapping = config.importMapping().get(nextImport);
if (mapping == null) {
mapping = config.toModelImport(nextImport);
mapping = nextImport;
}
if (mapping != null && !config.defaultIncludes().contains(mapping)) {
importSet.add(mapping);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,8 @@ default Set<String> getImports(boolean importContainerType, boolean importBaseTy
DefaultCodegenTest.mapParamImportInnerObject
*/
String refClass = this.getRefClass();
if (refClass != null) {
if (refClass != null && refClass.contains(".")) {
// self reference classes do not contain periods
imports.add(refClass);
}
/*
Expand All @@ -364,7 +365,8 @@ default Set<String> getImports(boolean importContainerType, boolean importBaseTy
} else {
// referenced or inline schemas
String refClass = this.getRefClass();
if (refClass != null) {
if (refClass != null && refClass.contains(".")) {
// self reference classes do not contain periods
imports.add(refClass);
}
String baseType = this.getBaseType();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1081,15 +1081,15 @@ public GeneratorLanguage generatorLanguage() {
}

@Override
protected void updateModelForObject(CodegenModel m, Schema schema) {
protected void updateModelForObject(CodegenModel m, Schema schema, String sourceJsonPath) {
/**
* we have a custom version of this function so we only set isMap to true if
* ModelUtils.isMapSchema
* In other generators, isMap is true for all type object schemas
*/
if (schema.getProperties() != null || schema.getRequired() != null && !(schema instanceof ComposedSchema)) {
// passing null to allProperties and allRequired as there's no parent
addVars(m, unaliasPropertySchema(schema.getProperties()), schema.getRequired(), null, null);
addVars(m, unaliasPropertySchema(schema.getProperties()), schema.getRequired(), null, null, sourceJsonPath);
}
if (ModelUtils.isMapSchema(schema)) {
// an object or anyType composed schema that has additionalProperties set
Expand All @@ -1103,6 +1103,6 @@ protected void updateModelForObject(CodegenModel m, Schema schema) {
}
}
// process 'additionalProperties'
setAddProps(schema, m);
setAddProps(schema, m, sourceJsonPath);
}
}
Loading