openapi-typescript
openapi-typescript copied to clipboard
Response types from openapi-fetch ignore null values
Description
Basically - types are getting a NonNullable<>
somewhere and I believe they shouldn't
Reproduction This was tested on version 0.9.3
type TestPaths = {
'/v1/test': {
/** @description Start a process flow */
post: {
/** @description Body */
requestBody: {
content: {
'application/json': { test: boolean };
};
};
responses: {
/** @description Response */
200: {
content: {
'application/json': { test: string | null };
};
};
};
};
};
};
async function testFunction() {
const client = createClient<TestPaths>({ baseUrl: '' });
const result = await client
.POST('/v1/test', { body: { test: true } })
.then((x) => x.data);
type Result = typeof result;
}
Expected result
Result
should be { test: string | null }
, not { test: string }
Checklist
- [x] I’m willing to open a PR (see CONTRIBUTING.md)