From 0fb4c8d62de524eecad5eada5ca39bc83e9941d1 Mon Sep 17 00:00:00 2001 From: Marco Friso Date: Tue, 11 Aug 2020 18:22:10 +0200 Subject: [PATCH 1/3] feat(apiaryb): add format link Closes APIARY-6104 --- packages/apiaryb-parser/CHANGELOG.md | 6 +++ packages/apiaryb-parser/lib/parser.js | 11 ++++- .../test/fixtures/format-link.json | 49 +++++++++++++++++++ .../test/fixtures/format-link.txt | 1 + 4 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 packages/apiaryb-parser/test/fixtures/format-link.json create mode 100644 packages/apiaryb-parser/test/fixtures/format-link.txt 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..c0b0ac688 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,9 @@ class Parser { }); this.result.push(this.api); + + // console.log('RES', this.result); + return this.result; } 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 From d134967f92833a46f8bbb6290ff7d7c1201586eb Mon Sep 17 00:00:00 2001 From: Marco Friso Date: Tue, 11 Aug 2020 18:23:28 +0200 Subject: [PATCH 2/3] chore(apiaryb): add format link to fixtures --- .../test/fixtures/description.json | 26 +++++++++++++++++ .../apiaryb-parser/test/fixtures/example.json | 28 ++++++++++++++++++- .../test/fixtures/host-metadata.json | 26 +++++++++++++++++ .../test/fixtures/host-path.json | 26 +++++++++++++++++ .../fixtures/host-trailing-slash-path.json | 26 +++++++++++++++++ .../fixtures/json-validations-host-path.json | 26 +++++++++++++++++ .../test/fixtures/json-validations.json | 26 +++++++++++++++++ .../apiaryb-parser/test/fixtures/title.json | 26 +++++++++++++++++ .../test/fixtures/unnamed-section.json | 26 +++++++++++++++++ 9 files changed, 235 insertions(+), 1 deletion(-) 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/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", From d923abfec4eeaa0ee18f4ead7e13e3da3dadbde4 Mon Sep 17 00:00:00 2001 From: Marco Friso Date: Thu, 13 Aug 2020 15:19:02 +0200 Subject: [PATCH 3/3] refactor(apiaryb): remove comment --- packages/apiaryb-parser/lib/parser.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/apiaryb-parser/lib/parser.js b/packages/apiaryb-parser/lib/parser.js index c0b0ac688..933303ae5 100644 --- a/packages/apiaryb-parser/lib/parser.js +++ b/packages/apiaryb-parser/lib/parser.js @@ -63,8 +63,6 @@ class Parser { this.result.push(this.api); - // console.log('RES', this.result); - return this.result; }