Closed Jukkay closed 9 months ago
Thank you for your reporting👍 It seems to be an issue caused by the lack of support for void type in typescript-json-schema. We'll work on this issue quickly in the near future and let you know when it is resolved.
After identifying the cause of the problem, we realized that the error was occurring in the typescript-json-schema library when a particular type was defined as only void instead of a union type. Rather than fixing the typescript-json-schema library directly, we wrote a fix PR to allow the response body to indicate that it is empty in a way other than void. (#46)
If your existing problematic code looked like this
'/{id}/data/': {
get: {
summary: 'Get data by id',
path: { id: number },
description: 'Returns data as an object.',
responses: {
200: responseDataType,
204: void,
},
},
},
As of tspec 0.1.111, you can fix this by modifying it like this (or by putting in an empty string)
'/{id}/data/': {
get: {
summary: 'Get data by id',
path: { id: number },
description: 'Returns data as an object.',
responses: {
200: responseDataType,
204: Tspec.NoContent,
},
},
},
Alright, this seems to work. Thank you, excellent work!
I'm having problems with adding response types for 204 responses.
As per documentation, this should be the way, right? But I'm getting this error:
Any other type works without errors. I'm on "tspec": "^0.1.110" and Node version 20.10.0.
My config:
Not sure if this is an issue with Tspec or typescript-json-schema but any help would be appreciated.