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

Errors inside 'items' show invalid message 'Component type has error: ' #102

Open
posesop opened this issue Sep 28, 2017 · 0 comments
Open

Comments

@posesop
Copy link

posesop commented Sep 28, 2017

Hi, I am parsing raml with raml-js-parser-2 load in 1.1.31 version:

#%RAML 1.0 AnnotationTypeDeclaration

displayName: My annotation
description: This is an annotation.
type: array
allowedTargets: TypeDeclaration
items:
  properties:
    name:
      type: wrooong

I expect to receive an error similar to: 'Wrong type name: wrooong'

But it shows only 'Component type has error: ' with no message.

Here is the result of the parser:

{
  "specification": {
    "displayName": "My annotation",
    "type": [
      "array"
    ],
    "required": true,
    "description": "This is an annotation.",
    "allowedTargets": [
      "TypeDeclaration"
    ],
    "items": [
      {
        "name": "items",
        "displayName": "items",
        "type": [
          "object"
        ],
        "properties": {
          "name": {
            "name": "name",
            "displayName": "name",
            "type": [
              "wrooong"
            ],
            "required": true,
            "__METADATA__": {
              "primitiveValuesMeta": {
                "displayName": {
                  "calculated": true
                },
                "required": {
                  "insertedAsDefault": true
                }
              }
            },
            "mediaType": "application/raml+yaml",
            "typePropertyKind": "TYPE_EXPRESSION"
          }
        },
        "__METADATA__": {
          "primitiveValuesMeta": {
            "displayName": {
              "calculated": true
            },
            "type": {
              "insertedAsDefault": true
            }
          }
        },
        "mediaType": "application/raml+yaml",
        "typePropertyKind": "TYPE_EXPRESSION"
      }
    ],
    "__METADATA__": {
      "primitiveValuesMeta": {
        "required": {
          "insertedAsDefault": true
        }
      }
    },
    "mediaType": "application/raml+yaml",
    "typePropertyKind": "TYPE_EXPRESSION"
  },
  "ramlVersion": "RAML10",
  "type": "ArrayTypeDeclaration",
  "errors": [
    {
      "code": "INVALID_COMPONENT_TYPE",
      "message": "Component type has error: ",
      "path": "annotation.raml",
      "range": {
        "start": {
          "line": 2,
          "column": 0,
          "position": 38
        },
        "end": {
          "line": 10,
          "column": 0,
          "position": 196
        }
      }
    }
  ]
}

I have seen in class restrictions.ts these lines:

            if (!typeStatus.isOk()) {
                st.addSubStatus(ts.error(messageRegistry.INVALID_COMPONENT_TYPE,
                    this,{msg: st.getMessage()}));
            }

if I replace st.getMessage() with typeStatus.getMessage() it shows the correct error:

{
  "specification": {
    "displayName": "My annotation",
    "type": [
      "array"
    ],
    "required": true,
    "description": "This is an annotation.",
    "allowedTargets": [
      "TypeDeclaration"
    ],
    "items": [
      {
        "name": "items",
        "displayName": "items",
        "type": [
          "object"
        ],
        "properties": {
          "name": {
            "name": "name",
            "displayName": "name",
            "type": [
              "wrooong"
            ],
            "required": true,
            "__METADATA__": {
              "primitiveValuesMeta": {
                "displayName": {
                  "calculated": true
                },
                "required": {
                  "insertedAsDefault": true
                }
              }
            },
            "mediaType": "application/raml+yaml",
            "typePropertyKind": "TYPE_EXPRESSION"
          }
        },
        "__METADATA__": {
          "primitiveValuesMeta": {
            "displayName": {
              "calculated": true
            },
            "type": {
              "insertedAsDefault": true
            }
          }
        },
        "mediaType": "application/raml+yaml",
        "typePropertyKind": "TYPE_EXPRESSION"
      }
    ],
    "__METADATA__": {
      "primitiveValuesMeta": {
        "required": {
          "insertedAsDefault": true
        }
      }
    },
    "mediaType": "application/raml+yaml",
    "typePropertyKind": "TYPE_EXPRESSION"
  },
  "ramlVersion": "RAML10",
  "type": "ArrayTypeDeclaration",
  "errors": [
    {
      "code": "INVALID_COMPONENT_TYPE",
      "message": "Component type has error: Property 'name' refers to unknown type 'wrooong'",
      "path": "annotation.raml",
      "range": {
        "start": {
          "line": 2,
          "column": 0,
          "position": 38
        },
        "end": {
          "line": 10,
          "column": 0,
          "position": 196
        }
      }
    }
  ]
}

This happens to me in any array with items declared in annotations, types or any raml

Thanks

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

No branches or pull requests

1 participant