[BUG][GO] go-server generates api-files with unused imports
Created by: feech
Bug Report Checklist
- [+] Have you provided a full/minimal spec to reproduce the issue?
- [+] Have you validated the input using an OpenAPI validator (example)?
- [+] Have you tested with the latest master to confirm the issue still exists?
- [+] Have you searched for related issues/PRs?
- [+] What's the actual output vs expected output?
-
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
if api does not include path-parameters files "api_***.go" includes unused imports: "encoding/json" and "github.com/go-chi/chi/v5" or "github.com/gorilla/mux" (depends on selected routed)
if you remove these unused imports generated project can be compiled
openapi-generator version
5.3.0
OpenAPI declaration file content or url
https://app.swaggerhub.com/apis/acceleratedlife/alife/1.0.0
Generation Details
java -jar ./openapi-generator-cli-5.3.0.jar generate -i acceleratedLife-1.0.0-resolved.json -g go-server -o path\
Steps to reproduce
once code generated need to populate package-name in main.go and run 'go build'
compiler will show the errors:
go\api_users.go:14:2: imported and not used: "encoding/json"
go\api_users.go:18:2: imported and not used: "github.com/go-chi/chi/v5" as chi
Related issues/PRs
Suggest a fix
change a template: https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/go-server/controller-api.mustache