raml-spec icon indicating copy to clipboard operation
raml-spec copied to clipboard

Ability to define wellknown objects in RAML

Open hitengajjar opened this issue 2 years ago • 1 comments

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.

hitengajjar avatar Aug 16 '22 11:08 hitengajjar

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

git2gus[bot] avatar Aug 16 '22 11:08 git2gus[bot]