Skip to content

Fix Required/Optional Type Ambiguity in OpenAPI's .json file #340

@daniel-slaugh

Description

@daniel-slaugh

I've been generating typescript types from the backend's OpenApi.json spec file with the openapi-typescript library. Problem is if a schema is declared with "default": [] and lacks "nullable": true, openapi-typescript interprets that combination as "always defined" instead of optional. For example, the RolesQueryParameter type should have an optional 'workspace_id?', but the generated TypeScript file defines it as required.

@kjlippold I'm not sure the easiest way to resolve this. I'm hoping there's a straightforward way to update Pydantic models to make optional fields more explicit in the generated OpenApi.json file, but if not we'll need to think of another way to fix this. For now, I can disable TypeScript for specific @hydroserver/client calls, but in production the Types should match the backend exactly.

Metadata

Metadata

Labels

backendAssociated with the backend repository

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions