diff --git a/README.md b/README.md index cfc92841..2c2e9f33 100644 --- a/README.md +++ b/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: ```javascript - window.swaggerUi = new SwaggerUi({ + var swaggerUi = new SwaggerUi({ url:"http://petstore.swagger.io/v2/swagger.json", dom_id:"swagger-ui-container" }); - window.swaggerUi.load(); + swaggerUi.load(); ``` ##### 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: ```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() { var key = $('#input_apiKey')[0].value; 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: ```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). -### Localisation and translation -The localisation files are in the dist/lang directory. +### Localization and translation +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 @@ -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. 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". 2. Mark this lexeme in source html with attribute data-sw-translate. - Example of changed source: + Example of changed source: ```html - new sentence + new sentence or ``` . @@ -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). -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 Plsee see [releases](https://github.com/swagger-api/swagger-ui/releases) for change log. diff --git a/src/main/html/index.html b/src/main/html/index.html index 809749a7..daff2810 100644 --- a/src/main/html/index.html +++ b/src/main/html/index.html @@ -67,9 +67,7 @@ } } - $('#input_apiKey').change(function() { - addApiKeyAuthorization(); - }); + $('#input_apiKey').change(addApiKeyAuthorization); // if you have an apiKey you would like to pre-populate on the page for demonstration purposes... /*