swagger-api / swagger-api/swagger-codegen

[Go] generated client packages are subject to linting

Open
#11,280 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

When running golang linter, it will complain about generated code. I would expect linter to be muted. It turns out that partial_header.mustache is very old, and does not contain proper comment in header section.

Swagger-codegen version

Latest

Swagger declaration file content or url
Command line used for generation

swagger-codegen generate -i ./api.json -l go -o ./tmp

Steps to reproduce
  1. Generate any API client
  2. Run golang linter
Related issues/PRs
Suggest a fix/enhancement

Proper template can be taken from here

The culprit is that generated header comment needs to contain line: Code generated by

As a workaround people can create their own partial_header.mustache and put it to directory that is passed to -t argument for swagger-codegen

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Go generator's partial_header.mustache template and compare it with the OpenAPI Generator template linked in the issue. Generate an API client using the provided command, then run a Go linter against the generated package. Done means the generated header contains the required Code generated by comment and the linter no longer reports generated files.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.