Skip to content
This repository has been archived by the owner on Feb 17, 2024. It is now read-only.

Ability to define wellknown objects in RAML #772

Open
hitengajjar opened this issue Aug 16, 2022 · 1 comment
Open

Ability to define wellknown objects in RAML #772

hitengajjar opened this issue Aug 16, 2022 · 1 comment

Comments

@hitengajjar
Copy link

We have a use case where users should be able to define well-known objects (instances) that are validated against their type in RAML. We need these instances defined as a RAML fragment.

We have found 2 ways to define instances with the current RAML specification. My intention with this bug ticket is to have a discussion on this topic, help us choose better approaches, or maybe if you see a need to enhance language with specific keywords to define instances.

Approach 1 using annotationTypes
e.g.

annotationTypes:
  wellknown-objects: MyType[]
types:
  MyType:
    properties:
      id: string
      name: string
    (wellknown-objects):
      - id: "123"
        name: "wow"
      - id: "345"
        name: "newone"

The problem is: that instances defined this way are in place with types and this is a restriction for us.


Approach 2 using facets
e.g.

types:
  _MyType:  # Have to create this as unfortunately, we cannot refer self in facets
    additionalProperties: false
    properties:
      id: string
      name: string
  MyType: 
    type: _MyType
    additionalProperties: false
    #
    facets:
      wellknown-object-value?: _MyType

  MyInstance:
    type: MyType
    wellknown-object-value:
       id: "345"
       name: "afds"

This method allows us to define instances in RAML fragments but it has below issues.

  1. Semantic meaning of types is changed to define instances. Instances still are defined as RAML Types.
  2. Instances can be inherited as they are still types. This doesn't make sense for instances.
@git2gus
Copy link

git2gus bot commented Aug 16, 2022

Git2Gus App is installed but the .git2gus/config.json doesn't exist.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

1 participant