Skip to content

responseSchema limitations via Zod: No support for non-object types #669

@crtag

Description

@crtag

When trying to use Zod schemas for simple response types (strings, null, etc.), the framework doesn't handle them properly. For example:

  // This doesn't work as expected
  responseSchema: {
      204: z.null(),           // Should represent HTTP 204 No Content  
  }

Results in
✖ responseSchema.204.properties: Required

The behaviour is consistent with this pattern for other scalar types. As far as I understand, an object for response is always assumed at the moment.
Eg

200: z.number()
or
405: z.string()

Are not acceptable

Workaround found:

  responseSchema: {
      204: { type: 'null', properties: {}, description: 'No content'},
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions