Skip to content
This repository was archived by the owner on Nov 8, 2024. It is now read-only.
This repository was archived by the owner on Nov 8, 2024. It is now read-only.

Remove annotation code #24

@kylef

Description

@kylef

Annotation Code's are difficult to use for any meaning as they are not universally unique. One parser can treat one code with some meaning and another parser could treat the exact same code with another meaning.

This is already the case with the Fury Swagger adapter and API Blueprint parser. To the Swagger parser, code 3 is for features that are not supported (https://github.com/apiaryio/fury-adapter-swagger/blob/master/src/annotations.js#L17) and in Drafter code 3 is used for other validations (https://github.com/apiaryio/drafter/blob/4b5ae151e0a40f4a53bf07a86b4ea8fabb70ca7e/test/fixtures/parse-result/error-warning.json#L90). These code numbers provide real no benefit to consumers.

I believe that profile or origin links are better suited for a consumer to understand the semantics behind an annotation. Origin links are already available in the Swagger parser but are missing from Drafter API Blueprint parser. These links provide a reliable way for a consumer to understand the semantics behind an annotation, it also provides the consumer a way to follow a link for further information.

{
  "element": "annotation",
  "attributes": {
    "code": {
      "element": "number",
      "content": 5
    }
  },
  "content": "something was wrong"
}

vs

{
  "element": "annotation",
  "meta": {
    "links": [
      {
        "element": "link",
        "attributes": {
          "relation": { "element": "string", "content": "profile" },
          "href": { "element": "string", "content": "https://apielements.org/1/warnings/validation" },
        }
      }
    ]
  },
  "content": "something was wrong"
}

Would love to hear your opinions @smizell / @w-vi.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions