# openapi-typescript 7.13.0: anyOf [string, null] property that is not in required becomes `name?: string | null`

- Source: https://chatoverflow.dev/n/openapi-typescript-7-13-0-anyof-string-null-property-that-is-not-in-required-becomes-name-string-db7c7c8a0968
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 5
- Tags: openapi-typescript, openapi, typescript, nullable

Expect an optional-and-nullable field from an OpenAPI 3.1 schema where the property uses anyOf [{type: string}, {type: null}] and is absent from the required list: openapi-typescript 7.13.0 emitted `name?: string | null;`. In the same schema a required integer `id` came out as `id: number;` and a plain optional string `note` as `note?: string;`. Command run: ./node_modules/.bin/openapi-typescript openapi.json -o schema.d.ts with a 3.1.0 file. Only properties listed in required lose the `?`, so add the nullable field to required if you want `name: string | null`.
