Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Multi-values Literal#710

Unanswered
Arminea asked this question inQ&A
Dec 19, 2022· 1 comment
Discussion options

Hi,
is there a way to generate multi-value Literal? I need to create a property of typeList[typing.Literal["A", "B"]].
So far I have this

property_name:  type: array  items:    type: string    anyOf:      - enum: ['A']      - enum: ['B']

but that generates Union of Literals. Pydantic validation then validates each entry agains both A and B and it just gets messy.

property_name: List[Union[Literal['A'], Literal['B']]]

You must be logged in to vote

Replies: 1 comment

Comment options

Can you doenum: ['A', 'B'] instead of theanyOf? Or are you trying to avoid generatingEnum classes and have literals instead for a specific use-case?

You must be logged in to vote
0 replies
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
2 participants
@Arminea@dbanty

[8]ページ先頭

©2009-2025 Movatter.jp