diff --git a/README.md b/README.md index c97aa636..1b9f7aef 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,7 @@ To use swagger-ui you should take a look at the [source of swagger-ui html page] ``` * *discoveryUrl* parameter should point to a resource listing url as per [Swagger Spec](https://github.com/wordnik/swagger-core/wiki) * *dom_id parameter* is the the id of a dom element inside which SwaggerUi will put the user interface for swagger +* *booleanValues* SwaggerUI renders boolean data types as a dropdown. By default it provides a 'true' and 'false' string as the possible choices. You can use this parameter to change the values in dropdown to be something else, for example 0 and 1 by setting booleanValues to new Array(0, 1) * *docExpansion* controls how the API listing is displayed. It can be set to 'none' (default), 'list' (shows operations for each resource), or 'full' (fully expanded: shows operations and their details) * *onComplete* is a callback function parameter which can be passed to be notified of when SwaggerUI has completed rendering successfully. * *onFailure* is a callback function parameter which can be passed to be notified of when SwaggerUI encountered a failure was unable to render. diff --git a/lib/swagger.js b/lib/swagger.js index 37d33ce3..1c08e41a 100644 --- a/lib/swagger.js +++ b/lib/swagger.js @@ -41,6 +41,7 @@ this.failure = options.failure != null ? options.failure : function() {}; this.progress = options.progress != null ? options.progress : function() {}; this.headers = options.headers != null ? options.headers : {}; + this.booleanValues = options.booleanValues != null ? options.booleanValues : new Array('true', 'false'); this.discoveryUrl = this.suffixApiKey(this.discoveryUrl); if (options.success != null) { this.build(); @@ -263,6 +264,10 @@ for (_i = 0, _len = _ref.length; _i < _len; _i++) { parameter = _ref[_i]; parameter.name = parameter.name || parameter.dataType; + if (parameter.dataType.toLowerCase() === 'boolean') { + parameter.allowableValues = {}; + parameter.allowableValues.values = this.resource.api.booleanValues; + } if (parameter.allowableValues != null) { if (parameter.allowableValues.valueType === "RANGE") { parameter.isRange = true;