Skip to content

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

@GregoryMerlet

Description

@GregoryMerlet
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.

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