Update docs
This commit is contained in:
24
README.md
24
README.md
@@ -73,12 +73,12 @@ You may choose to customize Swagger UI for your organization. Here is an overvie
|
|||||||
To use swagger-ui you should take a look at the [source of swagger-ui html page](https://github.com/swagger-api/swagger-ui/blob/master/dist/index.html) and customize it. This basically requires you to instantiate a SwaggerUi object and call load() on it as below:
|
To use swagger-ui you should take a look at the [source of swagger-ui html page](https://github.com/swagger-api/swagger-ui/blob/master/dist/index.html) and customize it. This basically requires you to instantiate a SwaggerUi object and call load() on it as below:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
window.swaggerUi = new SwaggerUi({
|
var swaggerUi = new SwaggerUi({
|
||||||
url:"http://petstore.swagger.io/v2/swagger.json",
|
url:"http://petstore.swagger.io/v2/swagger.json",
|
||||||
dom_id:"swagger-ui-container"
|
dom_id:"swagger-ui-container"
|
||||||
});
|
});
|
||||||
|
|
||||||
window.swaggerUi.load();
|
swaggerUi.load();
|
||||||
```
|
```
|
||||||
|
|
||||||
##### Parameters
|
##### Parameters
|
||||||
@@ -108,11 +108,11 @@ swagger-ui supports invocation of all HTTP methods APIs including GET, PUT, POST
|
|||||||
Header params are supported through a pluggable mechanism in [swagger-js](https://github.com/swagger-api/swagger-js). You can see the [index.html](https://github.com/swagger-api/swagger-ui/blob/master/dist/index.html) for a sample of how to dynamically set headers:
|
Header params are supported through a pluggable mechanism in [swagger-js](https://github.com/swagger-api/swagger-js). You can see the [index.html](https://github.com/swagger-api/swagger-ui/blob/master/dist/index.html) for a sample of how to dynamically set headers:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// add a new ApiKeyAuthorization when the api-key changes in the ui.
|
// add a new SwaggerClient.ApiKeyAuthorization when the api-key changes in the ui.
|
||||||
$('#input_apiKey').change(function() {
|
$('#input_apiKey').change(function() {
|
||||||
var key = $('#input_apiKey')[0].value;
|
var key = $('#input_apiKey')[0].value;
|
||||||
if(key && key.trim() != "") {
|
if(key && key.trim() != "") {
|
||||||
window.authorizations.add("key", new ApiKeyAuthorization("api_key", key, "header"));
|
swaggerUi.api.clientAuthorizations.add("key", new SwaggerClient.ApiKeyAuthorization("api_key", key, "header"));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
@@ -123,15 +123,15 @@ This will add header `api_key` with value `key` on every call to the server. Yo
|
|||||||
If you have some header parameters which you need to send with every request, use the headers as below:
|
If you have some header parameters which you need to send with every request, use the headers as below:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
window.authorizations.add("key", new ApiKeyAuthorization("Authorization", "XXXX", "header"));
|
swaggerUi.api.clientAuthorizations.add("key", new SwaggerClient.ApiKeyAuthorization("Authorization", "XXXX", "header"));
|
||||||
```
|
```
|
||||||
|
|
||||||
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
|
### Localization and translation
|
||||||
The localisation files are in the dist/lang directory.
|
The localization 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)
|
To enable translation you should append next two lines in your Swagger's index.html (or another entry point you use)
|
||||||
```html
|
```html
|
||||||
<script src='lang/translator.js' type='text/javascript'></script>
|
<script src='lang/translator.js' type='text/javascript'></script>
|
||||||
<script src='lang/en.js' type='text/javascript'></script>
|
<script src='lang/en.js' type='text/javascript'></script>
|
||||||
@@ -141,12 +141,12 @@ The first line script is a translator and the second one is your language lexeme
|
|||||||
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.
|
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:
|
To append new lexemex for translation you shoul do two things:
|
||||||
1. Add lexeme into the language file.
|
1. Add lexeme into the language file.
|
||||||
Example of new line: "new sentence":"translation of new sentence".
|
Example of new line: "new sentence":"translation of new sentence".
|
||||||
2. Mark this lexeme in source html with attribute data-sw-translate.
|
2. Mark this lexeme in source html with attribute data-sw-translate.
|
||||||
Example of changed source:
|
Example of changed source:
|
||||||
```html
|
```html
|
||||||
<anyHtmlTag data-sw-translate>new sentence</anyHtmlTag>
|
<anyHtmlTag data-sw-translate>new sentence</anyHtmlTag>
|
||||||
or <anyHtmlTag data-sw-translate value='new sentence'/>
|
or <anyHtmlTag data-sw-translate value='new sentence'/>
|
||||||
```
|
```
|
||||||
.
|
.
|
||||||
@@ -220,8 +220,6 @@ Create your own fork of [swagger-api/swagger-ui](https://github.com/swagger-api/
|
|||||||
|
|
||||||
To share your changes, [submit a pull request](https://github.com/swagger-api/swagger-ui/pull/new/master).
|
To share your changes, [submit a pull request](https://github.com/swagger-api/swagger-ui/pull/new/master).
|
||||||
|
|
||||||
Since the javascript files are compiled from coffeescript, please submit changes in the *.coffee files! We have to reject changes only in the .js files as they will be lost on each build of the ui.
|
|
||||||
|
|
||||||
## Change Log
|
## Change Log
|
||||||
Plsee see [releases](https://github.com/swagger-api/swagger-ui/releases) for change log.
|
Plsee see [releases](https://github.com/swagger-api/swagger-ui/releases) for change log.
|
||||||
|
|
||||||
|
|||||||
@@ -67,9 +67,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#input_apiKey').change(function() {
|
$('#input_apiKey').change(addApiKeyAuthorization);
|
||||||
addApiKeyAuthorization();
|
|
||||||
});
|
|
||||||
|
|
||||||
// if you have an apiKey you would like to pre-populate on the page for demonstration purposes...
|
// if you have an apiKey you would like to pre-populate on the page for demonstration purposes...
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user