Skip to content

Commit e66cdaa

Browse files
frantumachar0n
authored andcommitted
feat: add reference related metadata to namespaces
1 parent 224e778 commit e66cdaa

File tree

13 files changed

+621
-12
lines changed

13 files changed

+621
-12
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
1+
import stampit from 'stampit';
2+
import { StringElement, BREAK } from 'apidom';
3+
14
import FallbackVisitor from '../../FallbackVisitor';
25

3-
const $RefVisitor = FallbackVisitor;
6+
const $RefVisitor = stampit(FallbackVisitor, {
7+
methods: {
8+
StringElement(stringElement: StringElement) {
9+
this.element = stringElement.clone();
10+
this.element.classes.push('reference-value');
11+
12+
return BREAK;
13+
},
14+
},
15+
});
416

517
export default $RefVisitor;
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
1+
import stampit from 'stampit';
2+
import { StringElement, BREAK } from 'apidom';
3+
14
import FallbackVisitor from '../../FallbackVisitor';
25

3-
const $RefVisitor = FallbackVisitor;
6+
const $RefVisitor = stampit(FallbackVisitor, {
7+
methods: {
8+
StringElement(stringElement: StringElement) {
9+
this.element = stringElement.clone();
10+
this.element.classes.push('reference-value');
11+
12+
return BREAK;
13+
},
14+
},
15+
});
416

517
export default $RefVisitor;

apidom/packages/apidom-ns-asyncapi-2-0/src/refractor/visitors/async-api-2-0/servers/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const ServersVisitor = stampit(PatternedFieldsVisitor, FallbackVisitor, {
1313
},
1414
init() {
1515
this.element = new ServersElement();
16+
this.element.classes.push('servers');
1617
},
1718
});
1819

apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/__snapshots__/index.ts.snap

+242
Large diffs are not rendered by default.

apidom/packages/apidom-ns-openapi-3-1/src/refractor/specification.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ import ExampleVisitor from './visitors/open-api-3-1/example';
136136
import ExampleSummaryVisitor from './visitors/open-api-3-1/example/SummaryVisitor';
137137
import ExampleDescriptionVisitor from './visitors/open-api-3-1/example/DescriptionVisitor';
138138
import ExampleValueVisitor from './visitors/open-api-3-1/example/ValueVisitor';
139-
import ExampleExternalValueVisitor from './visitors/open-api-3-1/example/ExaternalValueVisitor';
139+
import ExampleExternalValueVisitor from './visitors/open-api-3-1/example/ExternalValueVisitor';
140140
import ExternalDocumentationVisitor from './visitors/open-api-3-1/external-documentation';
141141
import ExternalDocumentationDescriptionVisitor from './visitors/open-api-3-1/external-documentation/DescriptionVisitor';
142142
import ExternalDocumentationUrlVisitor from './visitors/open-api-3-1/external-documentation/UrlVisitor';

apidom/packages/apidom-ns-openapi-3-1/src/refractor/visitors/open-api-3-1/example/ExaternalValueVisitor.ts

-5
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import stampit from 'stampit';
2+
import { StringElement, BREAK } from 'apidom';
3+
4+
import FallbackVisitor from '../../FallbackVisitor';
5+
6+
const ExternalValueVisitor = stampit(FallbackVisitor, {
7+
methods: {
8+
StringElement(stringElement: StringElement) {
9+
this.element = stringElement.clone();
10+
this.element.classes.push('reference-value');
11+
12+
return BREAK;
13+
},
14+
},
15+
});
16+
17+
export default ExternalValueVisitor;
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
1+
import stampit from 'stampit';
2+
import { StringElement, BREAK } from 'apidom';
3+
14
import FallbackVisitor from '../../FallbackVisitor';
25

3-
const OperationRefVisitor = FallbackVisitor;
6+
const OperationRefVisitor = stampit(FallbackVisitor, {
7+
methods: {
8+
StringElement(stringElement: StringElement) {
9+
this.element = stringElement.clone();
10+
this.element.classes.push('reference-value');
11+
12+
return BREAK;
13+
},
14+
},
15+
});
416

517
export default OperationRefVisitor;
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
1+
import stampit from 'stampit';
2+
import { StringElement, BREAK } from 'apidom';
3+
14
import FallbackVisitor from '../../FallbackVisitor';
25

3-
const $RefVisitor = FallbackVisitor;
6+
const $RefVisitor = stampit(FallbackVisitor, {
7+
methods: {
8+
StringElement(stringElement: StringElement) {
9+
this.element = stringElement.clone();
10+
this.element.classes.push('reference-value');
11+
12+
return BREAK;
13+
},
14+
},
15+
});
416

517
export default $RefVisitor;
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
1+
import stampit from 'stampit';
2+
import { StringElement, BREAK } from 'apidom';
3+
14
import FallbackVisitor from '../../FallbackVisitor';
25

3-
const $RefVisitor = FallbackVisitor;
6+
const $RefVisitor = stampit(FallbackVisitor, {
7+
methods: {
8+
StringElement(stringElement: StringElement) {
9+
this.element = stringElement.clone();
10+
this.element.classes.push('reference-value');
11+
12+
return BREAK;
13+
},
14+
},
15+
});
416

517
export default $RefVisitor;
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
1+
import stampit from 'stampit';
2+
import { StringElement, BREAK } from 'apidom';
3+
14
import FallbackVisitor from '../../FallbackVisitor';
25

3-
const $refVisitor = FallbackVisitor;
6+
const $refVisitor = stampit(FallbackVisitor, {
7+
methods: {
8+
StringElement(stringElement: StringElement) {
9+
this.element = stringElement.clone();
10+
this.element.classes.push('reference-value');
11+
12+
return BREAK;
13+
},
14+
},
15+
});
416

517
export default $refVisitor;

apidom/packages/apidom-ns-openapi-3-1/src/refractor/visitors/open-api-3-1/schema/index.ts

+9
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,22 @@ const SchemaVisitor = stampit(FixedFieldsVisitor, ParentSchemaAwareVisitor, Fall
7979
this.element.setMetaProperty('inherited$id', inherited$id);
8080
};
8181

82+
const appendReferenceMetadata = (objectElement: ObjectElement) => {
83+
const $ref = objectElement.get('$ref')?.toValue();
84+
85+
if (isNonEmptyString($ref)) {
86+
this.element.classes.push('reference-element');
87+
}
88+
};
89+
8290
/**
8391
* Public Api.
8492
*/
8593
this.ObjectElement = function _ObjectElement(objectElement: ObjectElement) {
8694
this.element = new SchemaElement();
8795
handle$schema(objectElement);
8896
handle$id(objectElement);
97+
appendReferenceMetadata(objectElement);
8998

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

0 commit comments

Comments
 (0)