diff --git a/packages/apiaryb-parser/CHANGELOG.md b/packages/apiaryb-parser/CHANGELOG.md index 6f6d97142..a7d0f712f 100644 --- a/packages/apiaryb-parser/CHANGELOG.md +++ b/packages/apiaryb-parser/CHANGELOG.md @@ -1,5 +1,11 @@ # API Elements: Apiary Blueprint Parser Changelog +## Master + +### Enhancements + +- added a Link element to the specific format/version in the parse result. + ## 0.2.1 (2020-08-05) Adds compatibility for @apielements/core 0.2.0. diff --git a/packages/apiaryb-parser/lib/parser.js b/packages/apiaryb-parser/lib/parser.js index 4d38cf4ac..933303ae5 100644 --- a/packages/apiaryb-parser/lib/parser.js +++ b/packages/apiaryb-parser/lib/parser.js @@ -12,7 +12,7 @@ class Parser { parse() { const { - Annotation, Category, Copy, ParseResult, + Annotation, Category, Copy, ParseResult, Link, } = this.namespace.elements; this.result = new ParseResult(); @@ -34,6 +34,12 @@ class Parser { return this.result; } + const link = new Link(); + link.title = 'Apiary Blueprint'; + link.relation = 'via'; + link.href = 'https://apiary.io/blueprint'; + this.result.links.push(link); + this.api = new Category(); this.api.classes.push('api'); this.api.title = this.blueprint.name; @@ -56,6 +62,7 @@ class Parser { }); this.result.push(this.api); + return this.result; } diff --git a/packages/apiaryb-parser/test/fixtures/description.json b/packages/apiaryb-parser/test/fixtures/description.json index ee60f5056..9b3707790 100644 --- a/packages/apiaryb-parser/test/fixtures/description.json +++ b/packages/apiaryb-parser/test/fixtures/description.json @@ -1,5 +1,31 @@ { "element": "parseResult", + "meta": { + "links": { + "element": "array", + "content": [ + { + "element": "link", + "meta": { + "title": { + "element": "string", + "content": "Apiary Blueprint" + } + }, + "attributes": { + "relation": { + "element": "string", + "content": "via" + }, + "href": { + "element": "string", + "content": "https://apiary.io/blueprint" + } + } + } + ] + } + }, "content": [ { "element": "category", diff --git a/packages/apiaryb-parser/test/fixtures/example.json b/packages/apiaryb-parser/test/fixtures/example.json index 66cba5134..4773e2f94 100644 --- a/packages/apiaryb-parser/test/fixtures/example.json +++ b/packages/apiaryb-parser/test/fixtures/example.json @@ -1,5 +1,31 @@ { "element": "parseResult", + "meta": { + "links": { + "element": "array", + "content": [ + { + "element": "link", + "meta": { + "title": { + "element": "string", + "content": "Apiary Blueprint" + } + }, + "attributes": { + "relation": { + "element": "string", + "content": "via" + }, + "href": { + "element": "string", + "content": "https://apiary.io/blueprint" + } + } + } + ] + } + }, "content": [ { "element": "category", @@ -394,4 +420,4 @@ ] } ] -} +} \ No newline at end of file diff --git a/packages/apiaryb-parser/test/fixtures/format-link.json b/packages/apiaryb-parser/test/fixtures/format-link.json new file mode 100644 index 000000000..926b47050 --- /dev/null +++ b/packages/apiaryb-parser/test/fixtures/format-link.json @@ -0,0 +1,49 @@ +{ + "element": "parseResult", + "meta": { + "links": { + "element": "array", + "content": [ + { + "element": "link", + "meta": { + "title": { + "element": "string", + "content": "Apiary Blueprint" + } + }, + "attributes": { + "relation": { + "element": "string", + "content": "via" + }, + "href": { + "element": "string", + "content": "https://apiary.io/blueprint" + } + } + } + ] + } + }, + "content": [ + { + "element": "category", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "api" + } + ] + }, + "title": { + "element": "string", + "content": "Blueprint with Format Link" + } + } + } + ] +} \ No newline at end of file diff --git a/packages/apiaryb-parser/test/fixtures/format-link.txt b/packages/apiaryb-parser/test/fixtures/format-link.txt new file mode 100644 index 000000000..ba00ec74c --- /dev/null +++ b/packages/apiaryb-parser/test/fixtures/format-link.txt @@ -0,0 +1 @@ +--- Blueprint with Format Link --- \ No newline at end of file diff --git a/packages/apiaryb-parser/test/fixtures/host-metadata.json b/packages/apiaryb-parser/test/fixtures/host-metadata.json index b3b955752..00907ecb6 100644 --- a/packages/apiaryb-parser/test/fixtures/host-metadata.json +++ b/packages/apiaryb-parser/test/fixtures/host-metadata.json @@ -1,5 +1,31 @@ { "element": "parseResult", + "meta": { + "links": { + "element": "array", + "content": [ + { + "element": "link", + "meta": { + "title": { + "element": "string", + "content": "Apiary Blueprint" + } + }, + "attributes": { + "relation": { + "element": "string", + "content": "via" + }, + "href": { + "element": "string", + "content": "https://apiary.io/blueprint" + } + } + } + ] + } + }, "content": [ { "element": "category", diff --git a/packages/apiaryb-parser/test/fixtures/host-path.json b/packages/apiaryb-parser/test/fixtures/host-path.json index aab3fb692..b6c13284a 100644 --- a/packages/apiaryb-parser/test/fixtures/host-path.json +++ b/packages/apiaryb-parser/test/fixtures/host-path.json @@ -1,5 +1,31 @@ { "element": "parseResult", + "meta": { + "links": { + "element": "array", + "content": [ + { + "element": "link", + "meta": { + "title": { + "element": "string", + "content": "Apiary Blueprint" + } + }, + "attributes": { + "relation": { + "element": "string", + "content": "via" + }, + "href": { + "element": "string", + "content": "https://apiary.io/blueprint" + } + } + } + ] + } + }, "content": [ { "element": "category", diff --git a/packages/apiaryb-parser/test/fixtures/host-trailing-slash-path.json b/packages/apiaryb-parser/test/fixtures/host-trailing-slash-path.json index 74f8afc10..f4ecd22eb 100644 --- a/packages/apiaryb-parser/test/fixtures/host-trailing-slash-path.json +++ b/packages/apiaryb-parser/test/fixtures/host-trailing-slash-path.json @@ -1,5 +1,31 @@ { "element": "parseResult", + "meta": { + "links": { + "element": "array", + "content": [ + { + "element": "link", + "meta": { + "title": { + "element": "string", + "content": "Apiary Blueprint" + } + }, + "attributes": { + "relation": { + "element": "string", + "content": "via" + }, + "href": { + "element": "string", + "content": "https://apiary.io/blueprint" + } + } + } + ] + } + }, "content": [ { "element": "category", diff --git a/packages/apiaryb-parser/test/fixtures/json-validations-host-path.json b/packages/apiaryb-parser/test/fixtures/json-validations-host-path.json index 8d36c858c..baa4e397d 100644 --- a/packages/apiaryb-parser/test/fixtures/json-validations-host-path.json +++ b/packages/apiaryb-parser/test/fixtures/json-validations-host-path.json @@ -1,5 +1,31 @@ { "element": "parseResult", + "meta": { + "links": { + "element": "array", + "content": [ + { + "element": "link", + "meta": { + "title": { + "element": "string", + "content": "Apiary Blueprint" + } + }, + "attributes": { + "relation": { + "element": "string", + "content": "via" + }, + "href": { + "element": "string", + "content": "https://apiary.io/blueprint" + } + } + } + ] + } + }, "content": [ { "element": "category", diff --git a/packages/apiaryb-parser/test/fixtures/json-validations.json b/packages/apiaryb-parser/test/fixtures/json-validations.json index 89f5e7eb2..b39f7bfe5 100644 --- a/packages/apiaryb-parser/test/fixtures/json-validations.json +++ b/packages/apiaryb-parser/test/fixtures/json-validations.json @@ -1,5 +1,31 @@ { "element": "parseResult", + "meta": { + "links": { + "element": "array", + "content": [ + { + "element": "link", + "meta": { + "title": { + "element": "string", + "content": "Apiary Blueprint" + } + }, + "attributes": { + "relation": { + "element": "string", + "content": "via" + }, + "href": { + "element": "string", + "content": "https://apiary.io/blueprint" + } + } + } + ] + } + }, "content": [ { "element": "category", diff --git a/packages/apiaryb-parser/test/fixtures/title.json b/packages/apiaryb-parser/test/fixtures/title.json index d8277e5cd..9b56f7fb7 100644 --- a/packages/apiaryb-parser/test/fixtures/title.json +++ b/packages/apiaryb-parser/test/fixtures/title.json @@ -1,5 +1,31 @@ { "element": "parseResult", + "meta": { + "links": { + "element": "array", + "content": [ + { + "element": "link", + "meta": { + "title": { + "element": "string", + "content": "Apiary Blueprint" + } + }, + "attributes": { + "relation": { + "element": "string", + "content": "via" + }, + "href": { + "element": "string", + "content": "https://apiary.io/blueprint" + } + } + } + ] + } + }, "content": [ { "element": "category", diff --git a/packages/apiaryb-parser/test/fixtures/unnamed-section.json b/packages/apiaryb-parser/test/fixtures/unnamed-section.json index 1d49d5a0f..367d0a908 100644 --- a/packages/apiaryb-parser/test/fixtures/unnamed-section.json +++ b/packages/apiaryb-parser/test/fixtures/unnamed-section.json @@ -1,5 +1,31 @@ { "element": "parseResult", + "meta": { + "links": { + "element": "array", + "content": [ + { + "element": "link", + "meta": { + "title": { + "element": "string", + "content": "Apiary Blueprint" + } + }, + "attributes": { + "relation": { + "element": "string", + "content": "via" + }, + "href": { + "element": "string", + "content": "https://apiary.io/blueprint" + } + } + } + ] + } + }, "content": [ { "element": "category",