Skip to content

Commit 2f112ad

Browse files
committed
Add a blank option to enum values when field is not required
1 parent 0e6046a commit 2f112ad

File tree

6 files changed

+88
-4
lines changed

6 files changed

+88
-4
lines changed

dist/examples/leagues.raml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,35 @@ traits:
6161

6262
securedBy: [ null, basic, digest_auth, oauth_2_0, custom_scheme_1, custom_scheme_2 ]
6363

64+
/async:
65+
post:
66+
queryParameters:
67+
queryParam:
68+
type: string
69+
enum:
70+
- UPGRADE
71+
- PORT_NUMBER
72+
- UPDATE_FEATURES
73+
required: true
74+
headers:
75+
header:
76+
type: string
77+
enum:
78+
- UPGRADE
79+
- PORT_NUMBER
80+
- UPDATE_FEATURES
81+
required: false
82+
body:
83+
application/x-www-form-urlencoded:
84+
formParameters:
85+
formParam:
86+
type: string
87+
enum:
88+
- UPGRADE
89+
- PORT_NUMBER
90+
- UPDATE_FEATURES
91+
required: false
92+
6493
/teams:
6594
type: base
6695
is: [filterable]

dist/scripts/api-console-vendor.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68003,7 +68003,7 @@ function registerDefaultHelpers(instance) {
6800368003
if(context.hasOwnProperty(key)) {
6800468004
// We're running the iterations one step out of sync so we can detect
6800568005
// the last iteration without have to scan the object twice and create
68006-
// an itermediate keys array.
68006+
// an itermediate keys array.
6800768007
if (priorKey) {
6800868008
execIteration(priorKey, i-1);
6800968009
}
@@ -69047,4 +69047,4 @@ module.exports = function (str, locale) {
6904769047
exports.javascript = require('./javascript');
6904869048

6904969049
},{"./javascript":4}]},{},[62])(62)
69050-
});
69050+
});

dist/scripts/api-console.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@
225225
result += 'one of ';
226226
}
227227

228-
result += '(' + enumValues.join(', ') + ')';
228+
result += '(' + enumValues.filter(function (value) { return value !== ''; }).join(', ') + ')';
229229

230230
} else {
231231
result += parameter.type || '';
@@ -3464,6 +3464,19 @@ RAML.Inspector = (function() {
34643464
this.plain = copy(plain);
34653465
this.parameterized = parameterized;
34663466

3467+
var that = this;
3468+
3469+
Object.keys(this.plain).map(function (key) {
3470+
var data = that.plain[key].definitions[0];
3471+
3472+
if (typeof data.enum !== 'undefined') {
3473+
if (!data.required) {
3474+
var temp = [''];
3475+
data.enum = temp.concat(data.enum);
3476+
}
3477+
}
3478+
});
3479+
34673480
Object.keys(parameterized || {}).forEach(function(key) {
34683481
parameterized[key].created = [];
34693482
});

src/app/directives/documentation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
result += 'one of ';
108108
}
109109

110-
result += '(' + enumValues.join(', ') + ')';
110+
result += '(' + enumValues.filter(function (value) { return value !== ''; }).join(', ') + ')';
111111

112112
} else {
113113
result += parameter.type || '';

src/assets/examples/leagues.raml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,35 @@ traits:
6161

6262
securedBy: [ null, basic, digest_auth, oauth_2_0, custom_scheme_1, custom_scheme_2 ]
6363

64+
/async:
65+
post:
66+
queryParameters:
67+
queryParam:
68+
type: string
69+
enum:
70+
- UPGRADE
71+
- PORT_NUMBER
72+
- UPDATE_FEATURES
73+
required: true
74+
headers:
75+
header:
76+
type: string
77+
enum:
78+
- UPGRADE
79+
- PORT_NUMBER
80+
- UPDATE_FEATURES
81+
required: false
82+
body:
83+
application/x-www-form-urlencoded:
84+
formParameters:
85+
formParam:
86+
type: string
87+
enum:
88+
- UPGRADE
89+
- PORT_NUMBER
90+
- UPDATE_FEATURES
91+
required: false
92+
6493
/teams:
6594
type: base
6695
is: [filterable]

src/common/try_it/named_parameters.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,19 @@
3030
this.plain = copy(plain);
3131
this.parameterized = parameterized;
3232

33+
var that = this;
34+
35+
Object.keys(this.plain).map(function (key) {
36+
var data = that.plain[key].definitions[0];
37+
38+
if (typeof data.enum !== 'undefined') {
39+
if (!data.required) {
40+
var temp = [''];
41+
data.enum = temp.concat(data.enum);
42+
}
43+
}
44+
});
45+
3346
Object.keys(parameterized || {}).forEach(function(key) {
3447
parameterized[key].created = [];
3548
});

0 commit comments

Comments
 (0)