Skip to content

Bug: OpenAPI schema generation for msgspec.Structs is woefully lacking #4575

@umarbutler

Description

@umarbutler

Description

Currently, despite Litestar being meant to have first-class support for msgspec:

  1. Litestar's documentation does not document any way of customizing the titles, descriptions, examples, and other metadata of msgspec structs.
  2. msgspec.Meta annotations applied to msgspec structs are largely ignored by Litestar.
  3. msgspec.Meta annotations applied to ClassVar fields such as tag fields are ignored when generated OpenAPI specs.
  4. Litestar does not emit the required discriminator annotation for custom msgspec tag fields annotated with ClassVars.

It is proving very difficult to build a production API with litestar and msgspec given the above issues.

URL to code causing the issue

No response

MCVE

Steps to reproduce

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Screenshots

No response

Logs


Litestar Version

2.19.0

Platform

  • Linux
  • Mac
  • Windows
  • Other (Please specify in the description above)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug 🐛This is something that is not working as expected

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions