Skip to content

Commit 4c5785d

Browse files
author
Slavek Kabrda
authored
[go-experimental] Fix nullable support (#5414)
* Fix nullable support in go-experimental client * Fix support for models with parents and container fields * Make sure that oneOf interfaces serialize properly even if they're required (non-pointers) on other models * Spaces => tabs * Regenerate samples * Make some methods of nullables pointer-receivers, add tests * Improve the Get/Set logic to make usage more convenient * Address review
1 parent 9d96ab0 commit 4c5785d

File tree

194 files changed

+8998
-5946
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

194 files changed

+8998
-5946
lines changed

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/GoClientExperimentalCodegen.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,11 @@ public CodegenProperty fromProperty(String name, Schema p) {
151151

152152
@Override
153153
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
154+
// The superclass determines the list of required golang imports. The actual list of imports
155+
// depends on which types are used, some of which are changed in the code below (but then preserved
156+
// and used through x-basetype in templates). So super.postProcessModels
157+
// must be invoked at the beginning of this method.
158+
objs = super.postProcessModels(objs);
154159

155160
List<Map<String, Object>> models = (List<Map<String, Object>>) objs.get("models");
156161
for (Map<String, Object> m : models) {
@@ -162,6 +167,7 @@ public Map<String, Object> postProcessModels(Map<String, Object> objs) {
162167
}
163168

164169
for (CodegenProperty param : model.vars) {
170+
param.vendorExtensions.put("x-basetype", param.dataType);
165171
if (!param.isNullable || param.isMapContainer || param.isListContainer) {
166172
continue;
167173
}
@@ -178,11 +184,6 @@ public Map<String, Object> postProcessModels(Map<String, Object> objs) {
178184
}
179185
}
180186
}
181-
182-
// The superclass determines the list of required golang imports. The actual list of imports
183-
// depends on which types are used, which is done in the code above. So super.postProcessModels
184-
// must be invoked at the end of this method.
185-
objs = super.postProcessModels(objs);
186187
return objs;
187188
}
188189

0 commit comments

Comments
 (0)