swagger-api / swagger-api/swagger-codegen

[All] spec 1.2 doesn't WARN or ERROR on invalid template

Open
#6,832 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
Swagger-codegen version

v2.2.3

Swagger declaration file content or url
{   "apiVersion": "0.1",
    "apis": [
        { "operations": [{"method": "GET", "nickname": "testGet"} ],
          "path": "/test"
        }
    ],
    "models": {
        "MyError": {
            "properties": {
                "fields": {
                    "description": ["Arrays in the description seems to break the generator"],
                    "type": "object"
                }
            }
        }
    },
    "resourcePath": "/test",
    "swaggerVersion": "1.2"
}
Command line used for generation
swagger-codegen generate -i bareminimum.json -o bm1 -l go
Steps to reproduce
  1. Run the command
  2. Notice that it does not generate a my_error.go class nor does it throw a warning or an error
  3. Change the "description" value to a string
  4. Rerun the command
  5. Notice that it does generate a my_error.go class
Related issues/PRs

I closed #6811 and opened this, more general, issue. This issue seems similar to #5312 in that it is a parsing error with 1.2 spec.

Suggest a fix/enhancement

I suspect that the 1.2 spec parsing is swallowing errors/warnings somewhere. It would be great to expose these messages so that offending spec files can be more easily corrected.

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 running swagger-codegen generate -i bareminimum.json -o bm1 -l go with the supplied Swagger 1.2 declaration and compare it with the version whose description is a string. Trace the 1.2 parsing and template-generation path for how the invalid array value is handled; done means the invalid template produces a visible warning or error instead of silently omitting my_error.go.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.