OpenAPITools / OpenAPITools/openapi-generator

[BUG] [GO] Client does not allow unknown fields in response meaning additions to APIs break clients

Open
#21,446 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Bug Report Checklist
  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator?
  • 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?
    make the json serialisation of responses more permissive
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

wherever deserialisation is performed, option DisallowUnknownFields is set https://github.com/OpenAPITools/openapi-generator/blob/5eb083e5ce1dd99659fadc03d7c6e809d3077af6/modules/openapi-generator/src/main/resources/go-server/controller-api.mustache#L616. This means that if an API is being extended on a server and fields are added. Although this should not be a breaking change, this leads to all clients failing parsing server responses.

Suggest a fix

Either add an option to be strict or not about the schema or be more permissive and remove the DisallowUnknownFields when parsing responses

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 at modules/openapi-generator/src/main/resources/go-server/controller-api.mustache near line 616 and inspect where response deserialization uses DisallowUnknownFields. Review the surrounding generated Go response parsing, then reproduce an API response containing an added field. Done means generated clients no longer fail on unknown response fields, or the behavior is controlled by a documented strictness option.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.