Swagger UI is part of Swagger project. The Swagger project allows you to produce, visualize and consume your OWN RESTful services. No proxy or 3rd party services required. Do it your own way.
You can use the swagger-ui code AS-IS! No need to build or recompile--just download the distribution, unpack and start using it. If you like swagger-ui as-is, stop here.
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:
- Install CoffeeScript which will give you cake
- Run cake dist
- You should see the distribution under the dist folder. Open ./dist/index.html to launch Swagger UI in a browser
Once you open the Swagger UI, it will load the Swagger Petstore service and show its APIs. You can enter your own server url and click explore to view the API.
You may choose to customize Swagger UI for your organization. Here is an overview of what the various directories contain
- dist: Contains a distribution which you can deploy on a server or load from your local machine.
- bin: Contains files used by swagger-ui for its build/test. These are not required by the distribution.
- node_modules: Contains node modules which swagger-ui uses for its development.
- src/main/coffeescript: main code in CoffeeScript
- src/main/templates: handlebars templates used to render swagger-ui
- src/main/html: the html files, some images and css
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.
For example if you wanted to enable GET, POST and PUT but not for DELETE, you'd set this as:
supportedSubmitMethods: ['get', 'post', 'put']
Note that for POST/PUT body, you'd need to paste in the request data in an appropriate format which your service can unmarshall
header parameters are supported. However because of Cross-Origin Resource Sharing restrictions, swagger-ui, by default, does not send header parameters. This can be enabled by setting the supportHeaderParams to true when creating SwaggerUI instance as below:
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'
Create your own fork of wordnik/swagger-ui
To share your changes, submit a pull request.
Copyright 2011-2012 Wordnik, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.