Skip to content
This repository was archived by the owner on Dec 27, 2024. It is now read-only.

Commit a5662e3

Browse files
committed
test: improve coverage of license and contact
1 parent 40785f4 commit a5662e3

4 files changed

Lines changed: 160 additions & 2 deletions

File tree

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ Is as easy as define the values in the "Edit Collection" form page inside the ta
235235

236236
![contact and license variables](images/variables.png)
237237

238-
The variables names will be in dot notation, for example for `contact` fields will be as `contact.name`, `contact.url`... Take into account that some of this fields are required as described in OpenAPI specs if not provided all the section will be ignored.
238+
The variables names will be in dot notation, for example for `contact` fields will be as `contact.name`, `contact.url`... Take into account that fields that are required by OpenAPI specs, as `contact.name`, if not provided then all the section will be ignored.
239239

240240
You can also customize this information using the [Info option](#info-(object)), note that info provided by options will overwrite the variables inside the Postman collection (has more priority) but values will be merged from both sources (postman variables and options).
241241

test/index.spec.js

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ const EXPECTED_SERVERS_OPTIONS = readFileSync('./test/resources/output/ServersOp
3636
const EXPECTED_NO_SERVERS = readFileSync('./test/resources/output/NoServers.yml', 'utf8')
3737
const EXPECTED_LICENSE_CONTACT = readFileSync('./test/resources/output/LicenseContact.yml', 'utf8')
3838
const EXPECTED_LICENSE_CONTACT_OPT = readFileSync('./test/resources/output/LicenseContactOpts.yml', 'utf8')
39+
const EXPECTED_LICENSE_CONTACT_PARTIAL = readFileSync('./test/resources/output/LicenseContactPartial.yml', 'utf8')
40+
const EXPECTED_LICENSE_CONTACT_PARTIAL_2 = readFileSync('./test/resources/output/LicenseContactPartial2.yml', 'utf8')
3941

4042
describe('Library specs', function () {
4143
afterEach('remove file', function () {
@@ -160,7 +162,7 @@ describe('Library specs', function () {
160162
equal(result, EXPECTED_LICENSE_CONTACT)
161163
})
162164

163-
it('should use license from options', async function () {
165+
it('should use license and contact from options', async function () {
164166
const result = await postmanToOpenApi(COLLECTION_LICENSE_CONTACT, OUTPUT_PATH,
165167
{
166168
info: {
@@ -177,4 +179,34 @@ describe('Library specs', function () {
177179
})
178180
equal(result, EXPECTED_LICENSE_CONTACT_OPT)
179181
})
182+
183+
it('should support optional params in license and contact options', async function () {
184+
const result = await postmanToOpenApi(COLLECTION_BASIC, OUTPUT_PATH,
185+
{
186+
info: {
187+
license: {
188+
name: 'MIT'
189+
},
190+
contact: {
191+
name: 'My Support'
192+
}
193+
}
194+
})
195+
equal(result, EXPECTED_LICENSE_CONTACT_PARTIAL)
196+
})
197+
198+
it('should support optional params in license and contact options (2)', async function () {
199+
const result = await postmanToOpenApi(COLLECTION_BASIC, OUTPUT_PATH,
200+
{
201+
info: {
202+
license: {
203+
name: 'MIT'
204+
},
205+
contact: {
206+
url: 'http://www.api.com/support'
207+
}
208+
}
209+
})
210+
equal(result, EXPECTED_LICENSE_CONTACT_PARTIAL_2)
211+
})
180212
})
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
openapi: 3.0.0
2+
info:
3+
title: Postman to OpenAPI
4+
description: Mi super test collection from postman
5+
version: 1.1.0
6+
contact:
7+
name: My Support
8+
license:
9+
name: MIT
10+
servers:
11+
- url: 'https://api.io'
12+
paths:
13+
/users:
14+
post:
15+
tags:
16+
- default
17+
summary: Create new User
18+
description: Create a new user into your amazing API
19+
requestBody:
20+
content:
21+
application/json:
22+
schema:
23+
type: object
24+
example:
25+
example: field
26+
other:
27+
data1: 'yes'
28+
data2: 'no'
29+
responses:
30+
'200':
31+
description: Successful response
32+
content:
33+
application/json: {}
34+
/posts:
35+
post:
36+
tags:
37+
- default
38+
summary: Create a post
39+
requestBody:
40+
content:
41+
text/plain: {}
42+
responses:
43+
'200':
44+
description: Successful response
45+
content:
46+
application/json: {}
47+
/note:
48+
post:
49+
tags:
50+
- default
51+
summary: Create a note
52+
description: Just an example of text raw body
53+
requestBody:
54+
content:
55+
application/json:
56+
schema:
57+
type: string
58+
example: This is an example Note
59+
responses:
60+
'200':
61+
description: Successful response
62+
content:
63+
application/json: {}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
openapi: 3.0.0
2+
info:
3+
title: Postman to OpenAPI
4+
description: Mi super test collection from postman
5+
version: 1.1.0
6+
contact:
7+
url: 'http://www.api.com/support'
8+
license:
9+
name: MIT
10+
servers:
11+
- url: 'https://api.io'
12+
paths:
13+
/users:
14+
post:
15+
tags:
16+
- default
17+
summary: Create new User
18+
description: Create a new user into your amazing API
19+
requestBody:
20+
content:
21+
application/json:
22+
schema:
23+
type: object
24+
example:
25+
example: field
26+
other:
27+
data1: 'yes'
28+
data2: 'no'
29+
responses:
30+
'200':
31+
description: Successful response
32+
content:
33+
application/json: {}
34+
/posts:
35+
post:
36+
tags:
37+
- default
38+
summary: Create a post
39+
requestBody:
40+
content:
41+
text/plain: {}
42+
responses:
43+
'200':
44+
description: Successful response
45+
content:
46+
application/json: {}
47+
/note:
48+
post:
49+
tags:
50+
- default
51+
summary: Create a note
52+
description: Just an example of text raw body
53+
requestBody:
54+
content:
55+
application/json:
56+
schema:
57+
type: string
58+
example: This is an example Note
59+
responses:
60+
'200':
61+
description: Successful response
62+
content:
63+
application/json: {}

0 commit comments

Comments
 (0)