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

Property types with an anyOf definition are not processed correctly #130

Closed
praneetloke opened this issue Apr 13, 2024 · 2 comments
Closed
Assignees
Labels
wontfix This will not be worked on

Comments

@praneetloke
Copy link
Member

praneetloke commented Apr 13, 2024

See #129 (comment).

@praneetloke praneetloke self-assigned this Apr 13, 2024
@praneetloke praneetloke pinned this issue Apr 13, 2024
@praneetloke
Copy link
Member Author

praneetloke commented Apr 13, 2024

In almost all cases, I think anyOf can be rewritten as a oneOf definition without a discriminator. And when it cannot be rewritten as a oneOf definition it must have a discriminator to break the tie. In fact, Pulumi's own schema for a property TypeSpec doesn't have a provision to bind an anyOf definition. It supports a oneOf (line number may change in the future) though with an optional discriminator.

Especially in the case where an API uses anyOf to provide an enum type as well as a plain string to allow users to pass in custom values, I think these can be safely rewritten as oneOf without a discriminator. Because a discriminator is not needed there and the value of such a type can only be one of the enum values or a plain string value anyway but not more than one at the same time.

@praneetloke praneetloke closed this as not planned Won't fix, can't repro, duplicate, stale Apr 13, 2024
@praneetloke praneetloke added the wontfix This will not be worked on label Apr 13, 2024
@praneetloke
Copy link
Member Author

I've closed this for the time being as wontfix because it is not safe for pulschema to assume that all anyOf definitions can be treated as oneOf. So this is something that the provider code that uses pulschema to make the decision before calling it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

1 participant