Skip to content

[Language Agnostic] Regression between versions 2.3.1 and 2.4.5 finding some response type definitions #9885

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
twof opened this issue Nov 23, 2019 · 0 comments · May be fixed by #9891
Open

Comments

@twof
Copy link

twof commented Nov 23, 2019

Description

I can't tell which version specifically caused this regression because my project doesn't build on any versions in between 2.3.1 and 2.4.5.

Here is the spec where this occurs:

{
  "info": {
  },
  "paths": {
    "/user/email/v1": {
      "post": {
        "description": "email address",
        "operationId": "post_user_email_v1",
        "parameters": [
          {
            "description": "The future business user's email address. AdditionalProperties are allowed in order to accept utm_params",
            "in": "body",
            "name": "body",
            "required": true,
            "schema": {
              "additionalProperties": true,
              "properties": {
                "enc_email_addr": {
                  "description": "An email address",
                  "type": "string"
                },
                "utm_campaign": {
                  "description": "(Optional) The campaign of the request, provided by the deep link URL",
                  "type": "string"
                }
              },
              "required": [
                "enc_email_addr"
              ],
              "type": "object",
              "x-model": "PostUserEmailV1_RequestData"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A successful request will return a email address",
            "examples": {
              "application/json": {
                "email": "[email protected]"
              }
            },
            "schema": {
              "additionalProperties": false,
              "properties": {
                "email": {
                  "description": "Email address",
                  "type": "string"
                }
              },
              "required": [
                "email"
              ],
              "type": "object",
              "x-model": "PostUserEmailV1_ResponseData"
            }
          },
          "default": {
            "description": "Error response",
            "schema": {
              "$ref": "#/definitions/ErrorResponse"
            }
          }
        }
      }
    }
  },
  "produces": [
    "application/json"
  ],
  "schemes": [
    "http"
  ],
  "swagger": "2.0"
}

With the above example, the following are the contents of allDefinitions in fromModel(name: String, model: Model, allDefinitions: MutableMap<String, Model>?): CodegenModel
2.3.1:
The request parameters model
The response parameters model
2.4.5:
The request parameters model

Removing "additionalProperties": false, from the response schema "solves" the problem. This of course isn't a real solution, but it gets the response model included in allDefinitions.

Swagger-codegen version

2.3.1 is the last working version. This bug still exists in 3.0.14. It was introduced some time between 2.3.1 and 2.4.5. It is a regression as far as I can tell.

Swagger declaration file content or url

See json above

Command line used for generation

We're using custom tooling on top of swagger-codegen. I can try and figure out what command ends up getting used if it would be helpful though.

Steps to reproduce

See above

Related issues/PRs

Similar issue from May. My issue adds the additional information that this behavior is a regression and which versions it may have been introduced in.
#9262

Suggest a fix/enhancement

See linked issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant