question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Clarify oneOf usage if any

See original GitHub issue

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.

"params" :  { "oneOf" :[
        { "$ref": "#/components/schemas/Foo" },
        { "$ref": "#/components/schemas/Bar" } 
      ]
}

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

"params" :  [
        { "name": "p", "schema": { "type" : "object", "oneOf": [
               { "$ref": "#/components/schemas/Foo" } ,
               {  "$ref": "#/components/schemas/Bar" }
      ]}
}

I hope it makes sense.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
antoine-muletcommented, May 22, 2020

@BelfordZ Thanks for the clarification and your great work! My PR is all yours.

0reactions
openrpc-bastioncommented, May 22, 2020

🎉 This issue has been resolved in version 1.2.6 🎉

The release is available on:

Your semantic-release bot 📦🚀

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Ask for Clarification - VOA Learning English
Here are some phrases you can use. For many of them, you can use “can” or “could,” with could being a little more...
Read more >
Clarifying What You Mean, Restating Your Ideas, and ...
Learn how to to clarify what you mean, rephrase or restate an idea, and explain your thoughts in American English.
Read more >
ways of explaining or clarifying - synonyms and related words
used for explaining that a particular person or thing is affected by something only because they are connected to what you have just...
Read more >
Use clarification in a sentence
Values clarification is generally seen as a valuable component of moral education, but incomplete on its own. 0. 1.
Read more >
Amazon SageMaker Clarify Bias Detection and Model ...
Amazon SageMaker Clarify Processing – Use SageMaker Clarify to create a processing job for the detecting bias and explaining model predictions with feature ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found