2012-07-11 37 views
6

Tôi đang ghi lại API web REST với Swagger. Tôi đã tải xuống ví dụ về cửa hàng thú cưng. Nó bao gồm các resources.json mà tham chiếu pet.jsonuser.json:Lỗi giao diện người dùng chuyển đổi: Không thể tìm nạp danh sách API

{ 
    "apiVersion":"0.2", 
    "swaggerVersion":"1.0", 
    "basePath":"http://petstore.swagger.wordnik.com/api", 
    "apis": 
    [ 
     { 
      "path":"/pet.{format}", 
      "description":"Operations about pets" 
     }, 
     { 
      "path":"/user.{format}", 
      "description":"Operations about user" 
     } 
    ] 
} 

Nhưng ngay cả sau khi tải lên các tập tin ban đầu cho máy chủ web của tôi, Swagger UI nói với tôi:

Unable to fetch API Listing. Tried the following urls: 
http://www.myserver.org/resources.json 
http://www.myserver.org 
http://www.myserver.org/resources.json 
http://www.myserver.org/resources 

Bạn có thể cho biết những gì gây ra Swagger không tìm thấy tệp json của tôi?

Trả lời

4

Tôi giả sử bạn sẽ truy cập www.myserver.org và nó sẽ trả về ui? Trong hộp văn bản "Khám phá" trong giao diện người dùng Swagger ... hãy nhớ nhập vị trí của resources.json của bạn.

Cá nhân tôi đã chứng api vênh vang tôi thiết lập theo cách này ...

http://adamclerk.com/api   --Swagger UI 
http://adamclerk.com/api/doc  --returns json representing resources.js 
http://adamclerk.com/api/doc/donuts --returns json representing donut operations 

bạn có thể kiểm một Giải thích chi tiết hơn ở đây - Swagger With Static Documentation

Nếu bạn có thắc mắc hơn đừng ngần ngại hỏi.

Các vấn đề liên quan