-
Notifications
You must be signed in to change notification settings - Fork 14
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 for Components Object (#3456)
Refs #3392
- Loading branch information
1 parent
bac4850
commit 14dd260
Showing
16 changed files
with
236 additions
and
2 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { ObjectElement, Attributes, Meta } from '@swagger-api/apidom-core'; | ||
|
||
class Components extends ObjectElement { | ||
constructor(content?: Record<string, unknown>, meta?: Meta, attributes?: Attributes) { | ||
super(content, meta, attributes); | ||
this.element = 'components'; | ||
} | ||
|
||
get inputs(): ObjectElement | undefined { | ||
return this.get('inputs'); | ||
} | ||
|
||
set inputs(inputs: ObjectElement | undefined) { | ||
this.set('inputs', inputs); | ||
} | ||
|
||
get parameters(): ObjectElement | undefined { | ||
return this.get('parameters'); | ||
} | ||
|
||
set parameters(parameters: ObjectElement | undefined) { | ||
this.set('parameters', parameters); | ||
} | ||
} | ||
|
||
export default Components; |
12 changes: 12 additions & 0 deletions
12
packages/apidom-ns-workflows-1/src/elements/nces/ComponentsInputs.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 { ObjectElement, Attributes, Meta } from '@swagger-api/apidom-core'; | ||
|
||
class ComponentsInputs extends ObjectElement { | ||
static primaryClass = 'components-inputs'; | ||
|
||
constructor(content?: Record<string, unknown>, meta?: Meta, attributes?: Attributes) { | ||
super(content, meta, attributes); | ||
this.classes.push(ComponentsInputs.primaryClass); | ||
} | ||
} | ||
|
||
export default ComponentsInputs; |
12 changes: 12 additions & 0 deletions
12
packages/apidom-ns-workflows-1/src/elements/nces/ComponentsParameters.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 { ObjectElement, Attributes, Meta } from '@swagger-api/apidom-core'; | ||
|
||
class ComponentsParameters extends ObjectElement { | ||
static primaryClass = 'components-parameters'; | ||
|
||
constructor(content?: Record<string, unknown>, meta?: Meta, attributes?: Attributes) { | ||
super(content, meta, attributes); | ||
this.classes.push(ComponentsParameters.primaryClass); | ||
} | ||
} | ||
|
||
export default ComponentsParameters; |
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
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
17 changes: 17 additions & 0 deletions
17
...ages/apidom-ns-workflows-1/src/refractor/visitors/workflows-1/components/InputsVisitor.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,17 @@ | ||
import stampit from 'stampit'; | ||
import { always } from 'ramda'; | ||
|
||
import ComponentsInputsElement from '../../../../elements/nces/ComponentsInputs'; | ||
import MapVisitor from '../../generics/MapVisitor'; | ||
import FallbackVisitor from '../../FallbackVisitor'; | ||
|
||
const InputsVisitor = stampit(MapVisitor, FallbackVisitor, { | ||
props: { | ||
specPath: always(['document', 'objects', 'JSONSchema']), | ||
}, | ||
init() { | ||
this.element = new ComponentsInputsElement(); | ||
}, | ||
}); | ||
|
||
export default InputsVisitor; |
17 changes: 17 additions & 0 deletions
17
.../apidom-ns-workflows-1/src/refractor/visitors/workflows-1/components/ParametersVisitor.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,17 @@ | ||
import stampit from 'stampit'; | ||
import { always } from 'ramda'; | ||
|
||
import ComponentsParametersElement from '../../../../elements/nces/ComponentsParameters'; | ||
import FallbackVisitor from '../../FallbackVisitor'; | ||
import MapVisitor from '../../generics/MapVisitor'; | ||
|
||
const ParametersVisitor = stampit(MapVisitor, FallbackVisitor, { | ||
props: { | ||
specPath: always(['document', 'objects', 'Parameter']), | ||
}, | ||
init() { | ||
this.element = new ComponentsParametersElement(); | ||
}, | ||
}); | ||
|
||
export default ParametersVisitor; |
18 changes: 18 additions & 0 deletions
18
packages/apidom-ns-workflows-1/src/refractor/visitors/workflows-1/components/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,18 @@ | ||
import stampit from 'stampit'; | ||
import { always } from 'ramda'; | ||
|
||
import ComponentsElement from '../../../../elements/Components'; | ||
import FixedFieldsVisitor from '../../generics/FixedFieldsVisitor'; | ||
import FallbackVisitor from '../../FallbackVisitor'; | ||
|
||
const ComponentsVisitor = stampit(FixedFieldsVisitor, FallbackVisitor, { | ||
props: { | ||
specPath: always(['document', 'objects', 'Components']), | ||
canSupportSpecificationExtensions: true, | ||
}, | ||
init() { | ||
this.element = new ComponentsElement(); | ||
}, | ||
}); | ||
|
||
export default ComponentsVisitor; |
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
17 changes: 17 additions & 0 deletions
17
...ages/apidom-ns-workflows-1/test/refractor/elements/Components/__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,17 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`refractor elements ComponentsElement should refract to semantic ApiDOM tree 1`] = ` | ||
(ComponentsElement | ||
(MemberElement | ||
(StringElement) | ||
(ObjectElement | ||
(MemberElement | ||
(StringElement) | ||
(JSONSchemaDraft202012Element)))) | ||
(MemberElement | ||
(StringElement) | ||
(ObjectElement | ||
(MemberElement | ||
(StringElement) | ||
(ParameterElement))))) | ||
`; |
23 changes: 23 additions & 0 deletions
23
packages/apidom-ns-workflows-1/test/refractor/elements/Components/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,23 @@ | ||
import { expect } from 'chai'; | ||
import { sexprs } from '@swagger-api/apidom-core'; | ||
|
||
import { ComponentsElement } from '../../../../src'; | ||
|
||
describe('refractor', function () { | ||
context('elements', function () { | ||
context('ComponentsElement', function () { | ||
specify('should refract to semantic ApiDOM tree', function () { | ||
const componentsElement = ComponentsElement.refract({ | ||
inputs: { | ||
Schema1: {}, | ||
}, | ||
parameters: { | ||
Parameter1: {}, | ||
}, | ||
}); | ||
|
||
expect(sexprs(componentsElement)).toMatchSnapshot(); | ||
}); | ||
}); | ||
}); | ||
}); |