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:
25
.gitignore
vendored
25
.gitignore
vendored
@@ -1,12 +1,13 @@
|
|||||||
.DS_STORE
|
.DS_STORE
|
||||||
*.ipr
|
*.ipr
|
||||||
*.iml
|
*.iml
|
||||||
*.iws
|
*.iws
|
||||||
web/
|
web/
|
||||||
lib/*.zip
|
lib/*.zip
|
||||||
version.properties
|
version.properties
|
||||||
.sass-cache
|
.sass-cache
|
||||||
swagger-ui.sublime-workspace
|
swagger-ui.sublime-workspace
|
||||||
.idea
|
.idea
|
||||||
.project
|
.project
|
||||||
node_modules/*
|
node_modules/*
|
||||||
|
/nbproject/private/
|
||||||
26
README.md
26
README.md
@@ -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:
|
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: 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
|
- lib: Contains javascript dependencies which swagger-ui depends on
|
||||||
- node_modules: Contains node modules which swagger-ui uses for its development.
|
- node_modules: Contains node modules which swagger-ui uses for its development.
|
||||||
- src
|
- 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).
|
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 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.
|
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.
|
||||||
|
|||||||
40
dist/lib/swagger-client.js
vendored
40
dist/lib/swagger-client.js
vendored
@@ -9,7 +9,7 @@ var ArrayModel = function(definition) {
|
|||||||
this.name = "arrayModel";
|
this.name = "arrayModel";
|
||||||
this.definition = definition || {};
|
this.definition = definition || {};
|
||||||
this.properties = [];
|
this.properties = [];
|
||||||
|
|
||||||
var requiredFields = definition.enum || [];
|
var requiredFields = definition.enum || [];
|
||||||
var innerType = definition.items;
|
var innerType = definition.items;
|
||||||
if(innerType) {
|
if(innerType) {
|
||||||
@@ -301,7 +301,7 @@ PrimitiveModel.prototype.getMockSignature = function(modelsToIgnore) {
|
|||||||
}
|
}
|
||||||
return returnVal;
|
return returnVal;
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Resolves a spec's remote references
|
* Resolves a spec's remote references
|
||||||
*/
|
*/
|
||||||
var Resolver = function (){};
|
var Resolver = function (){};
|
||||||
@@ -1721,7 +1721,7 @@ Property.prototype.toString = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var options = '';
|
var options = '';
|
||||||
var isArray = this.schema.type === 'array';
|
var isArray = this.schema.type === 'array';
|
||||||
var type;
|
var type;
|
||||||
|
|
||||||
@@ -1783,11 +1783,11 @@ Property.prototype.toString = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
options += optionHtml('Enum', enumString);
|
options += optionHtml('Enum', enumString);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.length > 0)
|
if (options.length > 0)
|
||||||
str = '<span class="propWrap">' + str + '<table class="optionsWrapper"><tr><th colspan="2">' + this.name + '</th></tr>' + options + '</table></span>';
|
str = '<span class="propWrap">' + str + '<table class="optionsWrapper"><tr><th colspan="2">' + this.name + '</th></tr>' + options + '</table></span>';
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1882,7 +1882,7 @@ SwaggerClient.prototype.finish = function() {
|
|||||||
this.isBuilt = true;
|
this.isBuilt = true;
|
||||||
this.selfReflect();
|
this.selfReflect();
|
||||||
this.success();
|
this.success();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
SwaggerClient.prototype.buildFrom1_1Spec = function (response) {
|
SwaggerClient.prototype.buildFrom1_1Spec = function (response) {
|
||||||
@@ -2173,11 +2173,11 @@ SwaggerResource.prototype.addOperations = function (resource_path, ops, consumes
|
|||||||
o.summary,
|
o.summary,
|
||||||
o.notes,
|
o.notes,
|
||||||
type,
|
type,
|
||||||
responseMessages,
|
responseMessages,
|
||||||
this,
|
this,
|
||||||
consumes,
|
consumes,
|
||||||
produces,
|
produces,
|
||||||
o.authorizations,
|
o.authorizations,
|
||||||
o.deprecated);
|
o.deprecated);
|
||||||
|
|
||||||
this.operations[op.nickname] = op;
|
this.operations[op.nickname] = op;
|
||||||
@@ -2674,15 +2674,15 @@ SwaggerOperation.prototype.urlify = function (args) {
|
|||||||
param = params[i];
|
param = params[i];
|
||||||
if(param.paramType === 'query') {
|
if(param.paramType === 'query') {
|
||||||
if (queryParams !== '')
|
if (queryParams !== '')
|
||||||
queryParams += '&';
|
queryParams += '&';
|
||||||
if (Array.isArray(param)) {
|
if (Array.isArray(param)) {
|
||||||
var output = '';
|
var output = '';
|
||||||
for(j = 0; j < param.length; j++) {
|
for(j = 0; j < param.length; j++) {
|
||||||
if(j > 0)
|
if(j > 0)
|
||||||
output += ',';
|
output += ',';
|
||||||
output += encodeURIComponent(param[j]);
|
output += encodeURIComponent(param[j]);
|
||||||
}
|
}
|
||||||
queryParams += encodeURIComponent(param.name) + '=' + output;
|
queryParams += encodeURIComponent(param.name) + '=' + output;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (typeof args[param.name] !== 'undefined') {
|
if (typeof args[param.name] !== 'undefined') {
|
||||||
@@ -2751,7 +2751,7 @@ SwaggerOperation.prototype.asCurl = function (args) {
|
|||||||
var results = [];
|
var results = [];
|
||||||
var i;
|
var i;
|
||||||
|
|
||||||
var headers = SwaggerRequest.prototype.setHeaders(args, {}, this);
|
var headers = SwaggerRequest.prototype.setHeaders(args, {}, this);
|
||||||
for(i = 0; i < this.parameters.length; i++) {
|
for(i = 0; i < this.parameters.length; i++) {
|
||||||
var param = this.parameters[i];
|
var param = this.parameters[i];
|
||||||
if(param.paramType && param.paramType === 'header' && args[param.name]) {
|
if(param.paramType && param.paramType === 'header' && args[param.name]) {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ var ArrayModel = function(definition) {
|
|||||||
this.name = "arrayModel";
|
this.name = "arrayModel";
|
||||||
this.definition = definition || {};
|
this.definition = definition || {};
|
||||||
this.properties = [];
|
this.properties = [];
|
||||||
|
|
||||||
var requiredFields = definition.enum || [];
|
var requiredFields = definition.enum || [];
|
||||||
var innerType = definition.items;
|
var innerType = definition.items;
|
||||||
if(innerType) {
|
if(innerType) {
|
||||||
@@ -301,7 +301,7 @@ PrimitiveModel.prototype.getMockSignature = function(modelsToIgnore) {
|
|||||||
}
|
}
|
||||||
return returnVal;
|
return returnVal;
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Resolves a spec's remote references
|
* Resolves a spec's remote references
|
||||||
*/
|
*/
|
||||||
var Resolver = function (){};
|
var Resolver = function (){};
|
||||||
@@ -1721,7 +1721,7 @@ Property.prototype.toString = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var options = '';
|
var options = '';
|
||||||
var isArray = this.schema.type === 'array';
|
var isArray = this.schema.type === 'array';
|
||||||
var type;
|
var type;
|
||||||
|
|
||||||
@@ -1783,11 +1783,11 @@ Property.prototype.toString = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
options += optionHtml('Enum', enumString);
|
options += optionHtml('Enum', enumString);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.length > 0)
|
if (options.length > 0)
|
||||||
str = '<span class="propWrap">' + str + '<table class="optionsWrapper"><tr><th colspan="2">' + this.name + '</th></tr>' + options + '</table></span>';
|
str = '<span class="propWrap">' + str + '<table class="optionsWrapper"><tr><th colspan="2">' + this.name + '</th></tr>' + options + '</table></span>';
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1882,7 +1882,7 @@ SwaggerClient.prototype.finish = function() {
|
|||||||
this.isBuilt = true;
|
this.isBuilt = true;
|
||||||
this.selfReflect();
|
this.selfReflect();
|
||||||
this.success();
|
this.success();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
SwaggerClient.prototype.buildFrom1_1Spec = function (response) {
|
SwaggerClient.prototype.buildFrom1_1Spec = function (response) {
|
||||||
@@ -2173,11 +2173,11 @@ SwaggerResource.prototype.addOperations = function (resource_path, ops, consumes
|
|||||||
o.summary,
|
o.summary,
|
||||||
o.notes,
|
o.notes,
|
||||||
type,
|
type,
|
||||||
responseMessages,
|
responseMessages,
|
||||||
this,
|
this,
|
||||||
consumes,
|
consumes,
|
||||||
produces,
|
produces,
|
||||||
o.authorizations,
|
o.authorizations,
|
||||||
o.deprecated);
|
o.deprecated);
|
||||||
|
|
||||||
this.operations[op.nickname] = op;
|
this.operations[op.nickname] = op;
|
||||||
@@ -2674,15 +2674,15 @@ SwaggerOperation.prototype.urlify = function (args) {
|
|||||||
param = params[i];
|
param = params[i];
|
||||||
if(param.paramType === 'query') {
|
if(param.paramType === 'query') {
|
||||||
if (queryParams !== '')
|
if (queryParams !== '')
|
||||||
queryParams += '&';
|
queryParams += '&';
|
||||||
if (Array.isArray(param)) {
|
if (Array.isArray(param)) {
|
||||||
var output = '';
|
var output = '';
|
||||||
for(j = 0; j < param.length; j++) {
|
for(j = 0; j < param.length; j++) {
|
||||||
if(j > 0)
|
if(j > 0)
|
||||||
output += ',';
|
output += ',';
|
||||||
output += encodeURIComponent(param[j]);
|
output += encodeURIComponent(param[j]);
|
||||||
}
|
}
|
||||||
queryParams += encodeURIComponent(param.name) + '=' + output;
|
queryParams += encodeURIComponent(param.name) + '=' + output;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (typeof args[param.name] !== 'undefined') {
|
if (typeof args[param.name] !== 'undefined') {
|
||||||
@@ -2751,7 +2751,7 @@ SwaggerOperation.prototype.asCurl = function (args) {
|
|||||||
var results = [];
|
var results = [];
|
||||||
var i;
|
var i;
|
||||||
|
|
||||||
var headers = SwaggerRequest.prototype.setHeaders(args, {}, this);
|
var headers = SwaggerRequest.prototype.setHeaders(args, {}, this);
|
||||||
for(i = 0; i < this.parameters.length; i++) {
|
for(i = 0; i < this.parameters.length; i++) {
|
||||||
var param = this.parameters[i];
|
var param = this.parameters[i];
|
||||||
if(param.paramType && param.paramType === 'header' && args[param.name]) {
|
if(param.paramType && param.paramType === 'header' && args[param.name]) {
|
||||||
|
|||||||
Reference in New Issue
Block a user