Skip to content
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

Accept an array of types in Schema.type #660

Open
madjar opened this issue Mar 14, 2025 · 0 comments
Open

Accept an array of types in Schema.type #660

madjar opened this issue Mar 14, 2025 · 0 comments

Comments

@madjar
Copy link
Contributor

madjar commented Mar 14, 2025

Currently, when the decoder encounters a schema whose type is an array (such as ["string", "null"]) is ignores the object and leave it entirely as is.


Continuing on my streak of implementing the bits of OpenAPI 3.1.0 that I encounter on the schema I'm working with, I'd like to handle cases where the Schema.type is an array of types. In my case, it's exclusively [something, "null"], but if can be anything. According to some sources, it looks like the expected behaviour is that the schema object can contain any restriction field that would make sense for any of the types in the array. The expected behaviour is similar to a corresponding anyOf.

I've only been looking at the decoding so far, and I got it working by merging all the various clauses that deal with various possibilities into one big function that convert any field it finds. This works well, except for one piece of logic which depends on the actual type: properties should be %{} instead of nil if the type is/contains object.

This solution isn't very satisfying, so I'll sleep on it, see if I can figure a nicer way. The current progress lives at #659.

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

No branches or pull requests

1 participant