Skip to content

[BUG] Description from unrelated query parameter assigned to field in schema #25030

Open

Description

@jg50hz

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?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

When generating typescript-angular code, it was noticed that a field in a schema got the description of a seemingly unrelated query parameter. The field is an optional, nullable string. Changing the type in any way (making it required, making it non-nullable) leads to the correct description being assigned.

Generating code for other languages had the same issue, so it sounds like it's some problem prior to actual code generation.

openapi-generator version

Tried v7.23.0, v7.24.0, v7.25.0.

OpenAPI declaration file content or url
{
  "openapi": "3.1.0",
  "info": {
    "title": "minimal example - description bug",
    "description": "-",
    "version": "0.0.0"
  },
  "paths": {
    "/book": {
      "get": {
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Book"
                }
              }
            }
          }
        }
      }
    },
    "/book-with-pages": {
      "get": {
        "parameters": [
          {
            "name": "conflicting-param",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "WRONG DESCRIPTION! (schema)"
            },
            "description": "WRONG DESCRIPTION! (parameter)"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Book"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Book": {
        "properties": {
          "broken_field": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Correct description."
          }
        },
        "title": "Book",
        "type": "object"
      }
    }
  }
}
Generation Details

No specific configuration:

docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli:v7.25.0 generate -i /local/openapi-spec-minimal.json -g typescript-angular -o /local/clientsdk

Generates in book.ts:

export interface Book { 
    /**
     * WRONG DESCRIPTION! (schema)
     */
    broken_field?: string | null;
}

Expected output:

export interface Book { 
    /**
     * Correct description.
     */
    broken_field?: string | null;
}
Related issues/PRs

I could not find any, but it might be hard to find just based on the description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions