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

1
.gitignore vendored
View File

@@ -10,3 +10,4 @@ swagger-ui.sublime-workspace
.idea .idea
.project .project
node_modules/* 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: 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.