raml-spec
raml-spec copied to clipboard
Ability to define wellknown objects in RAML
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.
- Semantic meaning of types is changed to define instances. Instances still are defined as RAML Types.
- Instances can be inherited as they are still types. This doesn't make sense for instances.
Git2Gus App is installed but the .git2gus/config.json
doesn't exist.