-
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 Criterion Object (#3407)
Refs #3392
- Loading branch information
1 parent
79d657f
commit f6b053e
Showing
12 changed files
with
180 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { StringElement, ObjectElement, Attributes, Meta } from '@swagger-api/apidom-core'; | ||
|
||
class Criterion extends ObjectElement { | ||
constructor(content?: Record<string, unknown>, meta?: Meta, attributes?: Attributes) { | ||
super(content, meta, attributes); | ||
this.element = 'criterion'; | ||
} | ||
|
||
get context(): StringElement | undefined { | ||
return this.get('context'); | ||
} | ||
|
||
set context(context: StringElement | undefined) { | ||
this.set('context', context); | ||
} | ||
|
||
get condition(): StringElement | undefined { | ||
return this.get('condition'); | ||
} | ||
|
||
set condition(condition: StringElement | undefined) { | ||
this.set('condition', condition); | ||
} | ||
|
||
get type(): StringElement | undefined { | ||
return this.get('type'); | ||
} | ||
|
||
set type(type: StringElement | undefined) { | ||
this.set('type', type); | ||
} | ||
} | ||
|
||
export default Criterion; |
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
18 changes: 18 additions & 0 deletions
18
packages/apidom-ns-workflows-1/src/refractor/visitors/workflows-1/criterion/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 CriterionElement from '../../../../elements/Criterion'; | ||
import FallbackVisitor from '../../FallbackVisitor'; | ||
import FixedFieldsVisitor from '../../generics/FixedFieldsVisitor'; | ||
|
||
const CriterionVisitor = stampit(FixedFieldsVisitor, FallbackVisitor, { | ||
props: { | ||
specPath: always(['document', 'objects', 'Criterion']), | ||
canSupportSpecificationExtensions: true, | ||
}, | ||
init() { | ||
this.element = new CriterionElement(); | ||
}, | ||
}); | ||
|
||
export default CriterionVisitor; |
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
14 changes: 14 additions & 0 deletions
14
packages/apidom-ns-workflows-1/test/refractor/elements/Criterion/__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,14 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`refractor elements CriterionElement should refract to semantic ApiDOM tree 1`] = ` | ||
(CriterionElement | ||
(MemberElement | ||
(StringElement) | ||
(StringElement)) | ||
(MemberElement | ||
(StringElement) | ||
(StringElement)) | ||
(MemberElement | ||
(StringElement) | ||
(StringElement))) | ||
`; |
20 changes: 20 additions & 0 deletions
20
packages/apidom-ns-workflows-1/test/refractor/elements/Criterion/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,20 @@ | ||
import { expect } from 'chai'; | ||
import { sexprs } from '@swagger-api/apidom-core'; | ||
|
||
import { CriterionElement } from '../../../../src'; | ||
|
||
describe('refractor', function () { | ||
context('elements', function () { | ||
context('CriterionElement', function () { | ||
specify('should refract to semantic ApiDOM tree', function () { | ||
const criterionElement = CriterionElement.refract({ | ||
context: '$statusCode', | ||
condition: '^200$', | ||
type: 'regex', | ||
}); | ||
|
||
expect(sexprs(criterionElement)).toMatchSnapshot(); | ||
}); | ||
}); | ||
}); | ||
}); |