Skip to content

Commit c8ac41c

Browse files
bonifaidowing328
authored andcommitted
go: add os import in case of File return type (#3996)
1 parent 775d96c commit c8ac41c

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,11 @@ public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> o
377377
boolean addedOSImport = false;
378378
boolean addedReflectImport = false;
379379
for (CodegenOperation operation : operations) {
380+
// import "os" if the operation uses files
381+
if (!addedOSImport && "*os.File".equals(operation.returnType)) {
382+
imports.add(createMapping("import", "os"));
383+
addedOSImport = true;
384+
}
380385
for (CodegenParameter param : operation.allParams) {
381386
// import "os" if the operation uses files
382387
if (!addedOSImport && "*os.File".equals(param.dataType)) {

0 commit comments

Comments
 (0)