Skip to content

Commit

Permalink
feat(core): add support for OAS3 Server object
Browse files Browse the repository at this point in the history
Closes APIARY-5855
  • Loading branch information
Marco Friso committed Mar 25, 2020
1 parent ab47beb commit 9f29628
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/api-elements/lib/elements/Category.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ class Category extends ArrayElement {
return this.children.filter(item => schemes.indexOf(item.element) !== -1);
}

/**
* @name hosts
* @type ArraySlice
* @memberof Category.prototype
*/
get hosts() {
return this.children.filter(item => item.element === 'hosts');

This comment has been minimized.

Copy link
@opichals

opichals May 25, 2020

Contributor

There are no tests for any of the getters so it is hard to judge.

@kylef @marcofriso Shouldn't this rather be

   return this.children.filter(item => item.classes.contains('hosts'));
}

metadata(value) {
const metadata = this.attributes.get('metadata');

Expand Down
23 changes: 23 additions & 0 deletions packages/api-elements/lib/elements/Resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@ class Resource extends ArrayElement {
this.element = 'resource';
}

/**
* @name hosts
* @type ArraySlice
* @memberof Resource.prototype
*/
get hosts() {
return this.attributes.get('hosts');
}

set hosts(value) {
this.attributes.set('hosts', value);
}

/**
* @name href
* @type StringElement
Expand Down Expand Up @@ -59,6 +72,16 @@ class Resource extends ArrayElement {
get dataStructure() {
return this.children.filter(item => item.element === 'dataStructure').first;
}

/**
* @name host
* @type StringElement
* @memberof ParseResult.prototype
*/
get host() {
return this.children
.filter(item => item.classes.contains('host'));
}
}

module.exports = Resource;
23 changes: 23 additions & 0 deletions packages/api-elements/lib/elements/Transition.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,19 @@ class Transition extends ArrayElement {
this.attributes.set('relation', value);
}

/**
* @name hosts
* @type ArraySlice
* @memberof Resource.prototype
*/
get hosts() {
return this.attributes.get('hosts');
}

set hosts(value) {
this.attributes.set('hosts', value);
}

/**
* @name href
* @type StringElement
Expand Down Expand Up @@ -116,6 +129,16 @@ class Transition extends ArrayElement {
get transactions() {
return this.children.filter(item => item.element === 'httpTransaction');
}

/**
* @name host
* @type StringElement
* @memberof ParseResult.prototype
*/
get host() {
return this.children
.filter(item => item.classes.contains('host'));
}
}

module.exports = Transition;

0 comments on commit 9f29628

Please sign in to comment.