Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add reference related metadata to namespaces #538

Merged
merged 3 commits into from
Aug 2, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
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-value');

return BREAK;
},
},
});

export default $RefVisitor;
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import stampit from 'stampit';
import { always } from 'ramda';
import { ObjectElement, isStringElement } from 'apidom';

import ChannelItemElement from '../../../../elements/ChannelItem';
import FallbackVisitor from '../../FallbackVisitor';
Expand All @@ -13,6 +14,19 @@ const ChannelItemVisitor = stampit(FixedFieldsVisitor, FallbackVisitor, {
init() {
this.element = new ChannelItemElement();
},
methods: {
ObjectElement(objectElement: ObjectElement) {
// @ts-ignore
const result = FixedFieldsVisitor.compose.methods.ObjectElement.call(this, objectElement);

// mark this ChannelItemElement with reference metadata
if (isStringElement(this.element.$ref)) {
this.element.classes.push('reference-element');
}

return result;
},
},
});

export default ChannelItemVisitor;
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-value');

return BREAK;
},
},
});

export default $RefVisitor;
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import stampit from 'stampit';
import { always } from 'ramda';
import { ObjectElement, isStringElement } from 'apidom';

import ReferenceElement from '../../../../elements/Reference';
import FixedFieldsVisitor from '../../generics/FixedFieldsVisitor';
Expand All @@ -13,6 +14,19 @@ const ReferenceVisitor = stampit(FixedFieldsVisitor, FallbackVisitor, {
init() {
this.element = new ReferenceElement();
},
methods: {
ObjectElement(objectElement: ObjectElement) {
// @ts-ignore
const result = FixedFieldsVisitor.compose.methods.ObjectElement.call(this, objectElement);

// mark this ReferenceElement with reference metadata
if (isStringElement(this.element.$ref)) {
this.element.classes.push('reference-element');
}

return result;
},
},
});

export default ReferenceVisitor;
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
Expand Up @@ -136,7 +136,7 @@ import ExampleVisitor from './visitors/open-api-3-1/example';
import ExampleSummaryVisitor from './visitors/open-api-3-1/example/SummaryVisitor';
import ExampleDescriptionVisitor from './visitors/open-api-3-1/example/DescriptionVisitor';
import ExampleValueVisitor from './visitors/open-api-3-1/example/ValueVisitor';
import ExampleExternalValueVisitor from './visitors/open-api-3-1/example/ExaternalValueVisitor';
import ExampleExternalValueVisitor from './visitors/open-api-3-1/example/ExternalValueVisitor';
char0n marked this conversation as resolved.
Show resolved Hide resolved
import ExternalDocumentationVisitor from './visitors/open-api-3-1/external-documentation';
import ExternalDocumentationDescriptionVisitor from './visitors/open-api-3-1/external-documentation/DescriptionVisitor';
import ExternalDocumentationUrlVisitor from './visitors/open-api-3-1/external-documentation/UrlVisitor';
Expand Down

This file was deleted.

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

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

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

return BREAK;
},
},
});

export default ExternalValueVisitor;
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import stampit from 'stampit';
import { always } from 'ramda';
import { ObjectElement, isStringElement } from 'apidom';

import ExampleElement from '../../../../elements/Example';
import FallbackVisitor from '../../FallbackVisitor';
Expand All @@ -13,6 +14,19 @@ const ExampleVisitor = stampit(FixedFieldsVisitor, FallbackVisitor, {
init() {
this.element = new ExampleElement();
},
methods: {
ObjectElement(objectElement: ObjectElement) {
// @ts-ignore
const result = FixedFieldsVisitor.compose.methods.ObjectElement.call(this, objectElement);

// mark this ExampleElement with reference metadata
if (isStringElement(this.element.externalValue)) {
this.element.classes.push('reference-element');
}

return result;
},
},
});

