Closed antoine-mulet closed 4 years ago
Welcome to OpenRPC! Thank you for taking the time to create an issue. Please review the guidelines
Having the same issue as described by @antoine-mulet.
@antoine-mulet @georgeconstantinou Thank you both for raising this issue. It's something we experimented with early on and dropped, but as pointed out, we missed a reference to it in the spec. Anything referring to oneOf should be removed. Polymorphism as described should be pushed down to the JSON schema, since it already fully supports oneOf.
PRs are very welcomed. I'll make one later on today though.
@antoine-mulet since it's ultimately your contribution, if you want to copy the PR and re-open, I'm happy to merge yours.
@BelfordZ Thanks for the clarification and your great work! My PR is all yours.
:tada: This issue has been resolved in version 1.2.6 :tada:
The release is available on:
1.2.6
Your semantic-release bot :package::rocket:
I have been struggling to understand how oneOf can be used within params since it is mentioned in the documentation https://spec.open-rpc.org/#method-object. I have played a bit with the playground as well and the only way I found to make use of oneOf was inside the schema, which is standard json schema. Am I missing something?
I found issue #193 which was auto closed so I am wondering whether oneOf was somehow supported in the past but it's not anymore? If that's the case the documentation should probably be updated.
As a side note I can see a use case where one could want to use oneOf outside the schema. This would be to define some sort of polymorphic group of top level params e.g.
This is clearly not compatible with params being of type array so not sure the added complexity is worth the benefits but I am currently migrating an API to OpenRPC and I found myself in the need of doing something like this so maybe others would too.
This limitation is easily overcome by introducing another level of nesting as follow but it ultimately changes what your API looks like
I hope it makes sense.