-
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-workflows-1): add support Workflows Spec Object (#3496)
Refs #3392
- Loading branch information
1 parent
69d0f95
commit 4a467cb
Showing
9 changed files
with
120 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
12 changes: 12 additions & 0 deletions
12
packages/apidom-ns-workflows-1/src/elements/nces/Workflows.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,12 @@ | ||
import { ArrayElement, Attributes, Meta } from '@swagger-api/apidom-core'; | ||
|
||
class Workflows extends ArrayElement { | ||
static primaryClass = 'workflows'; | ||
|
||
constructor(content?: Array<unknown>, meta?: Meta, attributes?: Attributes) { | ||
super(content, meta, attributes); | ||
this.classes.push(Workflows.primaryClass); | ||
} | ||
} | ||
|
||
export default Workflows; |
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
28 changes: 28 additions & 0 deletions
28
packages/apidom-ns-workflows-1/src/refractor/visitors/workflows-1/WorkflowsVisitor.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,28 @@ | ||
import stampit from 'stampit'; | ||
import { ArrayElement, Element, BREAK } from '@swagger-api/apidom-core'; | ||
|
||
import WorkflowsElement from '../../../elements/nces/Workflows'; | ||
import SpecificationVisitor from '../SpecificationVisitor'; | ||
import FallbackVisitor from '../FallbackVisitor'; | ||
|
||
const WorkflowsVisitor = stampit(SpecificationVisitor, FallbackVisitor, { | ||
init() { | ||
this.element = new WorkflowsElement(); | ||
}, | ||
methods: { | ||
ArrayElement(arrayElement: ArrayElement) { | ||
arrayElement.forEach((item: Element): void => { | ||
const specPath = ['document', 'objects', 'Workflow']; | ||
const element = this.toRefractedElement(specPath, item); | ||
|
||
this.element.push(element); | ||
}); | ||
|
||
this.copyMetaAndAttributes(arrayElement, this.element); | ||
|
||
return BREAK; | ||
}, | ||
}, | ||
}); | ||
|
||
export default WorkflowsVisitor; |
22 changes: 22 additions & 0 deletions
22
...s-workflows-1/test/refractor/elements/WorkflowsSpecification1/__snapshots__/index.ts.snap
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,22 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`refractor elements WorkflowsSpecification1Element should refract to semantic ApiDOM tree 1`] = ` | ||
(WorkflowsSpecification1Element | ||
(MemberElement | ||
(StringElement) | ||
(StringElement)) | ||
(MemberElement | ||
(StringElement) | ||
(InfoElement)) | ||
(MemberElement | ||
(StringElement) | ||
(ArrayElement | ||
(SourceDescriptionElement))) | ||
(MemberElement | ||
(StringElement) | ||
(ArrayElement | ||
(WorkflowElement))) | ||
(MemberElement | ||
(StringElement) | ||
(ComponentsElement))) | ||
`; |
22 changes: 22 additions & 0 deletions
22
packages/apidom-ns-workflows-1/test/refractor/elements/WorkflowsSpecification1/index.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,22 @@ | ||
import { expect } from 'chai'; | ||
import { sexprs } from '@swagger-api/apidom-core'; | ||
|
||
import { WorkflowsSpecification1Element } from '../../../../src'; | ||
|
||
describe('refractor', function () { | ||
context('elements', function () { | ||
context('WorkflowsSpecification1Element', function () { | ||
specify('should refract to semantic ApiDOM tree', function () { | ||
const workflowsSpecification1Element = WorkflowsSpecification1Element.refract({ | ||
workflowsSpec: '1.0.0', | ||
info: {}, | ||
sourceDescriptions: [{}], | ||
workflows: [{}], | ||
components: {}, | ||
}); | ||
|
||
expect(sexprs(workflowsSpecification1Element)).toMatchSnapshot(); | ||
}); | ||
}); | ||
}); | ||
}); |