export default ExampleVisitor;
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 OperationIdVisitor = FallbackVisitor;
const OperationIdVisitor = stampit(FallbackVisitor, {
methods: {
StringElement(stringElement: StringElement) {
this.element = stringElement.clone();
this.element.classes.push('reference-value');

return BREAK;
},
},
});

export default OperationIdVisitor;
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';

char0n marked this conversation as resolved.
Show resolved Hide resolved
const OperationRefVisitor = FallbackVisitor;
const OperationRefVisitor = stampit(FallbackVisitor, {
methods: {
StringElement(stringElement: StringElement) {
this.element = stringElement.clone();
this.element.classes.push('reference-value');

return BREAK;
},
},
});

export default OperationRefVisitor;
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import stampit from 'stampit';
import { always } from 'ramda';
import { isStringElement, ObjectElement } from 'apidom';

import LinkElement from '../../../../elements/Link';
import FallbackVisitor from '../../FallbackVisitor';
Expand All @@ -13,6 +14,19 @@ const LinkVisitor = stampit(FixedFieldsVisitor, FallbackVisitor, {
init() {
this.element = new LinkElement();
},
methods: {
ObjectElement(objectElement: ObjectElement) {
// @ts-ignore
const result = FixedFieldsVisitor.compose.methods.ObjectElement.call(this, objectElement);

// mark this LinkElement with reference metadata
if (isStringElement(this.element.operationId) || isStringElement(this.element.operationRef)) {
this.element.classes.push('reference-element');
}

return result;
},
},
});

export default LinkVisitor;
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-value');

return BREAK;
},
},
});

export default $RefVisitor;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import stampit from 'stampit';
import { always } from 'ramda';
import { StringElement, ObjectElement } from 'apidom';
import { StringElement, ObjectElement, isStringElement } from 'apidom';

import PathItemElement from '../../../../elements/PathItem';
import OperationElement from '../../../../elements/Operation';
Expand Down Expand Up @@ -29,6 +29,11 @@ const PathItemVisitor = stampit(FixedFieldsVisitor, FallbackVisitor, {
operationElement.setMetaProperty('httpMethod', httpMethodElementCS);
});

// mark this PathItemElement with reference metadata
if (isStringElement(this.element.$ref)) {
this.element.classes.push('reference-element');
}

return result;
},
},
Expand Down
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-value');

return BREAK;
},
},
});

export default $RefVisitor;
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import stampit from 'stampit';
import { always } from 'ramda';
import { ObjectElement, isStringElement } from 'apidom';

import ReferenceElement from '../../../../elements/Reference';
import FixedFieldsVisitor from '../../generics/FixedFieldsVisitor';
Expand All @@ -13,6 +14,19 @@ const ReferenceVisitor = stampit(FixedFieldsVisitor, FallbackVisitor, {
init() {
this.element = new ReferenceElement();
},
methods: {
ObjectElement(objectElement: ObjectElement) {
// @ts-ignore
const result = FixedFieldsVisitor.compose.methods.ObjectElement.call(this, objectElement);

// mark this ReferenceElement with reference metadata
if (isStringElement(this.element.$ref)) {
this.element.classes.push('reference-element');
}

return result;
},
},
});

export default ReferenceVisitor;
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-value');

return BREAK;
},
},
});

export default $refVisitor;
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,14 @@ const SchemaVisitor = stampit(FixedFieldsVisitor, ParentSchemaAwareVisitor, Fall
// for further processing consider this Schema Element as parent for all embedded Schema Elements
this.parent = this.element;
// @ts-ignore
return FixedFieldsVisitor.compose.methods.ObjectElement.call(this, objectElement);
const result = FixedFieldsVisitor.compose.methods.ObjectElement.call(this, objectElement);

// mark this SchemaElement with reference metadata
if (isStringElement(this.element.$ref)) {
this.element.classes.push('reference-element');
}

return result;
};

this.BooleanElement = function _BooleanElement(booleanElement: BooleanElement) {
Expand Down
Loading