Skip to content
This repository was archived by the owner on Nov 8, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/openapi2-parser/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# API Elements: OpenAPI 2 Parser Changelog

## Master

- added a Link element to the specific format/version in the parse result.

## 0.32.2 (2020-07-22)

### Bug Fixes
Expand Down
13 changes: 13 additions & 0 deletions packages/openapi2-parser/lib/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ class Parser {
// By default there are no groups, just the root API element
this.group = this.api;

this.addFormatLink();
this.handleSwaggerInfo();
this.handleSwaggerHost();
this.handleSwaggerAuth();
Expand Down Expand Up @@ -325,6 +326,18 @@ class Parser {
});
}

// Add the link to the format version specs
addFormatLink() {
const { Link } = this.namespace.elements;
const link = new Link();

link.title = 'OpenAPI 2';
link.relation = 'via';
link.href = 'https://spec.openapis.org/oas/v2.0';

return this.api.links.push(link);
Comment thread
kylef marked this conversation as resolved.
Outdated
}

// Converts the Swagger title and description
handleSwaggerInfo() {
const { Copy } = this.namespace.elements;
Expand Down
24 changes: 24 additions & 0 deletions packages/openapi2-parser/test/fixtures/auth-extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,30 @@
}
]
},
"links": {
"element": "array",
"content": [
{
"element": "link",
"meta": {
"title": {
"element": "string",
"content": "OpenAPI 2"
}
},
"attributes": {
"relation": {
"element": "string",
"content": "via"
},
"href": {
"element": "string",
"content": "https://spec.openapis.org/oas/v2.0"
}
}
}
]
},
"title": {
"element": "string",
"content": "Authentication with extensions"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,30 @@
}
]
},
"links": {
"element": "array",
"content": [
{
"element": "link",
"meta": {
"title": {
"element": "string",
"content": "OpenAPI 2"
}
},
"attributes": {
"relation": {
"element": "string",
"content": "via"
},
"href": {
"element": "string",
"content": "https://spec.openapis.org/oas/v2.0"
}
}
}
]
},
"title": {
"element": "string",
"attributes": {
Expand Down
24 changes: 24 additions & 0 deletions packages/openapi2-parser/test/fixtures/auth-multi-consumes.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,30 @@
}
]
},
"links": {
"element": "array",
"content": [
{
"element": "link",
"meta": {
"title": {
"element": "string",
"content": "OpenAPI 2"
}
},
"attributes": {
"relation": {
"element": "string",
"content": "via"
},
"href": {
"element": "string",
"content": "https://spec.openapis.org/oas/v2.0"
}
}
}
]
},
"title": {
"element": "string",
"content": "Authentication with multiple consumes"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,30 @@
}
]
},
"links": {
"element": "array",
"content": [
{
"element": "link",
"meta": {
"title": {
"element": "string",
"content": "OpenAPI 2"
}
},
"attributes": {
"relation": {
"element": "string",
"content": "via"
},
"href": {
"element": "string",
"content": "https://spec.openapis.org/oas/v2.0"
}
}
}
]
},
"title": {
"element": "string",
"attributes": {
Expand Down
24 changes: 24 additions & 0 deletions packages/openapi2-parser/test/fixtures/circular-example.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,30 @@
}
]
},
"links": {
"element": "array",
"content": [
{
"element": "link",
"meta": {
"title": {
"element": "string",
"content": "OpenAPI 2"
}
},
"attributes": {
"relation": {
"element": "string",
"content": "via"
},
"href": {
"element": "string",
"content": "https://spec.openapis.org/oas/v2.0"
}
}
}
]
},
"title": {
"element": "string",
"content": "Test circular reference in example"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,30 @@
}
]
},
"links": {
"element": "array",
"content": [
{
"element": "link",
"meta": {
"title": {
"element": "string",
"content": "OpenAPI 2"
}
},
"attributes": {
"relation": {
"element": "string",
"content": "via"
},
"href": {
"element": "string",
"content": "https://spec.openapis.org/oas/v2.0"
}
}
}
]
},
"title": {
"element": "string",
"attributes": {
Expand Down
24 changes: 24 additions & 0 deletions packages/openapi2-parser/test/fixtures/consumes-invalid-type.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,30 @@
}
]
},
"links": {
"element": "array",
"content": [
{
"element": "link",
"meta": {
"title": {
"element": "string",
"content": "OpenAPI 2"
}
},
"attributes": {
"relation": {
"element": "string",
"content": "via"
},
"href": {
"element": "string",
"content": "https://spec.openapis.org/oas/v2.0"
}
}
}
]
},
"title": {
"element": "string",
"content": "Consumes JSON with invalid content type"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,30 @@
}
]
},
"links": {
"element": "array",
"content": [
{
"element": "link",
"meta": {
"title": {
"element": "string",
"content": "OpenAPI 2"
}
},
"attributes": {
"relation": {
"element": "string",
"content": "via"
},
"href": {
"element": "string",
"content": "https://spec.openapis.org/oas/v2.0"
}
}
}
]
},
"title": {
"element": "string",
"attributes": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,30 @@
}
]
},
"links": {
"element": "array",
"content": [
{
"element": "link",
"meta": {
"title": {
"element": "string",
"content": "OpenAPI 2"
}
},
"attributes": {
"relation": {
"element": "string",
"content": "via"
},
"href": {
"element": "string",
"content": "https://spec.openapis.org/oas/v2.0"
}
}
}
]
},
"title": {
"element": "string",
"content": "Consumes Multipart Form Data with file"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,30 @@
}
]
},
"links": {
"element": "array",
"content": [
{
"element": "link",
"meta": {
"title": {
"element": "string",
"content": "OpenAPI 2"
}
},
"attributes": {
"relation": {
"element": "string",
"content": "via"
},
"href": {
"element": "string",
"content": "https://spec.openapis.org/oas/v2.0"
}
}
}
]
},
"title": {
"element": "string",
"attributes": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,30 @@
}
]
},
"links": {
"element": "array",
"content": [
{
"element": "link",
"meta": {
"title": {
"element": "string",
"content": "OpenAPI 2"
}
},
"attributes": {
"relation": {
"element": "string",
"content": "via"
},
"href": {
"element": "string",
"content": "https://spec.openapis.org/oas/v2.0"
}
}
}
]
},
"title": {
"element": "string",
"content": "Test API"
Expand Down
Loading