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

Clarification on 'type' facet usage #762

Open
deiteris opened this issue Aug 23, 2021 · 1 comment
Open

Clarification on 'type' facet usage #762

deiteris opened this issue Aug 23, 2021 · 1 comment

Comments

@deiteris
Copy link

deiteris commented Aug 23, 2021

Hi 👋

When working with AMF parser, I've discovered that the following RAML passes the validation (aml-org/amf#1085):

#%RAML 1.0
title: Test API

/person:
  post:
    body:
      application/json:
        type:
          type:
            type: # And possibly many more nested 'type:' facets below until the actual Type Expression
              type: object
              properties:
                prop1: string

Here's what the current version of specification says:

The type which the current type extends or just wraps. The value of a type node MUST be either a) the name of a user-defined type or b) the name of a built-in RAML data type (object, array, or one of the scalar types) or c) an inline type declaration.

While points a) and b) are clear, the point c) here puzzles me since it creates a loophole that allows a user to create an infinite type declaration, or confusing constructions involving deprecated schema node:

types:
  MyType:
    schema:
      type: object
      properties:

Is it done on purpose? What is the point of allowing an inline type declaration inside a type?

@sammy-hughes
Copy link

given example A

types:
  foo:
    type: object
    properties:
      bar: string

if the following, example B

...
  baz:
    type: foo

is the same as, example C

...
  baz:
    type: !insert-the-definition-of-what-folllows foo

then example C would expand to the following, example D.

...
  baz:
    type:
      type: object
      properties:
        bar: string

which is, like you observed, a construction that passes validation. It seems to me only an issue to a non-conformant, naive RAML processor.

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

2 participants