Skip to content

feat: support OpenAPI 3.1 prefixItems property for arrays #1130

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

estyrke
Copy link
Contributor

@estyrke estyrke commented Oct 1, 2024

Generates a union of all types in prefixItems and items for 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.

Generates a union of all types in `prefixItems` and `items` for the inner list item type
dbanty added a commit that referenced this pull request Oct 20, 2024
…tyrke! (#1141)

Replaces #1130 with a couple tweaks

---------

Co-authored-by: Emil Styrke <[email protected]>
Co-authored-by: Dylan Anthony <[email protected]>
@dbanty
Copy link
Collaborator

dbanty commented Oct 20, 2024

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

@dbanty dbanty closed this Oct 20, 2024
@estyrke
Copy link
Contributor Author

estyrke commented Oct 24, 2024

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.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants