raml-org / raml-js-parser-2

(deprecated)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

KEYS_SHOULD_BE_UNIQUE error should include the key name

agirorn opened this issue · comments

When the parser encounters the KEYS_SHOULD_BE_UNIQUE error the key name should be included in the error message. That makes it easier to find the key in question.

Currently it is

 {
    "code": "KEYS_SHOULD_BE_UNIQUE",
    "message": "Keys should be unique",
    "path": "api/portions/index.raml",
    "range": {
      "start": {"line": 98, "column": 16, "position": 2383},
      "end": {"line": 98, "column": 27, "position": 2394}
    },
    "trace": [
      {
        "code": "ERROR_IN_INCLUDED_FILE",
        "message": "Error in the included file: Keys should be unique",
        "path": "index.raml",
        "range": {
          "start": {"line": 5, "column": 0, "position": 154},
          "end": {"line": 5, "column": 4, "position": 158}
        }
      }
    ]
  },

Should be

 {
    "code": "KEYS_SHOULD_BE_UNIQUE",
    "message": "Keys 'keyName' should be unique",
    "path": "api/portions/index.raml",
    "range": {
      "start": {"line": 98, "column": 16, "position": 2383},
      "end": {"line": 98, "column": 27, "position": 2394}
    },
    "trace": [
      {
        "code": "ERROR_IN_INCLUDED_FILE",
        "message": "Error in the included file: Keys 'keyName' should be unique",
        "path": "index.raml",
        "range": {
          "start": {"line": 5, "column": 0, "position": 154},
          "end": {"line": 5, "column": 4, "position": 158}
        }
      }
    ]
  },

Note that raml-js-parser-2 has been deprecated, the new official parser is webapi-parcser. Feel free to attempt to reproduce this issue with webapi-parser and report any issue you may have on that repository.

I don't feel like I want to be the QA every time you guys start a new module and repo for the RAML parser. This bug and the other bug I have reported #867 are such fundamental bugs that should have both been reported and fixed along time ago since they severely hinder the learning curve and the process of using the RAML. When I and my team started to us the RAML we spend considerable time trying to figure out what exactly was causing the RAML parsing to fail. So if you did not fix this in this or the other parsers I dought it is fixed in the new parser and it mostlikley just has some other new bug. I at least am not willing to invest my time in learning the new parser API and try to reproduce this bug.

Not to dismiss your past frustration but webapi-parser is based on AMF and is a complete revamp. I think it's worth giving it a try. In fact, if you can share a RAML snippet for the bug you described above, I am willing to test it for you.

I don't have a RAML sample for you to check this out and I hope this revamp works out for you.