Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'type' facet allows nested 'type' #1085

Closed
1 of 4 tasks
deiteris opened this issue Aug 12, 2021 · 5 comments
Closed
1 of 4 tasks

'type' facet allows nested 'type' #1085

deiteris opened this issue Aug 12, 2021 · 5 comments
Assignees

Comments

@deiteris
Copy link

Your issue may already be reported! Please search on Github issues before creating one.

  • I'm submitting a ...

    • bug report
    • feature request
    • question
    • other
  • What is the current behavior?

The following RAML is validated and parsed successfully:

#%RAML 1.0
title: Test API

/person:
  post:
    body:
      application/json:
        type:
          type:
            type:
              type: object
              properties:
                prop1: string
  • If the current behavior is a bug, please provide the minimal steps to reproduce with AMF code. Please don't upload AMF code mixed with yours.

  • What is the expected behavior?

Such use of the facet doesn't seem to be correct as it is supposed to allow only data types.

  • Please tell us about your environment:

    • AMF Version: 4.7.6
    • AMF Distribution: JVM and JS
    • Operating System: Windows 10 21H1
@tomsfernandez
Copy link
Contributor

Hi @deiteris, can you point out where in the spec it says this is not allowed?

According to https://github.com/raml-org/raml-spec/blob/master/versions/raml-10/raml-10.md#type-declarations in the type facet entry:

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.

@deiteris
Copy link
Author

deiteris commented Aug 23, 2021

Hi @tomsfernandez. Just to make sure we're on the same page (as my example may be unclear): I am considering as a bug the following construct that is allowed by AMF parser:

types:
  MyType:
    type:
      type:
        # And many more nested 'type:' facets below until the actual type value.

And according to your cite from the spec it accepts a value (that is one of the possible listed values), not the other facets.

This may become especially confusing when deprecated schema keyword is being mistakenly used to describe a type (I've recently stumbled upon this usage and that's the whole reason why I am reporting this) like this, since these facets are equal:

types:
  MyType:
    schema:
      type: object
      properties:

@tomsfernandez
Copy link
Contributor

Hmm I interpret the word value in the phrase:

The value of a type node

As a YAML node value. In the possible values described in that phrase are a scalar (point a) and b)) or an object (point c)). If this is the case then that is allowed behaviour.

@tomsfernandez
Copy link
Contributor

I suggest you raise an issue in https://github.com/raml-org/raml-spec/issues to see if this example should be valid or not.

@deiteris
Copy link
Author

Hmm I interpret the word value in the phrase:

The value of a type node

As a YAML node value. In the possible values described in that phrase are a scalar (point a) and b)) or an object (point c)). If this is the case then that is allowed behaviour.

Actually yeah, you are right and the spec means exactly that. But from the user's PoV it looks like a loophole in the spec (or I just don't see how it can be useful). I'll raise the issue in the spec repo. Thanks!

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

No branches or pull requests

3 participants