swagger-api / swagger-api/swagger-codegen

[Go] Generated client code doesn't return specified error objects for non-2xx response codes

Open
#2,296 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Client: Go Enhancement: General help wanted
Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Currently the generated code (DefaultApi) does return an error code if a non-2xx HTTP condition occurs (ie an error), but it ignores what the swagger says it should produce. E.g. if the swagger states that a 404 returns a petNotFoundError object, currently the Go code generator ignores this fact.

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 by examining the generated Go client’s DefaultApi handling of non-2xx responses and how the Go code generator uses the Swagger response definitions. Reproduce the 404 case with a petNotFoundError response; done means the generated client returns the error object specified by the Swagger definition instead of only a generic error.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.