openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

[BUG] [typescript-fetch] Broken files when mixing basic types and refs in oneOf

Open GregoryMerlet opened this issue 1 year ago • 0 comments

Description

When using basic types in a oneOf the generated code is importing the basic type like this:

Actual:
import type { TestA } from './TestA';
import type { TestB } from './TestB';
import type { string } from './string';

export type TestResponse = TestA | TestB | string;
Expected:
import type { TestA } from './TestA';
import type { TestB } from './TestB';

export type TestResponse = TestA | TestB | string;

When using arrays of refs in a oneOf it's the opposite, the referenced schemas are not imported:
Actual:
export type TestArrayResponse = Array<TestA> | Array<TestB> | Array<string>;
Expected:
import type { TestA } from './TestA';
import type { TestB } from './TestB';

export type TestArrayResponse = Array<TestA> | Array<TestB> | Array<string>;
openapi-generator version

7.9.0 and latest master

OpenAPI declaration file content or url

https://gist.github.com/GregoryMerlet/fc7d7c2cb750d8d27eb064a613312b0c

Generation Details

typescript-fetch generator

Steps to reproduce

Generate using the yaml previously linked.

GregoryMerlet avatar Oct 18 '24 15:10 GregoryMerlet