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
127 stars 5 forks source link

fix: empty responses fallback #45

Closed hyeonss0417 closed 9 months ago

hyeonss0417 commented 9 months ago

fix the bug where an empty responses object causes an error

ex)

Schema

export type BookApiSpec = Tspec.DefineApiSpec<{
  paths: {
    '/':  {
      get: {
        responses: { 200: never },
      },
    },
  }
}>;

Error

Error: Invalid 'responses' in {"additionalProperties":false,"type":"object","properties":{"responses":{"type":"object","additionalProperties":false},"handler":{},"method":{"type":"string","enum":["get"]},"url":{"type":"string","enum":["/"]},"security":{},"tags":{"type":"array","minItems":0,"maxItems":0}},"required":["handler","method","responses","security","tags","url"]}; value: {"type":"object","additionalProperties":false}