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 1 commit
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,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 @@ -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,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,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,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,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 @@ -79,13 +79,22 @@ const SchemaVisitor = stampit(FixedFieldsVisitor, ParentSchemaAwareVisitor, Fall
this.element.setMetaProperty('inherited$id', inherited$id);
};

const appendReferenceMetadata = (objectElement: ObjectElement) => {
const $ref = objectElement.get('$ref')?.toValue();

if (isNonEmptyString($ref)) {
this.element.classes.push('reference-element');
char0n marked this conversation as resolved.
Show resolved Hide resolved
}
};

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

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