-
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-2): add support for Tag Object (#3246)
Refs #3097
- Loading branch information
Showing
12 changed files
with
178 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,36 @@ | ||
import { ObjectElement, StringElement, Attributes, Meta } from '@swagger-api/apidom-core'; | ||
|
||
import ExternalDocumentationElement from './ExternalDocumentation'; | ||
|
||
class Tag extends ObjectElement { | ||
constructor(content?: Record<string, unknown>, meta?: Meta, attributes?: Attributes) { | ||
super(content, meta, attributes); | ||
this.element = 'tag'; | ||
} | ||
|
||
get name(): StringElement | undefined { | ||
return this.get('name'); | ||
} | ||
|
||
set name(name: StringElement | undefined) { | ||
this.set('name', name); | ||
} | ||
|
||
get description(): StringElement | undefined { | ||
return this.get('description'); | ||
} | ||
|
||
set description(description: StringElement | undefined) { | ||
this.set('description', description); | ||
} | ||
|
||
get externalDocs(): ExternalDocumentationElement | undefined { | ||
return this.get('externalDocs'); | ||
} | ||
|
||
set externalDocs(externalDocs: ExternalDocumentationElement | undefined) { | ||
this.set('externalDocs', externalDocs); | ||
} | ||
} | ||
|
||
export default Tag; |
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-openapi-2/src/refractor/visitors/open-api-2/tag/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 TagElement from '../../../../elements/Tag'; | ||
import FallbackVisitor from '../../FallbackVisitor'; | ||
import FixedFieldsVisitor from '../../generics/FixedFieldsVisitor'; | ||
|
||
const TagVisitor = stampit(FixedFieldsVisitor, FallbackVisitor, { | ||
props: { | ||
specPath: always(['document', 'objects', 'Tag']), | ||
canSupportSpecificationExtensions: true, | ||
}, | ||
init() { | ||
this.element = new TagElement(); | ||
}, | ||
}); | ||
|
||
export default TagVisitor; |
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-openapi-2/test/refractor/elements/Tag/__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 TagElement should refract to semantic ApiDOM tree 1`] = ` | ||
(TagElement | ||
(MemberElement | ||
(StringElement) | ||
(StringElement)) | ||
(MemberElement | ||
(StringElement) | ||
(StringElement)) | ||
(MemberElement | ||
(StringElement) | ||
(ExternalDocumentationElement))) | ||
`; |
20 changes: 20 additions & 0 deletions
20
packages/apidom-ns-openapi-2/test/refractor/elements/Tag/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 { TagElement } from '../../../../src'; | ||
|
||
describe('refractor', function () { | ||
context('elements', function () { | ||
context('TagElement', function () { | ||
specify('should refract to semantic ApiDOM tree', function () { | ||
const tagElement = TagElement.refract({ | ||
name: 'tag-name', | ||
description: 'tag-description', | ||
externalDocs: {}, | ||
}); | ||
|
||
expect(sexprs(tagElement)).toMatchSnapshot(); | ||
}); | ||
}); | ||
}); | ||
}); |