-
Notifications
You must be signed in to change notification settings - Fork 17
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 Responses Definitions Object (#3294)
Refs #3097
- Loading branch information
Showing
12 changed files
with
145 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
10 changes: 10 additions & 0 deletions
10
packages/apidom-ns-openapi-2/src/elements/ResponsesDefinitions.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,10 @@ | ||
import { ObjectElement, Attributes, Meta } from '@swagger-api/apidom-core'; | ||
|
||
class ResponsesDefinitions extends ObjectElement { | ||
constructor(content?: Record<string, unknown>, meta?: Meta, attributes?: Attributes) { | ||
super(content, meta, attributes); | ||
this.element = 'responsesDefinitions'; | ||
} | ||
} | ||
|
||
export default ResponsesDefinitions; |
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-openapi-2/src/refractor/visitors/open-api-2/responses-definitions/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,17 @@ | ||
import stampit from 'stampit'; | ||
import { always } from 'ramda'; | ||
|
||
import ResponsesDefinitionsElement from '../../../../elements/ResponsesDefinitions'; | ||
import MapVisitor from '../../generics/MapVisitor'; | ||
import FallbackVisitor from '../../FallbackVisitor'; | ||
|
||
const ResponsesDefinitionsVisitor = stampit(MapVisitor, FallbackVisitor, { | ||
props: { | ||
specPath: always(['document', 'objects', 'Response']), | ||
}, | ||
init() { | ||
this.element = new ResponsesDefinitionsElement(); | ||
}, | ||
}); | ||
|
||
export default ResponsesDefinitionsVisitor; |
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
11 changes: 11 additions & 0 deletions
11
...dom-ns-openapi-2/test/refractor/elements/ResponsesDefinitions/__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,11 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`refractor elements ResponsesDefinitionsElement should refract to semantic ApiDOM tree 1`] = ` | ||
(ResponsesDefinitionsElement | ||
(MemberElement | ||
(StringElement) | ||
(ResponseElement)) | ||
(MemberElement | ||
(StringElement) | ||
(ResponseElement))) | ||
`; |
19 changes: 19 additions & 0 deletions
19
packages/apidom-ns-openapi-2/test/refractor/elements/ResponsesDefinitions/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,19 @@ | ||
import { expect } from 'chai'; | ||
import { sexprs } from '@swagger-api/apidom-core'; | ||
|
||
import { ResponsesDefinitionsElement } from '../../../../src'; | ||
|
||
describe('refractor', function () { | ||
context('elements', function () { | ||
context('ResponsesDefinitionsElement', function () { | ||
specify('should refract to semantic ApiDOM tree', function () { | ||
const responsesDefinitionsElement = ResponsesDefinitionsElement.refract({ | ||
response1: {}, | ||
response2: {}, | ||
}); | ||
|
||
expect(sexprs(responsesDefinitionsElement)).toMatchSnapshot(); | ||
}); | ||
}); | ||
}); | ||
}); |