Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #11097
Closed
Open
Issue created Dec 13, 2021 by Administrator@rootContributor0 of 1 checklist item completed0/1 checklist item

[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

Assignee
Assign to
Time tracking