Skip to content

Commit

Permalink
fix class names in builder functions
Browse files Browse the repository at this point in the history
  • Loading branch information
aallam committed May 2, 2023
1 parent 0549175 commit ca1f41d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ private static void jsonParent(Map<String, ModelsMap> models) {
}
}

private static void modelsOneOf(Map<String, ModelsMap> models) {
private void modelsOneOf(Map<String, ModelsMap> models) {
for (ModelsMap modelContainer : models.values()) {
// modelContainers always have 1 and only 1 model in our specs
CodegenModel model = modelContainer.getModels().get(0).getModel();
Expand Down Expand Up @@ -228,6 +228,8 @@ private static void modelsOneOf(Map<String, ModelsMap> models) {
if (modelsMap != null) {
CodegenModel compoundModel = modelsMap.getModels().get(0).getModel();
compoundModel.vendorExtensions.put("x-one-of-explicit-name", compoundModel.classname);
compoundModel.vendorExtensions.put("x-fully-qualified-classname", modelPackage + "." + compoundModel.classname);
compoundModel.vendorExtensions.put("x-classname-or-alias", compoundModel.classname + "Impl");
sealedChilds.add(compoundModel);
} else {
CodegenModel newModel = new CodegenModel();
Expand All @@ -239,6 +241,7 @@ private static void modelsOneOf(Map<String, ModelsMap> models) {
property.setDatatypeWithEnum(oneOf);
newModel.setVars(Collections.singletonList(property));
newModel.vendorExtensions.put("x-one-of-explicit-name", oneOf.replace("<", "Of").replace(">", ""));
newModel.vendorExtensions.put("x-fully-qualified-classname", newModel.classname);
sealedChilds.add(newModel);
}
}
Expand Down
2 changes: 1 addition & 1 deletion templates/kotlin/builder_function.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
{{#vars}}
{{{name}}}: {{>data_class_field_type}}{{^required}}? = null{{/required}},
{{/vars}}
): {{classname}} = {{classname}} (
): {{classname}} = {{vendorExtensions.x-fully-qualified-classname}} (
{{#vars}}
{{{name}}} = {{{name}}},
{{/vars}}
Expand Down
3 changes: 3 additions & 0 deletions templates/kotlin/oneof_imports_alias.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{#vendorExtensions.x-sealed-childs}}
{{#vendorExtensions.x-fully-qualified-classname}}import {{.}} as {{vendorExtensions.x-classname-or-alias}}{{/vendorExtensions.x-fully-qualified-classname}}
{{/vendorExtensions.x-sealed-childs}}

0 comments on commit ca1f41d

Please sign in to comment.