-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ns-openapi-3-1): finish OpenAPI Object
Closes #386
- Loading branch information
Showing
5 changed files
with
78 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
apidom/packages/apidom-ns-openapi-3-1/src/refractor/visitors/open-api-3-1/TagsVisitor.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import stampit from 'stampit'; | ||
import { ArrayElement, Element, BREAK } from 'apidom'; | ||
|
||
import SpecificationVisitor from '../SpecificationVisitor'; | ||
import FallbackVisitor from '../FallbackVisitor'; | ||
import { isTagLikeElement } from '../../predicates'; | ||
|
||
const TagsVisitor = stampit(SpecificationVisitor, FallbackVisitor, { | ||
init() { | ||
this.element = new ArrayElement(); | ||
}, | ||
methods: { | ||
ArrayElement(arrayElement: ArrayElement) { | ||
arrayElement.forEach((item: Element) => { | ||
const specPath = isTagLikeElement(item) ? ['document', 'objects', 'Tag'] : ['value']; | ||
const element = this.toRefractedElement(specPath); | ||
|
||
this.element.push(element); | ||
}); | ||
|
||
this.copyMetaAndAttributes(arrayElement, this.element); | ||
this.element.classes.push('tags'); | ||
|
||
return BREAK; | ||
}, | ||
}, | ||
}); | ||
|
||
export default TagsVisitor; |
39 changes: 39 additions & 0 deletions
39
apidom/packages/apidom-ns-openapi-3-1/src/refractor/visitors/open-api-3-1/WebhooksVisitor.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import stampit from 'stampit'; | ||
import { ObjectElement, Element } from 'apidom'; | ||
|
||
import ReferenceElement from '../../../elements/Reference'; | ||
import MapVisitor from '../generics/MapVisitor'; | ||
import FallbackVisitor from '../FallbackVisitor'; | ||
import { isPathItemLikeElement, isReferenceLikeElement } from '../../predicates'; | ||
import { isReferenceElement } from '../../../predicates'; | ||
|
||
const WebhooksVisitor = stampit(MapVisitor, FallbackVisitor, { | ||
props: { | ||
specPath: (element: Element) => { | ||
// eslint-disable-next-line no-nested-ternary | ||
return isReferenceLikeElement(element) | ||
? ['document', 'objects', 'Reference'] | ||
: isPathItemLikeElement(element) | ||
? ['document', 'objects', 'PathItem'] | ||
: ['value']; | ||
}, | ||
}, | ||
init() { | ||
this.element = new ObjectElement(); | ||
this.element.classes.push('webhooks'); | ||
}, | ||
methods: { | ||
ObjectElement(objectElement: ObjectElement) { | ||
// @ts-ignore | ||
const result = MapVisitor.compose.methods.ObjectElement.call(this, objectElement); | ||
|
||
this.element.filter(isReferenceElement).forEach((referenceElement: ReferenceElement) => { | ||
referenceElement.setMetaProperty('referenced-element', 'pathItem'); | ||
}); | ||
|
||
return result; | ||
}, | ||
}, | ||
}); | ||
|
||
export default WebhooksVisitor; |