Skip to content

Bug: Setting the title of an Enum (+ msgspec Struct) does not work (in terms of OpenAPI gen) #4002

Open
@umarbutler

Description

Description

Setting the title of an Enum with Body() or msgspec.Meta like so will still not allow it be shown in the autogenerated OpenAPI spec even if you try setting schema_name does not work:

class UniversalClassificationScoringMethod(StrEnum):
    AUTO = "auto"
    CHUNK_MAX = "chunk_max"
    CHUNK_AVG = "chunk_avg"
    CHUNK_MIN = "chunk_min"


UniversalClassificationScoringMethod.__schema_name__ = "Universal classification scoring method"

UniversalClassificationScoringMethod = Annotated[
    UniversalClassificationScoringMethod,
    Meta(
        title="Universal classification scoring method",
    ),
    Body(
        title="Universal classification scoring method",
        description="A method for producing an overall confidence score for a universal classification.",
        examples=[Example(value=UniversalClassificationScoringMethod.AUTO)],
    ),
]

This also applies to msgspec Struct's, however, schema_name does at least still work.

URL to code causing the issue

No response

MCVE

# Your MCVE code here

Steps to reproduce

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

Screenshots

"![SCREENSHOT_DESCRIPTION](SCREENSHOT_LINK.png)"

Logs

Litestar Version

2.14.0

Platform

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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