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-axios] Schema with oneOf is processed incorrectly #18999

Open
5 of 6 tasks
turtton opened this issue Jun 23, 2024 · 0 comments
Open
5 of 6 tasks

[BUG][typescript-axios] Schema with oneOf is processed incorrectly #18999

turtton opened this issue Jun 23, 2024 · 0 comments

Comments

@turtton
Copy link

turtton commented Jun 23, 2024

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 oneOf to represent a tuple, the process of inserting the value as a query is incorrect.

Please see this repository:
https://github.com/turtton/openapi-generator-bug-reproduction

openapi-generator version

7.6.0

OpenAPI declaration file content or url
components:
  schemas:
    Id:
      type: integer
      format: int32
    CreatedAt:
      type: string
      format: date-time
    Cursor:
      oneOf:
        - $ref: '#/components/schemas/Id'
        - $ref: '#/components/schemas/CreatedAt'

Full code
https://github.com/turtton/openapi-generator-bug-reproduction/blob/main/api.yaml

Generation Details

Type

export type Cursor = number | string;
if (cursor !== undefined) {
	for (const [key, value] of Object.entries(cursor)) { // Object.entries always returns empty array
		localVarQueryParameter[key] = value;
	}
}

expected(~7.0.0):

if (cursor !== undefined) {
	localVarQueryParameter['cursor'] = cursor;
}
Steps to reproduce
  1. clone https://github.com/turtton/openapi-generator-bug-reproduction
  2. run ./gen-latest and see generated-latest/api.ts
    or corepack enable && pnpm i && pnpm openapi-generator-cli generate and see generated76/api.ts
Related issues/PRs

#17335

#16898

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