Skip to content
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

[BUG] [typescript-fetch] anyOf with "number" and "string" leads to empty Interface #19155

Open
5 of 6 tasks
dankgen-tobias opened this issue Jul 13, 2024 · 0 comments
Open
5 of 6 tasks

Comments

@dankgen-tobias
Copy link

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • 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 using openapi-generator on an openapi.json that inluced anyOf with number and string, the resulting typescript schema is incorrect.

"PostsSchema": {
                "properties": {
                    "content": {
                        "anyOf": [
                            {
                                "type": "number"
                            },
                            {
                                "type": "string"
                            }
                        ],
                        "title": "Content"
                    }
                },
                "title": "PostsSchema",
                "type": "object"
            }

leads to

export interface Content {
}
export interface PostsSchema {
    /**
     * 
     * @type {Content}
     * @memberof PostsSchema
     */
    content?: Content;
}

but it should be content?: number | string; Content should not be an interface I think?.

openapi-generator version

v7.7.0
(https://github.com/OpenAPITools/openapi-generator/releases/tag/v7.7.0)

OpenAPI declaration file content or url

openapi.json

Generation Details
docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli:v7.7.0 generate -i /local/openapi.json -g typescript-fetch -o /local/out/ts
Steps to reproduce
  1. put openapi.json into directory
  2. execute cli command above
  3. check ./out/ts/models/PostsSchema.ts and Content.ts

for reference here are the files I get:
PostsSchema.ts
Content.ts

Related issues/PRs
Suggest a fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant