Skip to content

Commit 9c86011

Browse files
authored
Merge pull request #646 from postmanlabs/fix/issue#643
Fixing issue #643 - Generated value for corresponding authorization should be an environment value.
2 parents 851645d + c3f0157 commit 9c86011

File tree

7 files changed

+343
-14
lines changed

7 files changed

+343
-14
lines changed

lib/schemaUtils.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,33 +1082,33 @@ module.exports = {
10821082
helper = {
10831083
type: 'basic',
10841084
basic: [
1085-
{ key: 'username', value: '<Basic Auth Username>' },
1086-
{ key: 'password', value: '<Basic Auth Password>' }
1085+
{ key: 'username', value: '{{basicAuthUsername}}' },
1086+
{ key: 'password', value: '{{basicAuthPassword}}' }
10871087
]
10881088
};
10891089
}
10901090
else if (_.toLower(securityDef.scheme) === 'bearer') {
10911091
helper = {
10921092
type: 'bearer',
1093-
bearer: [{ key: 'token', value: '<Bearer Token>' }]
1093+
bearer: [{ key: 'token', value: '{{bearerToken}}' }]
10941094
};
10951095
}
10961096
else if (_.toLower(securityDef.scheme) === 'digest') {
10971097
helper = {
10981098
type: 'digest',
10991099
digest: [
1100-
{ key: 'username', value: '<Digest Auth Username>' },
1101-
{ key: 'password', value: '<Digest Auth Password>' },
1102-
{ key: 'realm', value: '<realm>' }
1100+
{ key: 'username', value: '{{digestAuthUsername}}' },
1101+
{ key: 'password', value: '{{digestAuthPassword}}' },
1102+
{ key: 'realm', value: '{{realm}}' }
11031103
]
11041104
};
11051105
}
11061106
else if (_.toLower(securityDef.scheme) === 'oauth' || _.toLower(securityDef.scheme) === 'oauth1') {
11071107
helper = {
11081108
type: 'oauth1',
11091109
oauth1: [
1110-
{ key: 'consumerSecret', value: '<OAuth 1.0 Consumer Key>' },
1111-
{ key: 'consumerKey', value: '<OAuth 1.0 Consumer Secret>' },
1110+
{ key: 'consumerSecret', value: '{{consumerSecret}}' },
1111+
{ key: 'consumerKey', value: '{{consumerKey}}' },
11121112
{ key: 'addParamsToHeader', value: true }
11131113
]
11141114
};
@@ -1161,7 +1161,7 @@ module.exports = {
11611161
if (!_.isEmpty(flowObj.refreshUrl)) {
11621162
helper.oauth2.push({
11631163
key: 'redirect_uri',
1164-
value: _.isString(flowObj.refreshUrl) ? flowObj.refreshUrl : '{{OAuth2_CallbackURL}}'
1164+
value: _.isString(flowObj.refreshUrl) ? flowObj.refreshUrl : '{{oAuth2CallbackURL}}'
11651165
});
11661166
}
11671167

@@ -1170,7 +1170,7 @@ module.exports = {
11701170
if (!_.isEmpty(flowObj.tokenUrl)) {
11711171
helper.oauth2.push({
11721172
key: 'accessTokenUrl',
1173-
value: _.isString(flowObj.tokenUrl) ? flowObj.tokenUrl : '{{OAuth2_AccessTokenURL}}'
1173+
value: _.isString(flowObj.tokenUrl) ? flowObj.tokenUrl : '{{oAuth2AccessTokenURL}}'
11741174
});
11751175
}
11761176
}
@@ -1180,7 +1180,7 @@ module.exports = {
11801180
if (!_.isEmpty(flowObj.authorizationUrl)) {
11811181
helper.oauth2.push({
11821182
key: 'authUrl',
1183-
value: _.isString(flowObj.authorizationUrl) ? flowObj.authorizationUrl : '{{OAuth2_AuthURL}}'
1183+
value: _.isString(flowObj.authorizationUrl) ? flowObj.authorizationUrl : '{{oAuth2AuthURL}}'
11841184
});
11851185
}
11861186
}
@@ -1197,9 +1197,9 @@ module.exports = {
11971197
apikey: [
11981198
{
11991199
key: 'key',
1200-
value: _.isString(securityDef.name) ? securityDef.name : '<API Key Name>'
1200+
value: _.isString(securityDef.name) ? securityDef.name : '{{apiKeyName}}'
12011201
},
1202-
{ key: 'value', value: '<API Key>' },
1202+
{ key: 'value', value: '{{apiKey}}' },
12031203
{
12041204
key: 'in',
12051205
value: _.includes(['query', 'header'], securityDef.in) ? securityDef.in : 'header'
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
openapi: "3.0.0"
2+
info:
3+
version: 1.0.0
4+
title: Swagger Petstore
5+
license:
6+
name: MIT
7+
servers:
8+
- url: https://postman-echo.com/get
9+
security:
10+
- bear: []
11+
paths:
12+
/pets/{petId}:
13+
get:
14+
summary: Info for a specific pet
15+
operationId: showPetById
16+
tags:
17+
- pets
18+
parameters:
19+
- name: petId
20+
in: path
21+
required: true
22+
description: The id of the pet to retrieve
23+
schema:
24+
type: string
25+
responses:
26+
default:
27+
description: unexpected error
28+
content:
29+
application/json:
30+
schema:
31+
$ref: "#/components/schemas/Error"
32+
components:
33+
schemas:
34+
Error:
35+
type: object
36+
required:
37+
- code
38+
- message
39+
properties:
40+
code:
41+
type: integer
42+
format: int32
43+
message:
44+
type: string
45+
securitySchemes:
46+
bear:
47+
type: apiKey
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
openapi: "3.0.0"
2+
info:
3+
version: 1.0.0
4+
title: Swagger Petstore
5+
license:
6+
name: MIT
7+
servers:
8+
- url: https://postman-echo.com/get
9+
security:
10+
- bear: []
11+
paths:
12+
/pets/{petId}:
13+
get:
14+
summary: Info for a specific pet
15+
operationId: showPetById
16+
tags:
17+
- pets
18+
parameters:
19+
- name: petId
20+
in: path
21+
required: true
22+
description: The id of the pet to retrieve
23+
schema:
24+
type: string
25+
responses:
26+
default:
27+
description: unexpected error
28+
content:
29+
application/json:
30+
schema:
31+
$ref: "#/components/schemas/Error"
32+
components:
33+
schemas:
34+
Error:
35+
type: object
36+
required:
37+
- code
38+
- message
39+
properties:
40+
code:
41+
type: integer
42+
format: int32
43+
message:
44+
type: string
45+
securitySchemes:
46+
bear:
47+
type: http
48+
scheme: basic
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
openapi: "3.0.0"
2+
info:
3+
version: 1.0.0
4+
title: Swagger Petstore
5+
license:
6+
name: MIT
7+
servers:
8+
- url: https://postman-echo.com/get
9+
security:
10+
- bear: []
11+
paths:
12+
/pets/{petId}:
13+
get:
14+
summary: Info for a specific pet
15+
operationId: showPetById
16+
tags:
17+
- pets
18+
parameters:
19+
- name: petId
20+
in: path
21+
required: true
22+
description: The id of the pet to retrieve
23+
schema:
24+
type: string
25+
responses:
26+
default:
27+
description: unexpected error
28+
content:
29+
application/json:
30+
schema:
31+
$ref: "#/components/schemas/Error"
32+
components:
33+
schemas:
34+
Error:
35+
type: object
36+
required:
37+
- code
38+
- message
39+
properties:
40+
code:
41+
type: integer
42+
format: int32
43+
message:
44+
type: string
45+
securitySchemes:
46+
bear:
47+
type: http
48+
scheme: bearer
49+
bearerFormat: JWT
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
openapi: "3.0.0"
2+
info:
3+
version: 1.0.0
4+
title: Swagger Petstore
5+
license:
6+
name: MIT
7+
servers:
8+
- url: https://postman-echo.com/get
9+
security:
10+
- bear: []
11+
paths:
12+
/pets/{petId}:
13+
get:
14+
summary: Info for a specific pet
15+
operationId: showPetById
16+
tags:
17+
- pets
18+
parameters:
19+
- name: petId
20+
in: path
21+
required: true
22+
description: The id of the pet to retrieve
23+
schema:
24+
type: string
25+
responses:
26+
default:
27+
description: unexpected error
28+
content:
29+
application/json:
30+
schema:
31+
$ref: "#/components/schemas/Error"
32+
components:
33+
schemas:
34+
Error:
35+
type: object
36+
required:
37+
- code
38+
- message
39+
properties:
40+
code:
41+
type: integer
42+
format: int32
43+
message:
44+
type: string
45+
securitySchemes:
46+
bear:
47+
type: http
48+
scheme: digest
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
openapi: "3.0.0"
2+
info:
3+
version: 1.0.0
4+
title: Swagger Petstore
5+
license:
6+
name: MIT
7+
servers:
8+
- url: https://postman-echo.com/get
9+
security:
10+
- bear: []
11+
paths:
12+
/pets/{petId}:
13+
get:
14+
summary: Info for a specific pet
15+
operationId: showPetById
16+
tags:
17+
- pets
18+
parameters:
19+
- name: petId
20+
in: path
21+
required: true
22+
description: The id of the pet to retrieve
23+
schema:
24+
type: string
25+
responses:
26+
default:
27+
description: unexpected error
28+
content:
29+
application/json:
30+
schema:
31+
$ref: "#/components/schemas/Error"
32+
components:
33+
schemas:
34+
Error:
35+
type: object
36+
required:
37+
- code
38+
- message
39+
properties:
40+
code:
41+
type: integer
42+
format: int32
43+
message:
44+
type: string
45+
securitySchemes:
46+
bear:
47+
type: http
48+
scheme: oauth1

0 commit comments

Comments
 (0)