Open darbymanning opened 2 months ago
When defining minItems in an array type, the typegen generates a bit of a strange type definition for that entry.
minItems
Example schema:
daycare_days: type: array minItems: 1 items: type: string enum: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
Output:
daycare_days?: [ ("Monday" | "Tuesday" | "Wednesday" | "Thursday" | "Friday" | "Saturday" | "Sunday"), ...("Monday" | "Tuesday" | "Wednesday" | "Thursday" | "Friday" | "Saturday" | "Sunday")[] ];
Whilst there's not really a way to represent minItems I'd just expect the typegen to disregard it, and generate an array from the enum:
Expected:
daycare_days?: ("Monday" | "Tuesday" | "Wednesday" | "Thursday" | "Friday" | "Saturday" | "Sunday")[];
I also just checked to see how it behaves with maxItems, and hilariously it seems to duplicate the array entries in the type information by x. For example:
maxItems
x
maxItems: 10 generates:
maxItems: 10
daycare_days?: [ ("Monday" | "Tuesday" | "Wednesday" | "Thursday" | "Friday" | "Saturday" | "Sunday")?, ("Monday" | "Tuesday" | "Wednesday" | "Thursday" | "Friday" | "Saturday" | "Sunday")?, ("Monday" | "Tuesday" | "Wednesday" | "Thursday" | "Friday" | "Saturday" | "Sunday")?, ("Monday" | "Tuesday" | "Wednesday" | "Thursday" | "Friday" | "Saturday" | "Sunday")?, ("Monday" | "Tuesday" | "Wednesday" | "Thursday" | "Friday" | "Saturday" | "Sunday")?, ("Monday" | "Tuesday" | "Wednesday" | "Thursday" | "Friday" | "Saturday" | "Sunday")?, ("Monday" | "Tuesday" | "Wednesday" | "Thursday" | "Friday" | "Saturday" | "Sunday")?, ("Monday" | "Tuesday" | "Wednesday" | "Thursday" | "Friday" | "Saturday" | "Sunday")?, ("Monday" | "Tuesday" | "Wednesday" | "Thursday" | "Friday" | "Saturday" | "Sunday")?, ("Monday" | "Tuesday" | "Wednesday" | "Thursday" | "Friday" | "Saturday" | "Sunday")? ];
When defining
minItems
in an array type, the typegen generates a bit of a strange type definition for that entry.Example schema:
Output:
Whilst there's not really a way to represent
minItems
I'd just expect the typegen to disregard it, and generate an array from the enum:Expected:
I also just checked to see how it behaves with
maxItems
, and hilariously it seems to duplicate the array entries in the type information byx
. For example:maxItems: 10
generates: