feat: support OpenAPI 3.1 prefixItems property for arrays#1130
feat: support OpenAPI 3.1 prefixItems property for arrays#1130estyrke wants to merge 1 commit intoopenapi-generators:mainfrom
Conversation
Generates a union of all types in `prefixItems` and `items` for the inner list item type
0374ce8 to
23909aa
Compare
|
Looks great, thanks! I don't even know how we'd represent this with Python types, I don't think you can specify types for only certain elements of a list, and tuples wouldn't work because they're fixed-length 😵💫. So this might be the best we can ever do for this feature. I had to update a snapshot, so this is merged via #1141 |
Indeed, but for a fixed length list we could represent it as a tuple (I think that's how you'd represent a tuple type in OpenAPI, and that's also how it is in my use case), but yeah, in the general case it's not possible. I guess we could also add specific isinstance validation for each prefix element in from_dict, but I guess that might be considered un-pythonic. |
…tyrke! (openapi-generators#1141) Replaces openapi-generators#1130 with a couple tweaks --------- Co-authored-by: Emil Styrke <emil.styrke@arboair.com> Co-authored-by: Dylan Anthony <dbanty@users.noreply.github.com>
Generates a union of all types in
prefixItemsanditemsfor the inner list item type. This could probably be made more strict by validating each prefix item against its specific type, but this felt good enough for a start.