open-rpc / spec

The OpenRPC specification
https://spec.open-rpc.org
Apache License 2.0
166 stars 49 forks source link

Does OpenRPC supports something like "discriminator" for oneOf and anyOf? #382

Open svetlyak40wt opened 12 months ago

svetlyak40wt commented 12 months ago

OpenAPI supports it and this feature is useful when writing code-generated API wrappers.

Here is how it looks like in the OpenAPI spec:

components:
  responses:
    sampleObjectResponse:
      content:
        application/json:
          schema:
            oneOf:
              - $ref: '#/components/schemas/Object1'
              - $ref: '#/components/schemas/Object2'
              - $ref: 'sysObject.json#/sysObject'
            discriminator:
              propertyName: objectType
              mapping:
                obj1: '#/components/schemas/Object1'
                obj2: '#/components/schemas/Object2'
                system: 'sysObject.json#/sysObject'

Example was taken from here.

github-actions[bot] commented 12 months ago

Welcome to OpenRPC! Thank you for taking the time to create an issue. Please review the guidelines

etodanik commented 6 months ago

This is similar to an earlier request: https://github.com/open-rpc/spec/issues/357

Would be great to hear which path maintainers prefer so someone could cook up a PR