ts-spec / tspec

Type-driven API Documentation library. Auto-generating REST API document based on TypeScript types.
https://ts-spec.github.io/tspec/
MIT License
108 stars 5 forks source link

Responses with type void caused exception #54

Open programatix opened 1 month ago

programatix commented 1 month ago

Describe the bug Using type void in responses crashed node,js.

To Reproduce Steps to reproduce the behavior:

  1. Follow the instructions found at https://ts-spec.github.io/tspec/guide/crud-api-example.
  2. For path delete, the responses for 204 is void. It crashed node.js

Expected behavior No crash.

Exception

...\node_modules\typescript-json-schema\dist\typescript-json-schema.js:470
                    throw new Error("Not supported: root type undefined");
                          ^

Error: Not supported: root type undefined
    at JsonSchemaGenerator.getDefinitionForRootType (...\node_modules\typescript-json-schema\dist\typescript-json-schema.js:470:27)
    at JsonSchemaGenerator.getTypeDefinition (...\node_modules\typescript-json-schema\dist\typescript-json-schema.js:1120:26)
    at JsonSchemaGenerator.getDefinitionForProperty (...\node_modules\typescript-json-schema\dist\typescript-json-schema.js:591:31)
    at ...\node_modules\typescript-json-schema\dist\typescript-json-schema.js:905:37
    at Array.reduce (<anonymous>)
    at JsonSchemaGenerator.getClassDefinition (...\node_modules\typescript-json-schema\dist\typescript-json-schema.js:903:45)
    at JsonSchemaGenerator.getTypeDefinition (...\node_modules\typescript-json-schema\dist\typescript-json-schema.js:1134:26)
    at JsonSchemaGenerator.getDefinitionForProperty (...\node_modules\typescript-json-schema\dist\typescript-json-schema.js:591:31)
    at ...\node_modules\typescript-json-schema\dist\typescript-json-schema.js:905:37
    at Array.reduce (<anonymous>)

Node.js v22.2.0

Desktop (please complete the following information):

Versions "tspec": "^0.1.114" "typescript": "^5.4.5"