Skip to content

Nullable array with $ref is generated as any[] | null #991

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

Open
clemeth opened this issue Nov 24, 2024 · 0 comments · May be fixed by #1167
Open

Nullable array with $ref is generated as any[] | null #991

clemeth opened this issue Nov 24, 2024 · 0 comments · May be fixed by #1167

Comments

@clemeth
Copy link

clemeth commented Nov 24, 2024

I have an object with the following (non-required) property defined in the schema (OpenAPI 3.1.0):

"foos": {
  "type": ["array", "null"],
  "items": {
    "$ref": "#/components/schemas/Foo"
  }
}

On 13.0.22, this generates: foos?: any[] | null

I would instead expect: foos?: Foo[] | null

The same thing happens if the property is required, as well. If I make it non-nullable, it works as expected.

Thomasdezeeuw added a commit to Thomasdezeeuw/swagger-typescript-api that referenced this issue Apr 10, 2025
In OpenAPI v3.1 the nullable property was replaced with a "typed array",
that is an array that can either be of type T or null.

To make the minimal amount of changes this commit converts a type array
back into what a 3.0 parser would expect.

Closes acacode#991
@Thomasdezeeuw Thomasdezeeuw linked a pull request Apr 10, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant