-
Notifications
You must be signed in to change notification settings - Fork 228
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #345 from aleksey-a-maltsev/fix/extensions-multipl…
…e-webhooks fix(extensions): support multiple webhooks
- Loading branch information
Showing
6 changed files
with
111 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,31 @@ | ||
const swaggerJsdoc = require('../..'); | ||
const referenceSpecification = require('./reference-specification.json'); | ||
const webhooksSingleSpecification = require('./x-webhooks-single-reference-specification.json'); | ||
const webhooksMultipleSpecification = require('./x-webhooks-multiple-reference-specification.json'); | ||
|
||
describe('Example for using extensions', () => { | ||
it('should support x-webhooks', () => { | ||
it('should support single entry in x-webhooks', () => { | ||
const result = swaggerJsdoc({ | ||
swaggerDefinition: { | ||
info: { | ||
title: 'Example with extensions', | ||
version: '0.0.1', | ||
}, | ||
}, | ||
apis: ['./examples/extensions/example.js'], | ||
apis: ['./examples/extensions/x-webhooks-single.js'], | ||
}); | ||
expect(result).toEqual(referenceSpecification); | ||
expect(result).toEqual(webhooksSingleSpecification); | ||
}); | ||
|
||
it('should support multiple entries in x-webhooks', () => { | ||
const result = swaggerJsdoc({ | ||
swaggerDefinition: { | ||
info: { | ||
title: 'Example with extensions', | ||
version: '0.0.1', | ||
}, | ||
}, | ||
apis: ['./examples/extensions/x-webhooks-multiple.js'], | ||
}); | ||
expect(result).toEqual(webhooksMultipleSpecification); | ||
}); | ||
}); |
48 changes: 48 additions & 0 deletions
48
examples/extensions/x-webhooks-multiple-reference-specification.json
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,48 @@ | ||
{ | ||
"info": { "title": "Example with extensions", "version": "0.0.1" }, | ||
"swagger": "2.0", | ||
"paths": {}, | ||
"definitions": {}, | ||
"responses": {}, | ||
"parameters": {}, | ||
"securityDefinitions": {}, | ||
"tags": [], | ||
"x-webhooks": { | ||
"newCat": { | ||
"post": { | ||
"description": "Information about a new cat in the systems", | ||
"tags": ["pet"], | ||
"requestBody": { | ||
"content": { | ||
"application/json": { | ||
"schema": { "$ref": "#/components/schemas/Cat" } | ||
} | ||
} | ||
}, | ||
"responses": { | ||
"200": { | ||
"description": "Return a 200 status to indicate that the data was received successfully" | ||
} | ||
} | ||
} | ||
}, | ||
"newDog": { | ||
"post": { | ||
"description": "Information about a new dog in the systems", | ||
"tags": ["pet"], | ||
"requestBody": { | ||
"content": { | ||
"application/json": { | ||
"schema": { "$ref": "#/components/schemas/Dog" } | ||
} | ||
} | ||
}, | ||
"responses": { | ||
"200": { | ||
"description": "Return a 200 status to indicate that the data was received successfully" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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,41 @@ | ||
/* istanbul ignore file */ | ||
|
||
/** | ||
* Example of cat | ||
* | ||
* @swagger | ||
* x-webhooks: | ||
* newCat: | ||
* post: | ||
* description: Information about a new cat in the systems | ||
* tags: | ||
* - pet | ||
* requestBody: | ||
* content: | ||
* application/json: | ||
* schema: | ||
* $ref: "#/components/schemas/Cat" | ||
* responses: | ||
* "200": | ||
* description: Return a 200 status to indicate that the data was received successfully | ||
*/ | ||
|
||
/** | ||
* Example of dog | ||
* | ||
* @swagger | ||
* x-webhooks: | ||
* newDog: | ||
* post: | ||
* description: Information about a new dog in the systems | ||
* tags: | ||
* - pet | ||
* requestBody: | ||
* content: | ||
* application/json: | ||
* schema: | ||
* $ref: "#/components/schemas/Dog" | ||
* responses: | ||
* "200": | ||
* description: Return a 200 status to indicate that the data was received successfully | ||
*/ |
File renamed without changes.
File renamed without changes.
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