Skip to content

Commit

Permalink
feat: add reference related metadata to namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
frantuma committed Jul 30, 2021
1 parent 224e778 commit 63dc250
Show file tree
Hide file tree
Showing 7 changed files with 511 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
import stampit from 'stampit';
import { StringElement, BREAK } from 'apidom';

import FallbackVisitor from '../../FallbackVisitor';

const $RefVisitor = FallbackVisitor;
const $RefVisitor = stampit(FallbackVisitor, {
methods: {
StringElement(stringElement: StringElement) {
this.element = stringElement.clone();
this.element.classes.push('reference-field');

return BREAK;
},
},
});

export default $RefVisitor;
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const ServersVisitor = stampit(PatternedFieldsVisitor, FallbackVisitor, {
},
init() {
this.element = new ServersElement();
this.element.classes.push('servers');
},
});

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
import stampit from 'stampit';
import { StringElement, BREAK } from 'apidom';

import FallbackVisitor from '../../FallbackVisitor';

const $RefVisitor = FallbackVisitor;
const $RefVisitor = stampit(FallbackVisitor, {
methods: {
StringElement(stringElement: StringElement) {
this.element = stringElement.clone();
this.element.classes.push('reference-field');

return BREAK;
},
},
});

export default $RefVisitor;
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
import stampit from 'stampit';
import { StringElement, BREAK } from 'apidom';

import FallbackVisitor from '../../FallbackVisitor';

const $refVisitor = FallbackVisitor;
const $refVisitor = stampit(FallbackVisitor, {
methods: {
StringElement(stringElement: StringElement) {
this.element = stringElement.clone();
this.element.classes.push('reference-field');

return BREAK;
},
},
});

export default $refVisitor;
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,24 @@ const SchemaVisitor = stampit(FixedFieldsVisitor, ParentSchemaAwareVisitor, Fall
this.element.setMetaProperty('inherited$id', inherited$id);
};

const handle$ref = (objectElement: ObjectElement) => {
// get current $ref keyword
const $ref = objectElement.get('$ref')?.toValue();

// if it's a non empty strings
if (isNonEmptyString($ref)) {
this.element.classes.push('reference-element');
}
};

/**
* Public Api.
*/
this.ObjectElement = function _ObjectElement(objectElement: ObjectElement) {
this.element = new SchemaElement();
handle$schema(objectElement);
handle$id(objectElement);
handle$ref(objectElement);

// for further processing consider this Schema Element as parent for all embedded Schema Elements
this.parent = this.element;
Expand Down

Large diffs are not rendered by default.

0 comments on commit 63dc250

Please sign in to comment.