What did I try
Define the following pydantic schema:
class Amount(BaseModel):
value: int
unit: str
class Booking(BaseModel):
project: str
date: str
amount: Amount
class Bookings(BaseModel):
bookings: List[Booking]
Bookings(bookings=...).json() generates the desired output {"bookings": [{"project": "...", "date": "...", ' '"amount": {"value": "...", "unit": "..."}}]}, so I think the schema definition is correct.\
The output of the current from_pydantic implementation is the following:
Call:
The output is better, but I need the string "bookings" (with an "s"), and couldn't find a way to accomplish this.
How I think it may be solved
Add parameter id to from_pydantic method.\
Currently the from_pydantic method allows for the definition of a description, examples and the many flag. \
In my opinion the id parameter is missing. Since it is possible to define it in a kor-Object, it should also be possible to provide it to this method. This way it will be possible to set the name of the root object, in my case to "bookings".
What do I want to achive I want kor to generate a Typescript description like the following:
What did I try Define the following pydantic schema:
Bookings(bookings=...).json()
generates the desired output{"bookings": [{"project": "...", "date": "...", ' '"amount": {"value": "...", "unit": "..."}}]}
, so I think the schema definition is correct.\ The output of the currentfrom_pydantic
implementation is the following: Call:Output:
To overcome this, I tried: Call:
Output:
The output is better, but I need the string "bookings" (with an "s"), and couldn't find a way to accomplish this.
How I think it may be solved Add parameter
id
tofrom_pydantic
method.\ Currently thefrom_pydantic
method allows for the definition of adescription
,examples
and themany
flag. \ In my opinion the id parameter is missing. Since it is possible to define it in a kor-Object, it should also be possible to provide it to this method. This way it will be possible to set the name of the root object, in my case to "bookings".