Merge branch 'kalinin-k-a-master' into develop_2.0

Conflicts:
	dist/lib/swagger-client.js
	lib/swagger-client.js
This commit is contained in:
Mohsen Azimi
2015-02-27 09:44:54 -08:00
4 changed files with 79 additions and 52 deletions

25
.gitignore vendored
View File

@@ -1,12 +1,13 @@
.DS_STORE
*.ipr
*.iml
*.iws
web/
lib/*.zip
version.properties
.sass-cache
swagger-ui.sublime-workspace
.idea
.project
node_modules/*
.DS_STORE
*.ipr
*.iml
*.iws
web/
lib/*.zip
version.properties
.sass-cache
swagger-ui.sublime-workspace
.idea
.project
node_modules/*
/nbproject/private/

View File

@@ -57,6 +57,7 @@ Once you open the Swagger UI, it will load the [Swagger Petstore](http://petstor
You may choose to customize Swagger UI for your organization. Here is an overview of whats in its various directories:
- dist: Contains a distribution which you can deploy on a server or load from your local machine.
- dist/lang: The swagger localisation
- lib: Contains javascript dependencies which swagger-ui depends on
- node_modules: Contains node modules which swagger-ui uses for its development.
- src
@@ -124,6 +125,31 @@ window.authorizations.add("key", new ApiKeyAuthorization("Authorization", "XXXX"
Note! You can pass multiple header params on a single request, just use unique names for them (`key` is used in the above example).
### Localisation and translation
The localisation files are in the dist/lang directory.
To enable translation you should append next two lines in your swagger's index.html (or another entry point you use)
```html
<script src='lang/translator.js' type='text/javascript'></script>
<script src='lang/en.js' type='text/javascript'></script>
```
The first line script is a translator and the second one is your language lexemes.
If you wish to append support for new language you just need to create lang/your_lang.js and fill it like it's done in existing files.
To append new lexemex for translation you shoul do two things:
1. Add lexeme into the language file.
Example of new line: "new sentence":"translation of new sentence".
2. Mark this lexeme in source html with attribute data-sw-translate.
Example of changed source:
```html
<anyHtmlTag data-sw-translate>new sentence</anyHtmlTag>
or <anyHtmlTag data-sw-translate value='new sentence'/>
```
.
At this moment only inner html, title-attribute and value-attribute are going to be translated.
## CORS Support
CORS is a technique to prevent websites from doing bad things with your personal data. Most browsers + javascript toolkits not only support CORS but enforce it, which has implications for your API server which supports Swagger.

View File

@@ -9,7 +9,7 @@ var ArrayModel = function(definition) {
this.name = "arrayModel";
this.definition = definition || {};
this.properties = [];
var requiredFields = definition.enum || [];
var innerType = definition.items;
if(innerType) {
@@ -301,7 +301,7 @@ PrimitiveModel.prototype.getMockSignature = function(modelsToIgnore) {
}
return returnVal;
};
/**
/**
* Resolves a spec's remote references
*/
var Resolver = function (){};
@@ -1721,7 +1721,7 @@ Property.prototype.toString = function() {
}
var options = '';
var options = '';
var isArray = this.schema.type === 'array';
var type;
@@ -1783,11 +1783,11 @@ Property.prototype.toString = function() {
}
options += optionHtml('Enum', enumString);
}
}
if (options.length > 0)
str = '<span class="propWrap">' + str + '<table class="optionsWrapper"><tr><th colspan="2">' + this.name + '</th></tr>' + options + '</table></span>';
return str;
};
@@ -1882,7 +1882,7 @@ SwaggerClient.prototype.finish = function() {
this.isBuilt = true;
this.selfReflect();
this.success();
}
}
};
SwaggerClient.prototype.buildFrom1_1Spec = function (response) {
@@ -2173,11 +2173,11 @@ SwaggerResource.prototype.addOperations = function (resource_path, ops, consumes
o.summary,
o.notes,
type,
responseMessages,
this,
consumes,
produces,
o.authorizations,
responseMessages,
this,
consumes,
produces,
o.authorizations,
o.deprecated);
this.operations[op.nickname] = op;
@@ -2674,15 +2674,15 @@ SwaggerOperation.prototype.urlify = function (args) {
param = params[i];
if(param.paramType === 'query') {
if (queryParams !== '')
queryParams += '&';
queryParams += '&';
if (Array.isArray(param)) {
var output = '';
for(j = 0; j < param.length; j++) {
if(j > 0)
output += ',';
output += encodeURIComponent(param[j]);
}
queryParams += encodeURIComponent(param.name) + '=' + output;
var output = '';
for(j = 0; j < param.length; j++) {
if(j > 0)
output += ',';
output += encodeURIComponent(param[j]);
}
queryParams += encodeURIComponent(param.name) + '=' + output;
}
else {
if (typeof args[param.name] !== 'undefined') {
@@ -2751,7 +2751,7 @@ SwaggerOperation.prototype.asCurl = function (args) {
var results = [];
var i;
var headers = SwaggerRequest.prototype.setHeaders(args, {}, this);
var headers = SwaggerRequest.prototype.setHeaders(args, {}, this);
for(i = 0; i < this.parameters.length; i++) {
var param = this.parameters[i];
if(param.paramType && param.paramType === 'header' && args[param.name]) {

View File

@@ -9,7 +9,7 @@ var ArrayModel = function(definition) {
this.name = "arrayModel";
this.definition = definition || {};
this.properties = [];
var requiredFields = definition.enum || [];
var innerType = definition.items;
if(innerType) {
@@ -301,7 +301,7 @@ PrimitiveModel.prototype.getMockSignature = function(modelsToIgnore) {
}
return returnVal;
};
/**
/**
* Resolves a spec's remote references
*/
var Resolver = function (){};
@@ -1721,7 +1721,7 @@ Property.prototype.toString = function() {
}
var options = '';
var options = '';
var isArray = this.schema.type === 'array';
var type;
@@ -1783,11 +1783,11 @@ Property.prototype.toString = function() {
}
options += optionHtml('Enum', enumString);
}
}
if (options.length > 0)
str = '<span class="propWrap">' + str + '<table class="optionsWrapper"><tr><th colspan="2">' + this.name + '</th></tr>' + options + '</table></span>';
return str;
};
@@ -1882,7 +1882,7 @@ SwaggerClient.prototype.finish = function() {
this.isBuilt = true;
this.selfReflect();
this.success();
}
}
};
SwaggerClient.prototype.buildFrom1_1Spec = function (response) {
@@ -2173,11 +2173,11 @@ SwaggerResource.prototype.addOperations = function (resource_path, ops, consumes
o.summary,
o.notes,
type,
responseMessages,
this,
consumes,
produces,
o.authorizations,
responseMessages,
this,
consumes,
produces,
o.authorizations,
o.deprecated);
this.operations[op.nickname] = op;
@@ -2674,15 +2674,15 @@ SwaggerOperation.prototype.urlify = function (args) {
param = params[i];
if(param.paramType === 'query') {
if (queryParams !== '')
queryParams += '&';
queryParams += '&';
if (Array.isArray(param)) {
var output = '';
for(j = 0; j < param.length; j++) {
if(j > 0)
output += ',';
output += encodeURIComponent(param[j]);
}
queryParams += encodeURIComponent(param.name) + '=' + output;
var output = '';
for(j = 0; j < param.length; j++) {
if(j > 0)
output += ',';
output += encodeURIComponent(param[j]);
}
queryParams += encodeURIComponent(param.name) + '=' + output;
}
else {
if (typeof args[param.name] !== 'undefined') {
@@ -2751,7 +2751,7 @@ SwaggerOperation.prototype.asCurl = function (args) {
var results = [];
var i;
var headers = SwaggerRequest.prototype.setHeaders(args, {}, this);
var headers = SwaggerRequest.prototype.setHeaders(args, {}, this);
for(i = 0; i < this.parameters.length; i++) {
var param = this.parameters[i];
if(param.paramType && param.paramType === 'header' && args[param.name]) {