Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

před 13 roky
před 12 roky
před 11 roky
před 12 roky
před 13 roky
před 13 roky
před 12 roky
před 11 roky
před 13 roky
před 12 roky
před 13 roky
před 12 roky
před 13 roky
před 12 roky
před 11 roky
před 11 roky
před 12 roky
před 12 roky
před 12 roky
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. Swagger UI
  2. ==========
  3. Swagger UI is part of [Swagger](http://swagger.wordnik.com/) project. The Swagger project allows you to produce, visualize and consume your OWN RESTful
  4. services. No proxy or 3rd party services required. Do it your own way.
  5. Swagger UI is a dependency-free collection of HTML, Javascript, and CSS assets that dynamically
  6. generate beautiful documentation and sandbox from a [Swagger-compliant](https://github.com/wordnik/swagger-core/wiki) API. Because Swagger UI has no
  7. dependencies, you can host it in any server environment, or on your local machine.
  8. How to Use It
  9. -------------
  10. ### Download
  11. You can use the swagger-ui code AS-IS! No need to build or recompile--just [download](https://github.com/wordnik/swagger-ui/dist) the distribution and start using it. If you like swagger-ui as-is, stop here.
  12. ### Build
  13. You can rebuild swagger-ui on your own to tweak it or just so you can say you did. To do so, follow these steps:
  14. 1. npm install
  15. 2. npm run-script build
  16. 3. You should see the distribution under the dist folder. Open ./dist/index.html to launch Swagger UI in a browser
  17. ### Use
  18. Once you open the Swagger UI, it will load the [Swagger Petstore](http://petstore.swagger.wordnik.com/api/resources.json) service and show its APIs.
  19. You can enter your own server url and click explore to view the API.
  20. ### Customize
  21. You may choose to customize Swagger UI for your organization. Here is an overview of whats in its various directories:
  22. - dist: Contains a distribution which you can deploy on a server or load from your local machine.
  23. - bin: Contains files used by swagger-ui for its build/test. These are not required by the distribution.
  24. - lib: Contains javascript dependencies which swagger-ui depends on
  25. - node_modules: Contains node modules which swagger-ui uses for its development.
  26. - src
  27. - src/main/coffeescript: main code in CoffeeScript
  28. - src/main/templates: [handlebars](http://handlebarsjs.com/) templates used to render swagger-ui
  29. - src/main/html: the html files, some images and css
  30. - src/main/javascript: some legacy javascript referenced by CofffeeScript code
  31. ### SwaggerUi
  32. To use swagger-ui you should take a look at the [source of swagger-ui html page](https://github.com/wordnik/swagger-ui/tree/master/src/main/html) and customize it. This basically requires you to instantiate a SwaggerUi object and call load() on it as below:
  33. ```javascript
  34. window.swaggerUi = new SwaggerUi({
  35. discoveryUrl:"http://petstore.swagger.wordnik.com/api/resources.json",
  36. dom_id:"swagger-ui-container",
  37. apiKey:"special-key",
  38. supportHeaderParams: false,
  39. headers: { "Authorization": "XXXX", "someOtherHeader": "YYYY" },
  40. supportedSubmitMethods: ['get', 'post', 'put']
  41. });
  42. window.swaggerUi.load();
  43. ```
  44. * *discoveryUrl* parameter should point to a resource listing url as per [Swagger Spec](https://github.com/wordnik/swagger-core/wiki)
  45. * *dom_id parameter* is the the id of a dom element inside which SwaggerUi will put the user interface for swagger
  46. * *booleanValues* SwaggerUI renders boolean data types as a dropdown. By default it provides a 'true' and 'false' string as the possible choices. You can use this parameter to change the values in dropdown to be something else, for example 0 and 1 by setting booleanValues to new Array(0, 1)
  47. * *docExpansion* controls how the API listing is displayed. It can be set to 'none' (default), 'list' (shows operations for each resource), or 'full' (fully expanded: shows operations and their details)
  48. * *onComplete* is a callback function parameter which can be passed to be notified of when SwaggerUI has completed rendering successfully.
  49. * *onFailure* is a callback function parameter which can be passed to be notified of when SwaggerUI encountered a failure was unable to render.
  50. * All other parameters are explained in greater detail below
  51. ### HTTP Methods and API Invocation
  52. swagger-ui supports invocation of all HTTP methods APIs but only GET methods APIs are enabled by default. You can choose to enable other HTTP methods like POST, PUT and DELETE. This can be enabled by [setting the supportedSubmitMethods parameter when creating SwaggerUI instance](https://github.com/wordnik/swagger-ui/blob/f2e63c65a759421aad590b7275371cd0c06c74ea/src/main/html/index.html#L49).
  53. For example if you wanted to enable GET, POST and PUT but not for DELETE, you'd set this as:
  54. supportedSubmitMethods: ['get', 'post', 'put']
  55. _Note that for POST/PUT body, you'd need to paste in the request data in an appropriate format which your service can unmarshall_
  56. ### Header Parameters
  57. header parameters are supported. However because of [Cross-Origin Resource Sharing](http://www.w3.org/TR/cors/) restrictions, swagger-ui, by default, does not send header parameters. This can be enabled by [setting the supportHeaderParams to true when creating SwaggerUI instance](https://github.com/wordnik/swagger-ui/blob/f2e63c65a759421aad590b7275371cd0c06c74ea/src/main/html/index.html#L48) as below:
  58. supportHeaderParams: true
  59. ### Custom Header Parameters - (For Basic auth etc)
  60. If you have some header parameters which you need to send with every request, use the headers as below:
  61. headers: { "Authorization": "XXXX", "someOtherHeader": "YYYY" }
  62. ### Api Key Parameter
  63. If you enter an api key in swagger-ui, it sends a parameter named 'api\_key' as a query (or as a header param if you've enabled it as described above). You may not want to use the name 'api\_key' as the name of this parameter. You can change its name by setting the _apiKeyName_ parameter when you instantiate a SwaggerUI instance. For example to call it 'sessionId'
  64. apiKeyName: "sessionId"
  65. How to Improve It
  66. -----------------
  67. Create your own fork of [wordnik/swagger-ui](https://github.com/wordnik/swagger-ui)
  68. To share your changes, [submit a pull request](https://github.com/wordnik/swagger-ui/pull/new/master).
  69. License
  70. -------
  71. Copyright 2011-2013 Wordnik, Inc.
  72. Licensed under the Apache License, Version 2.0 (the "License");
  73. you may not use this file except in compliance with the License.
  74. You may obtain a copy of the License at [apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
  75. Unless required by applicable law or agreed to in writing, software
  76. distributed under the License is distributed on an "AS IS" BASIS,
  77. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  78. See the License for the specific language governing permissions and
  79. limitations under the License.