diff --git a/apidom/packages/apidom-ns-asyncapi-2-0/src/refractor/visitors/async-api-2-0/channel-item/$RefVisitor.ts b/apidom/packages/apidom-ns-asyncapi-2-0/src/refractor/visitors/async-api-2-0/channel-item/$RefVisitor.ts index 89bcfcfd81..7d0e7425c2 100644 --- a/apidom/packages/apidom-ns-asyncapi-2-0/src/refractor/visitors/async-api-2-0/channel-item/$RefVisitor.ts +++ b/apidom/packages/apidom-ns-asyncapi-2-0/src/refractor/visitors/async-api-2-0/channel-item/$RefVisitor.ts @@ -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; diff --git a/apidom/packages/apidom-ns-asyncapi-2-0/src/refractor/visitors/async-api-2-0/channel-item/index.ts b/apidom/packages/apidom-ns-asyncapi-2-0/src/refractor/visitors/async-api-2-0/channel-item/index.ts index 3f0721e815..a1060febf2 100644 --- a/apidom/packages/apidom-ns-asyncapi-2-0/src/refractor/visitors/async-api-2-0/channel-item/index.ts +++ b/apidom/packages/apidom-ns-asyncapi-2-0/src/refractor/visitors/async-api-2-0/channel-item/index.ts @@ -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'; @@ -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; diff --git a/apidom/packages/apidom-ns-asyncapi-2-0/src/refractor/visitors/async-api-2-0/reference/$RefVisitor.ts b/apidom/packages/apidom-ns-asyncapi-2-0/src/refractor/visitors/async-api-2-0/reference/$RefVisitor.ts index 89bcfcfd81..7d0e7425c2 100644 --- a/apidom/packages/apidom-ns-asyncapi-2-0/src/refractor/visitors/async-api-2-0/reference/$RefVisitor.ts +++ b/apidom/packages/apidom-ns-asyncapi-2-0/src/refractor/visitors/async-api-2-0/reference/$RefVisitor.ts @@ -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; diff --git a/apidom/packages/apidom-ns-asyncapi-2-0/src/refractor/visitors/async-api-2-0/reference/index.ts b/apidom/packages/apidom-ns-asyncapi-2-0/src/refractor/visitors/async-api-2-0/reference/index.ts index 7ecc3f7d0e..0aac88ba6d 100644 --- a/apidom/packages/apidom-ns-asyncapi-2-0/src/refractor/visitors/async-api-2-0/reference/index.ts +++ b/apidom/packages/apidom-ns-asyncapi-2-0/src/refractor/visitors/async-api-2-0/reference/index.ts @@ -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'; @@ -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; diff --git a/apidom/packages/apidom-ns-asyncapi-2-0/src/refractor/visitors/async-api-2-0/servers/index.ts b/apidom/packages/apidom-ns-asyncapi-2-0/src/refractor/visitors/async-api-2-0/servers/index.ts index 84d4b82c89..0bab3d6279 100644 --- a/apidom/packages/apidom-ns-asyncapi-2-0/src/refractor/visitors/async-api-2-0/servers/index.ts +++ b/apidom/packages/apidom-ns-asyncapi-2-0/src/refractor/visitors/async-api-2-0/servers/index.ts @@ -13,6 +13,7 @@ const ServersVisitor = stampit(PatternedFieldsVisitor, FallbackVisitor, { }, init() { this.element = new ServersElement(); + this.element.classes.push('servers'); }, }); diff --git a/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/__snapshots__/index.ts.snap b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/__snapshots__/index.ts.snap index 5f3eb3e87d..9e016e337d 100644 --- a/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/__snapshots__/index.ts.snap +++ b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/__snapshots__/index.ts.snap @@ -396,6 +396,17 @@ exports[`refractor given generic ApiDOM object in AsyncApi 2.0 shape should refr }, "value": { "element": "servers", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "servers" + } + ] + } + }, "content": [ { "element": "member", @@ -945,6 +956,10 @@ exports[`refractor given generic ApiDOM object in AsyncApi 2.0 shape should refr { "element": "string", "content": "asyncapi-reference" + }, + { + "element": "string", + "content": "reference-element" } ] }, @@ -974,6 +989,17 @@ exports[`refractor given generic ApiDOM object in AsyncApi 2.0 shape should refr }, "value": { "element": "string", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-value" + } + ] + } + }, "content": "#/components/serverBindings/ServerBinding1" } } @@ -2098,6 +2124,10 @@ exports[`refractor given generic ApiDOM object in AsyncApi 2.0 shape should refr { "element": "string", "content": "asyncapi-reference" + }, + { + "element": "string", + "content": "reference-element" } ] }, @@ -2127,6 +2157,17 @@ exports[`refractor given generic ApiDOM object in AsyncApi 2.0 shape should refr }, "value": { "element": "string", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-value" + } + ] + } + }, "content": "#/components/schemas/user" } } @@ -2166,6 +2207,10 @@ exports[`refractor given generic ApiDOM object in AsyncApi 2.0 shape should refr { "element": "string", "content": "asyncapi-reference" + }, + { + "element": "string", + "content": "reference-element" } ] }, @@ -2195,6 +2240,17 @@ exports[`refractor given generic ApiDOM object in AsyncApi 2.0 shape should refr }, "value": { "element": "string", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-value" + } + ] + } + }, "content": "#/components/schemas/signup" } } @@ -3883,6 +3939,10 @@ exports[`refractor given generic ApiDOM object in AsyncApi 2.0 shape should refr { "element": "string", "content": "asyncapi-reference" + }, + { + "element": "string", + "content": "reference-element" } ] }, @@ -3912,6 +3972,17 @@ exports[`refractor given generic ApiDOM object in AsyncApi 2.0 shape should refr }, "value": { "element": "string", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-value" + } + ] + } + }, "content": "#/components/parameters/userId" } } @@ -3996,6 +4067,17 @@ exports[`refractor given generic ApiDOM object in AsyncApi 2.0 shape should refr }, "value": { "element": "channelItem", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-element" + } + ] + } + }, "content": [ { "element": "member", @@ -4017,6 +4099,17 @@ exports[`refractor given generic ApiDOM object in AsyncApi 2.0 shape should refr }, "value": { "element": "string", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-value" + } + ] + } + }, "content": "https://outside.com/#/path/to/channelItem" } } @@ -4430,6 +4523,10 @@ exports[`refractor given generic ApiDOM object in AsyncApi 2.0 shape should refr { "element": "string", "content": "asyncapi-reference" + }, + { + "element": "string", + "content": "reference-element" } ] }, @@ -4459,6 +4556,17 @@ exports[`refractor given generic ApiDOM object in AsyncApi 2.0 shape should refr }, "value": { "element": "string", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-value" + } + ] + } + }, "content": "#/components/operationTraits/OperationTrait1" } } @@ -4514,6 +4622,10 @@ exports[`refractor given generic ApiDOM object in AsyncApi 2.0 shape should refr { "element": "string", "content": "asyncapi-reference" + }, + { + "element": "string", + "content": "reference-element" } ] }, @@ -4543,6 +4655,17 @@ exports[`refractor given generic ApiDOM object in AsyncApi 2.0 shape should refr }, "value": { "element": "string", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-value" + } + ] + } + }, "content": "#/components/messages/Message1" } } @@ -4584,6 +4707,10 @@ exports[`refractor given generic ApiDOM object in AsyncApi 2.0 shape should refr { "element": "string", "content": "asyncapi-reference" + }, + { + "element": "string", + "content": "reference-element" } ] }, @@ -4613,6 +4740,17 @@ exports[`refractor given generic ApiDOM object in AsyncApi 2.0 shape should refr }, "value": { "element": "string", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-value" + } + ] + } + }, "content": "#/components/operationBindings/OperationBinding1" } } @@ -4799,6 +4937,10 @@ exports[`refractor given generic ApiDOM object in AsyncApi 2.0 shape should refr { "element": "string", "content": "asyncapi-reference" + }, + { + "element": "string", + "content": "reference-element" } ] }, @@ -4828,6 +4970,17 @@ exports[`refractor given generic ApiDOM object in AsyncApi 2.0 shape should refr }, "value": { "element": "string", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-value" + } + ] + } + }, "content": "#/components/parameters/userId" } } @@ -4871,6 +5024,10 @@ exports[`refractor given generic ApiDOM object in AsyncApi 2.0 shape should refr { "element": "string", "content": "asyncapi-reference" + }, + { + "element": "string", + "content": "reference-element" } ] }, @@ -4900,6 +5057,17 @@ exports[`refractor given generic ApiDOM object in AsyncApi 2.0 shape should refr }, "value": { "element": "string", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-value" + } + ] + } + }, "content": "#/components/channelBindings/ChannelBinding1" } } @@ -5049,6 +5217,10 @@ exports[`refractor given generic ApiDOM object in AsyncApi 2.0 shape should refr { "element": "string", "content": "asyncapi-reference" + }, + { + "element": "string", + "content": "reference-element" } ] }, @@ -5078,6 +5250,17 @@ exports[`refractor given generic ApiDOM object in AsyncApi 2.0 shape should refr }, "value": { "element": "string", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-value" + } + ] + } + }, "content": "#/components/schemas/Schema1" } } @@ -5176,6 +5359,10 @@ exports[`refractor given generic ApiDOM object in AsyncApi 2.0 shape should refr { "element": "string", "content": "asyncapi-reference" + }, + { + "element": "string", + "content": "reference-element" } ] }, @@ -5205,6 +5392,17 @@ exports[`refractor given generic ApiDOM object in AsyncApi 2.0 shape should refr }, "value": { "element": "string", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-value" + } + ] + } + }, "content": "#/components/messages/Message1" } } @@ -5303,6 +5501,10 @@ exports[`refractor given generic ApiDOM object in AsyncApi 2.0 shape should refr { "element": "string", "content": "asyncapi-reference" + }, + { + "element": "string", + "content": "reference-element" } ] }, @@ -5332,6 +5534,17 @@ exports[`refractor given generic ApiDOM object in AsyncApi 2.0 shape should refr }, "value": { "element": "string", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-value" + } + ] + } + }, "content": "#/components/securitySchemes/SecurityScheme1" } } @@ -5529,6 +5742,10 @@ exports[`refractor given generic ApiDOM object in AsyncApi 2.0 shape should refr { "element": "string", "content": "asyncapi-reference" + }, + { + "element": "string", + "content": "reference-element" } ] }, @@ -5558,6 +5775,17 @@ exports[`refractor given generic ApiDOM object in AsyncApi 2.0 shape should refr }, "value": { "element": "string", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-value" + } + ] + } + }, "content": "#/components/parameters/Parameter1" } } @@ -5656,6 +5884,10 @@ exports[`refractor given generic ApiDOM object in AsyncApi 2.0 shape should refr { "element": "string", "content": "asyncapi-reference" + }, + { + "element": "string", + "content": "reference-element" } ] }, @@ -5685,6 +5917,17 @@ exports[`refractor given generic ApiDOM object in AsyncApi 2.0 shape should refr }, "value": { "element": "string", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-value" + } + ] + } + }, "content": "#/components/correlationIds/CorrelationID1" } } @@ -5783,6 +6026,10 @@ exports[`refractor given generic ApiDOM object in AsyncApi 2.0 shape should refr { "element": "string", "content": "asyncapi-reference" + }, + { + "element": "string", + "content": "reference-element" } ] }, @@ -5812,6 +6059,17 @@ exports[`refractor given generic ApiDOM object in AsyncApi 2.0 shape should refr }, "value": { "element": "string", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-value" + } + ] + } + }, "content": "#/components/operationTraits/OperationTrait1" } } @@ -5910,6 +6168,10 @@ exports[`refractor given generic ApiDOM object in AsyncApi 2.0 shape should refr { "element": "string", "content": "asyncapi-reference" + }, + { + "element": "string", + "content": "reference-element" } ] }, @@ -5939,6 +6201,17 @@ exports[`refractor given generic ApiDOM object in AsyncApi 2.0 shape should refr }, "value": { "element": "string", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-value" + } + ] + } + }, "content": "#/components/messageTraits/MessageTrait1" } } @@ -6062,6 +6335,10 @@ exports[`refractor given generic ApiDOM object in AsyncApi 2.0 shape should refr { "element": "string", "content": "asyncapi-reference" + }, + { + "element": "string", + "content": "reference-element" } ] }, @@ -6091,6 +6368,17 @@ exports[`refractor given generic ApiDOM object in AsyncApi 2.0 shape should refr }, "value": { "element": "string", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-value" + } + ] + } + }, "content": "#/components/serverBindings/ServerBinding1" } } @@ -6214,6 +6502,10 @@ exports[`refractor given generic ApiDOM object in AsyncApi 2.0 shape should refr { "element": "string", "content": "asyncapi-reference" + }, + { + "element": "string", + "content": "reference-element" } ] }, @@ -6243,6 +6535,17 @@ exports[`refractor given generic ApiDOM object in AsyncApi 2.0 shape should refr }, "value": { "element": "string", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-value" + } + ] + } + }, "content": "#/components/channelBindings/ChannelBinding1" } } @@ -6366,6 +6669,10 @@ exports[`refractor given generic ApiDOM object in AsyncApi 2.0 shape should refr { "element": "string", "content": "asyncapi-reference" + }, + { + "element": "string", + "content": "reference-element" } ] }, @@ -6395,6 +6702,17 @@ exports[`refractor given generic ApiDOM object in AsyncApi 2.0 shape should refr }, "value": { "element": "string", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-value" + } + ] + } + }, "content": "#/components/operationBindings/OperationBinding1" } } @@ -6518,6 +6836,10 @@ exports[`refractor given generic ApiDOM object in AsyncApi 2.0 shape should refr { "element": "string", "content": "asyncapi-reference" + }, + { + "element": "string", + "content": "reference-element" } ] }, @@ -6547,6 +6869,17 @@ exports[`refractor given generic ApiDOM object in AsyncApi 2.0 shape should refr }, "value": { "element": "string", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-value" + } + ] + } + }, "content": "#/components/messageBindings/MessageBinding1" } } diff --git a/apidom/packages/apidom-ns-openapi-3-1/src/refractor/specification.ts b/apidom/packages/apidom-ns-openapi-3-1/src/refractor/specification.ts index 2a90119793..989ed044aa 100644 --- a/apidom/packages/apidom-ns-openapi-3-1/src/refractor/specification.ts +++ b/apidom/packages/apidom-ns-openapi-3-1/src/refractor/specification.ts @@ -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'; 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'; diff --git a/apidom/packages/apidom-ns-openapi-3-1/src/refractor/visitors/open-api-3-1/example/ExaternalValueVisitor.ts b/apidom/packages/apidom-ns-openapi-3-1/src/refractor/visitors/open-api-3-1/example/ExaternalValueVisitor.ts deleted file mode 100644 index 7ab03dfcf7..0000000000 --- a/apidom/packages/apidom-ns-openapi-3-1/src/refractor/visitors/open-api-3-1/example/ExaternalValueVisitor.ts +++ /dev/null @@ -1,5 +0,0 @@ -import FallbackVisitor from '../../FallbackVisitor'; - -const ExternalValueVisitor = FallbackVisitor; - -export default ExternalValueVisitor; diff --git a/apidom/packages/apidom-ns-openapi-3-1/src/refractor/visitors/open-api-3-1/example/ExternalValueVisitor.ts b/apidom/packages/apidom-ns-openapi-3-1/src/refractor/visitors/open-api-3-1/example/ExternalValueVisitor.ts new file mode 100644 index 0000000000..ca3f2b2972 --- /dev/null +++ b/apidom/packages/apidom-ns-openapi-3-1/src/refractor/visitors/open-api-3-1/example/ExternalValueVisitor.ts @@ -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; diff --git a/apidom/packages/apidom-ns-openapi-3-1/src/refractor/visitors/open-api-3-1/example/index.ts b/apidom/packages/apidom-ns-openapi-3-1/src/refractor/visitors/open-api-3-1/example/index.ts index 4977f960f8..b923fa55b6 100644 --- a/apidom/packages/apidom-ns-openapi-3-1/src/refractor/visitors/open-api-3-1/example/index.ts +++ b/apidom/packages/apidom-ns-openapi-3-1/src/refractor/visitors/open-api-3-1/example/index.ts @@ -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'; @@ -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; diff --git a/apidom/packages/apidom-ns-openapi-3-1/src/refractor/visitors/open-api-3-1/link/OperationIdVisitor.ts b/apidom/packages/apidom-ns-openapi-3-1/src/refractor/visitors/open-api-3-1/link/OperationIdVisitor.ts index 2f69218814..e89edb4d24 100644 --- a/apidom/packages/apidom-ns-openapi-3-1/src/refractor/visitors/open-api-3-1/link/OperationIdVisitor.ts +++ b/apidom/packages/apidom-ns-openapi-3-1/src/refractor/visitors/open-api-3-1/link/OperationIdVisitor.ts @@ -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; diff --git a/apidom/packages/apidom-ns-openapi-3-1/src/refractor/visitors/open-api-3-1/link/OperationRefVisitor.ts b/apidom/packages/apidom-ns-openapi-3-1/src/refractor/visitors/open-api-3-1/link/OperationRefVisitor.ts index f0da3483e4..f1aae5f439 100644 --- a/apidom/packages/apidom-ns-openapi-3-1/src/refractor/visitors/open-api-3-1/link/OperationRefVisitor.ts +++ b/apidom/packages/apidom-ns-openapi-3-1/src/refractor/visitors/open-api-3-1/link/OperationRefVisitor.ts @@ -1,5 +1,17 @@ +import stampit from 'stampit'; +import { StringElement, BREAK } from 'apidom'; + import FallbackVisitor from '../../FallbackVisitor'; -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; diff --git a/apidom/packages/apidom-ns-openapi-3-1/src/refractor/visitors/open-api-3-1/link/index.ts b/apidom/packages/apidom-ns-openapi-3-1/src/refractor/visitors/open-api-3-1/link/index.ts index 07766ae30c..8599c9cf49 100644 --- a/apidom/packages/apidom-ns-openapi-3-1/src/refractor/visitors/open-api-3-1/link/index.ts +++ b/apidom/packages/apidom-ns-openapi-3-1/src/refractor/visitors/open-api-3-1/link/index.ts @@ -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'; @@ -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; diff --git a/apidom/packages/apidom-ns-openapi-3-1/src/refractor/visitors/open-api-3-1/path-item/$RefVisitor.ts b/apidom/packages/apidom-ns-openapi-3-1/src/refractor/visitors/open-api-3-1/path-item/$RefVisitor.ts index 89bcfcfd81..7d0e7425c2 100644 --- a/apidom/packages/apidom-ns-openapi-3-1/src/refractor/visitors/open-api-3-1/path-item/$RefVisitor.ts +++ b/apidom/packages/apidom-ns-openapi-3-1/src/refractor/visitors/open-api-3-1/path-item/$RefVisitor.ts @@ -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; diff --git a/apidom/packages/apidom-ns-openapi-3-1/src/refractor/visitors/open-api-3-1/path-item/index.ts b/apidom/packages/apidom-ns-openapi-3-1/src/refractor/visitors/open-api-3-1/path-item/index.ts index 473b87df0c..7f4f3b3445 100644 --- a/apidom/packages/apidom-ns-openapi-3-1/src/refractor/visitors/open-api-3-1/path-item/index.ts +++ b/apidom/packages/apidom-ns-openapi-3-1/src/refractor/visitors/open-api-3-1/path-item/index.ts @@ -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'; @@ -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; }, }, diff --git a/apidom/packages/apidom-ns-openapi-3-1/src/refractor/visitors/open-api-3-1/reference/$RefVisitor.ts b/apidom/packages/apidom-ns-openapi-3-1/src/refractor/visitors/open-api-3-1/reference/$RefVisitor.ts index 89bcfcfd81..7d0e7425c2 100644 --- a/apidom/packages/apidom-ns-openapi-3-1/src/refractor/visitors/open-api-3-1/reference/$RefVisitor.ts +++ b/apidom/packages/apidom-ns-openapi-3-1/src/refractor/visitors/open-api-3-1/reference/$RefVisitor.ts @@ -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; diff --git a/apidom/packages/apidom-ns-openapi-3-1/src/refractor/visitors/open-api-3-1/reference/index.ts b/apidom/packages/apidom-ns-openapi-3-1/src/refractor/visitors/open-api-3-1/reference/index.ts index 7ecc3f7d0e..0aac88ba6d 100644 --- a/apidom/packages/apidom-ns-openapi-3-1/src/refractor/visitors/open-api-3-1/reference/index.ts +++ b/apidom/packages/apidom-ns-openapi-3-1/src/refractor/visitors/open-api-3-1/reference/index.ts @@ -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'; @@ -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; diff --git a/apidom/packages/apidom-ns-openapi-3-1/src/refractor/visitors/open-api-3-1/schema/$refVisitor.ts b/apidom/packages/apidom-ns-openapi-3-1/src/refractor/visitors/open-api-3-1/schema/$refVisitor.ts index 851788ae2d..4ccafd6642 100644 --- a/apidom/packages/apidom-ns-openapi-3-1/src/refractor/visitors/open-api-3-1/schema/$refVisitor.ts +++ b/apidom/packages/apidom-ns-openapi-3-1/src/refractor/visitors/open-api-3-1/schema/$refVisitor.ts @@ -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; diff --git a/apidom/packages/apidom-ns-openapi-3-1/src/refractor/visitors/open-api-3-1/schema/index.ts b/apidom/packages/apidom-ns-openapi-3-1/src/refractor/visitors/open-api-3-1/schema/index.ts index a4817798ed..6460e09385 100644 --- a/apidom/packages/apidom-ns-openapi-3-1/src/refractor/visitors/open-api-3-1/schema/index.ts +++ b/apidom/packages/apidom-ns-openapi-3-1/src/refractor/visitors/open-api-3-1/schema/index.ts @@ -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) { diff --git a/apidom/packages/apidom-ns-openapi-3-1/test/refractor/__snapshots__/index.ts.snap b/apidom/packages/apidom-ns-openapi-3-1/test/refractor/__snapshots__/index.ts.snap index 4ccf9e3fba..abb19eaea9 100644 --- a/apidom/packages/apidom-ns-openapi-3-1/test/refractor/__snapshots__/index.ts.snap +++ b/apidom/packages/apidom-ns-openapi-3-1/test/refractor/__snapshots__/index.ts.snap @@ -1201,6 +1201,10 @@ exports[`refractor given generic ApiDOM object in OpenApi 3.1 shape should refra { "element": "string", "content": "openapi-reference" + }, + { + "element": "string", + "content": "reference-element" } ] }, @@ -1230,6 +1234,17 @@ exports[`refractor given generic ApiDOM object in OpenApi 3.1 shape should refra }, "value": { "element": "string", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-value" + } + ] + } + }, "content": "#/components/parameters/parameter2" } } @@ -1492,6 +1507,17 @@ exports[`refractor given generic ApiDOM object in OpenApi 3.1 shape should refra }, "value": { "element": "example", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-element" + } + ] + } + }, "content": [ { "element": "member", @@ -1585,6 +1611,17 @@ exports[`refractor given generic ApiDOM object in OpenApi 3.1 shape should refra }, "value": { "element": "string", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-value" + } + ] + } + }, "content": "https://example1.com/" } } @@ -1620,6 +1657,10 @@ exports[`refractor given generic ApiDOM object in OpenApi 3.1 shape should refra { "element": "string", "content": "openapi-reference" + }, + { + "element": "string", + "content": "reference-element" } ] }, @@ -1649,6 +1690,17 @@ exports[`refractor given generic ApiDOM object in OpenApi 3.1 shape should refra }, "value": { "element": "string", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-value" + } + ] + } + }, "content": "#/components/examples/example3" } } @@ -1914,6 +1966,10 @@ exports[`refractor given generic ApiDOM object in OpenApi 3.1 shape should refra { "element": "string", "content": "openapi-reference" + }, + { + "element": "string", + "content": "reference-element" } ] }, @@ -1943,6 +1999,17 @@ exports[`refractor given generic ApiDOM object in OpenApi 3.1 shape should refra }, "value": { "element": "string", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-value" + } + ] + } + }, "content": "#/components/headers/Content-Type" } } @@ -2260,6 +2327,17 @@ exports[`refractor given generic ApiDOM object in OpenApi 3.1 shape should refra }, "value": { "element": "link", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-element" + } + ] + } + }, "content": [ { "element": "member", @@ -2281,6 +2359,17 @@ exports[`refractor given generic ApiDOM object in OpenApi 3.1 shape should refra }, "value": { "element": "string", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-value" + } + ] + } + }, "content": "https://example.com/external-link" } } @@ -2305,6 +2394,17 @@ exports[`refractor given generic ApiDOM object in OpenApi 3.1 shape should refra }, "value": { "element": "string", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-value" + } + ] + } + }, "content": "operationId-1" } } @@ -2471,6 +2571,10 @@ exports[`refractor given generic ApiDOM object in OpenApi 3.1 shape should refra { "element": "string", "content": "openapi-reference" + }, + { + "element": "string", + "content": "reference-element" } ] }, @@ -2500,6 +2604,17 @@ exports[`refractor given generic ApiDOM object in OpenApi 3.1 shape should refra }, "value": { "element": "string", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-value" + } + ] + } + }, "content": "#/components/links/link3" } } @@ -2543,6 +2658,10 @@ exports[`refractor given generic ApiDOM object in OpenApi 3.1 shape should refra { "element": "string", "content": "openapi-reference" + }, + { + "element": "string", + "content": "reference-element" } ] }, @@ -2572,6 +2691,17 @@ exports[`refractor given generic ApiDOM object in OpenApi 3.1 shape should refra }, "value": { "element": "string", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-value" + } + ] + } + }, "content": "#/components/responses/201" } } @@ -2984,6 +3114,10 @@ exports[`refractor given generic ApiDOM object in OpenApi 3.1 shape should refra { "element": "string", "content": "openapi-reference" + }, + { + "element": "string", + "content": "reference-element" } ] }, @@ -3013,6 +3147,17 @@ exports[`refractor given generic ApiDOM object in OpenApi 3.1 shape should refra }, "value": { "element": "string", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-value" + } + ] + } + }, "content": "#/components/callbacks/callback1" } } @@ -3427,6 +3572,10 @@ exports[`refractor given generic ApiDOM object in OpenApi 3.1 shape should refra { "element": "string", "content": "openapi-reference" + }, + { + "element": "string", + "content": "reference-element" } ] }, @@ -3456,6 +3605,17 @@ exports[`refractor given generic ApiDOM object in OpenApi 3.1 shape should refra }, "value": { "element": "string", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-value" + } + ] + } + }, "content": "#/components/requestBodies/requestBody1" } } @@ -3512,6 +3672,10 @@ exports[`refractor given generic ApiDOM object in OpenApi 3.1 shape should refra { "element": "string", "content": "openapi-reference" + }, + { + "element": "string", + "content": "reference-element" } ] }, @@ -3541,6 +3705,17 @@ exports[`refractor given generic ApiDOM object in OpenApi 3.1 shape should refra }, "value": { "element": "string", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-value" + } + ] + } + }, "content": "#/components/responses/201" } } @@ -4138,6 +4313,10 @@ exports[`refractor given generic ApiDOM object in OpenApi 3.1 shape should refra { "element": "string", "content": "openapi-reference" + }, + { + "element": "string", + "content": "reference-element" } ] }, @@ -4167,6 +4346,17 @@ exports[`refractor given generic ApiDOM object in OpenApi 3.1 shape should refra }, "value": { "element": "string", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-value" + } + ] + } + }, "content": "#/components/parameters/parameter2" } } @@ -4202,6 +4392,15 @@ exports[`refractor given generic ApiDOM object in OpenApi 3.1 shape should refra "value": { "element": "pathItem", "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-element" + } + ] + }, "path": { "element": "string", "content": "/path2" @@ -4276,6 +4475,17 @@ exports[`refractor given generic ApiDOM object in OpenApi 3.1 shape should refra }, "value": { "element": "string", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-value" + } + ] + } + }, "content": "#/components/pathItems/path2" } } @@ -4501,6 +4711,10 @@ exports[`refractor given generic ApiDOM object in OpenApi 3.1 shape should refra { "element": "string", "content": "openapi-reference" + }, + { + "element": "string", + "content": "reference-element" } ] }, @@ -4530,6 +4744,17 @@ exports[`refractor given generic ApiDOM object in OpenApi 3.1 shape should refra }, "value": { "element": "string", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-value" + } + ] + } + }, "content": "#/components/pathItems/path2" } } @@ -4680,6 +4905,15 @@ exports[`refractor given generic ApiDOM object in OpenApi 3.1 shape should refra }, "inherited$id": { "element": "array" + }, + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-element" + } + ] } }, "content": [ @@ -4703,6 +4937,17 @@ exports[`refractor given generic ApiDOM object in OpenApi 3.1 shape should refra }, "value": { "element": "string", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-value" + } + ] + } + }, "content": "#/components/schemas/schema1" } } @@ -4982,6 +5227,10 @@ exports[`refractor given generic ApiDOM object in OpenApi 3.1 shape should refra { "element": "string", "content": "openapi-reference" + }, + { + "element": "string", + "content": "reference-element" } ] }, @@ -5011,6 +5260,17 @@ exports[`refractor given generic ApiDOM object in OpenApi 3.1 shape should refra }, "value": { "element": "string", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-value" + } + ] + } + }, "content": "#/components/responses/201" } } @@ -5316,6 +5576,10 @@ exports[`refractor given generic ApiDOM object in OpenApi 3.1 shape should refra { "element": "string", "content": "openapi-reference" + }, + { + "element": "string", + "content": "reference-element" } ] }, @@ -5345,6 +5609,17 @@ exports[`refractor given generic ApiDOM object in OpenApi 3.1 shape should refra }, "value": { "element": "string", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-value" + } + ] + } + }, "content": "#/components/parameters/parameter2" } } @@ -5409,6 +5684,17 @@ exports[`refractor given generic ApiDOM object in OpenApi 3.1 shape should refra }, "value": { "element": "example", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-element" + } + ] + } + }, "content": [ { "element": "member", @@ -5502,6 +5788,17 @@ exports[`refractor given generic ApiDOM object in OpenApi 3.1 shape should refra }, "value": { "element": "string", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-value" + } + ] + } + }, "content": "https://example3.com/" } } @@ -5537,6 +5834,10 @@ exports[`refractor given generic ApiDOM object in OpenApi 3.1 shape should refra { "element": "string", "content": "openapi-reference" + }, + { + "element": "string", + "content": "reference-element" } ] }, @@ -5566,6 +5867,17 @@ exports[`refractor given generic ApiDOM object in OpenApi 3.1 shape should refra }, "value": { "element": "string", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-value" + } + ] + } + }, "content": "#/components/examples/example3" } } @@ -5710,6 +6022,10 @@ exports[`refractor given generic ApiDOM object in OpenApi 3.1 shape should refra { "element": "string", "content": "openapi-reference" + }, + { + "element": "string", + "content": "reference-element" } ] }, @@ -5739,6 +6055,17 @@ exports[`refractor given generic ApiDOM object in OpenApi 3.1 shape should refra }, "value": { "element": "string", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-value" + } + ] + } + }, "content": "#/components/requestBodies/requestBody1" } } @@ -5923,6 +6250,10 @@ exports[`refractor given generic ApiDOM object in OpenApi 3.1 shape should refra { "element": "string", "content": "openapi-reference" + }, + { + "element": "string", + "content": "reference-element" } ] }, @@ -5952,6 +6283,17 @@ exports[`refractor given generic ApiDOM object in OpenApi 3.1 shape should refra }, "value": { "element": "string", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-value" + } + ] + } + }, "content": "#/components/headers/Content-Type" } } @@ -6242,6 +6584,10 @@ exports[`refractor given generic ApiDOM object in OpenApi 3.1 shape should refra { "element": "string", "content": "openapi-reference" + }, + { + "element": "string", + "content": "reference-element" } ] }, @@ -6271,6 +6617,17 @@ exports[`refractor given generic ApiDOM object in OpenApi 3.1 shape should refra }, "value": { "element": "string", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-value" + } + ] + } + }, "content": "#/components/securitySchemes/securityScheme1" } } @@ -6391,6 +6748,10 @@ exports[`refractor given generic ApiDOM object in OpenApi 3.1 shape should refra { "element": "string", "content": "openapi-reference" + }, + { + "element": "string", + "content": "reference-element" } ] }, @@ -6420,6 +6781,17 @@ exports[`refractor given generic ApiDOM object in OpenApi 3.1 shape should refra }, "value": { "element": "string", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-value" + } + ] + } + }, "content": "#/components/links/link4" } } @@ -6832,6 +7204,10 @@ exports[`refractor given generic ApiDOM object in OpenApi 3.1 shape should refra { "element": "string", "content": "openapi-reference" + }, + { + "element": "string", + "content": "reference-element" } ] }, @@ -6861,6 +7237,17 @@ exports[`refractor given generic ApiDOM object in OpenApi 3.1 shape should refra }, "value": { "element": "string", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-value" + } + ] + } + }, "content": "#/components/callbacks/callback1" } } @@ -7080,6 +7467,10 @@ exports[`refractor given generic ApiDOM object in OpenApi 3.1 shape should refra { "element": "string", "content": "openapi-reference" + }, + { + "element": "string", + "content": "reference-element" } ] }, @@ -7109,6 +7500,17 @@ exports[`refractor given generic ApiDOM object in OpenApi 3.1 shape should refra }, "value": { "element": "string", + "meta": { + "classes": { + "element": "array", + "content": [ + { + "element": "string", + "content": "reference-value" + } + ] + } + }, "content": "#/components/pathItems/path2" } }