Visual Grape Swagger-ui

Source: Internet
Author: User

Swagger-docs:

Https://github.com/richhollis/swagger-docs
Swagger-docs-sample:https://github.com/richhollis/swagger-docs-sample/blob/master/readme.md
Swagger-ui:https://github.com/wordnik/swagger-ui

1. Vim Gemfile Add gem ‘swagger-docs‘ 然后bundle    或者直接gem installSwagger-docs
2、cd rails项目目录;   vim CONFIG/INITIALIZERS/SWAGGER_DOCS.RB, and add the following to save:
Swagger::D Ocs::config.register_apis ({
"1.0" + = {: Base_path = "http://localhost:3000",: Api_file_path = "public"}
})
3. Add in a controller:
Swagger_controller:user_api, "Userapi"

Swagger_api:index do
Summary "Test"
Response:unauthorized
Response:not_acceptable
End

def index
Render:json = {result: "Success"},: status = 200
End

4. Rake Swagger:docs
5. Rails S
6. CD Public
7. Git clone https://github.com/wordnik/swagger-ui.git
8. Vim swagger-ui/dist/index.html
To modify the URL to Http://localhost:3000/api-docs.json
Window.swaggerui = new Swaggerui ({
URL: "Http://localhost:3000/api-docs.json",
Http://petstore.swagger.wordnik.com/api/api-docs
dom_id: "Swagger-ui-container",
Supportedsubmitmethods: [' Get ', ' post ', ' Put ', ' delete '],
... ... ...
9. Enter http://localhost:3000/swagger-ui/dist/index.html in the browser
To view and test the API


If the page is turned on slowly, vim public/swagger-ui/dist/index.html,
To Fonts.googleapis.com/css ... This line of code is commented out.

Note: config/routes.rb in swagger corresponding route do not use match, otherwise will error

Visual Grape Swagger-ui

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.