swagger-api / swagger-api/swagger-codegen

Go generation does not exhaustively sense every kind of response JSON content-type

Open
#11,878 0 comments 0 reactions 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

The generation of the Go language APIClient's decode() method looks for application/json to recognise JSON content-type.

This doesn't represent all real-life scenarios, for example application/vnd.oracle.resource+json is a JSON payload.

Swagger-codegen version

3.0.35

Swagger declaration file content or url
...
        "responses": {
          "200": {
            "description": "Retrived record.",
            "headers": {...},
            "content": {
              "application/vnd.oracle.resource+json; type=singular": {
                "schema": {
                  "$ref": "#/components/schemas/invoice"
                }
              }
            }
          },
...

-->

Command line used for generation

swagger-codegen generate -i ./input.json -o ./generated -l go

Steps to reproduce

Just run the command line above.

Related issues/PRs
Suggest a fix/enhancement

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 APIClient decode() method generated by swagger-codegen generate -i ./input.json -o ./generated -l go, using the response content type shown in the issue to reproduce the behavior. Done means the generated client recognizes that JSON response content type during decoding.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.