orval
orval copied to clipboard
Bugs/typed tuple on zod
Status
DONE
Description
Support for typed tuples as they are produced by pydantic v2.0+
Reproduction for issue https://github.com/orval-labs/orval/issues/1592
- in
generateZodValidationSchemaDefinition, thearrayswitch case has to be altered to adhereprefixItemsconstraints. IfprefixItemsexists,- [x] a
tuplehas to be pushed into functions instead of array, - [x] each prefixItem has to be parsed and nested into the tuple
- [x] if items exists, a rest function has to be pushed after the tuple with the schema in items
- [x] a
- in parseZodValidationSchemaDefinition:
- [x] logic to add positional parameters to tuple
- [x] logic for the rest functions has to be added
- somewhere:
- [x] prevent .min().max() on tuple.
- [x] Tests added
Run npm run format to format the code. Also for min() and max() i assume jus tlook at where min and max are being createed in the code and you porbbaly need to ignore that if its a tuple?
More issues that I would like to know if there is a better solution:
- I have to cast to oas31.SchemaObject and back to oas30.SchemaObject because prefixItems is a oas 3.1.0 thing. Is there a better way? Without casting?
I have no answer for that I assume casting it is the only way.
I think this is done now. Please review and comment (and merge)
tests are still failing?
Ok. I see. Fakerjs got triggered because I accidentially re-used a existing test oas file. I reverted the hijacked file and added an explicit one. Hope thats ok this way.
Running build now
Did huskies job and formatted the code