2016-10-18 2 views
4

나는 Swagger 도구에서 최신 버전입니다. Restfull 응용 프로그램을 swagger 편집기으로 테스트 해 봅니다. 기본 인증을 사용하여 웹 서비스에 액세스했습니다. 자신감-UI에서Swagger Editor : 오류 서버를 찾을 수 없거나 오류가 발생했습니다.

, 미리보기, 즉 콘텐츠 형식을 올바른 같습니다 application/json를 내가 서버에 자신감 편집기에서 GET 요청을 보낼 때 JSON이 퍼질에, 오류가 발생했습니다.

ERROR Server not found or an error occurred 

내 자신감

{ 
    "swagger": "2.0", 
    "info": { 
     "version": "1.0.0", 
     "title": "Swagger Petstore (Simple)", 
     "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification", 
     "termsOfService": "http://helloreverb.com/terms/", 
     "contact": { 
      "name": "Swagger API team", 
      "email": "[email protected]", 
      "url": "http://avfg.com" 
     }, 
     "license": { 
      "name": "MIT", 
      "url": "http://opensource.org/licenses/MIT" 
     } 
    }, 
    "host": "127.0.0.1:8xxx", 
    "basePath": "/v1", 
    "schemes": [ 
     "http" 
    ], 
    "consumes": [ 
     "application/json" 
    ], 
    "produces": [ 
     "application/json" 
    ], 
    "paths": { 
     "/facedetect/{username}/{albumname}/{imagename}": { 
      "get": { 
       "description": "Returns all pets from the system that the user has access to", 
       "operationId": "findPets", 
       "produces": [ 
        "application/json", 
        "application/xml" 
       ], 
       "parameters": [ 
        { 
         "name": "username", 
         "in": "path", 
         "description": "tags to filter by", 
         "required": true, 
         "type": "string" 
        }, 
        { 
         "name": "albumname", 
         "in": "path", 
         "description": "maximum number of results to return", 
         "required": true, 
         "type": "string" 
        }, 
        { 
         "name": "imagename", 
         "in": "path", 
         "description": "maximum number of results to return", 
         "required": true, 
         "type": "string" 
        } 
       ], 
       "responses": { 
        "200": { 
         "description": "pet response", 
         "schema": { 
          "type": "array", 
          "items": { 
           "$ref": "#/definitions/pet" 
          } 
         } 
        }, 
        "default": { 
         "description": "unexpected error", 
         "schema": { 
          "$ref": "#/definitions/errorModel" 
         } 
        } 
       } 
      } 
     } 
    }, 
    "definitions": { 
     "pet": { 
      "type": "object", 
      "required": [ 
       "id", 
       "name" 
      ], 
      "properties": { 
       "id": { 
        "type": "integer", 
        "format": "int64" 
       }, 
       "name": { 
        "type": "string" 
       }, 
       "tag": { 
        "type": "string" 
       } 
      } 
     }, 
     "errorModel": { 
      "type": "object", 
      "required": [ 
       "code", 
       "message" 
      ], 
      "properties": { 
       "code": { 
        "type": "integer", 
        "format": "int32" 
       }, 
       "message": { 
        "type": "string" 
       } 
      } 
     } 
    } 
} 

제발 도와주세요.

미리 감사드립니다.

+1

서버가 사용자가 구성한 것에 응답한다고 가정합니다. http://127.0.0.1:8610/api/v1? – fehguy

답변

1

할 수 있습니다.

해당 CORS 문제. 브라우저가 cors 요청을 차단하고 있습니다. 크롬 확장 프로그램을 설치하여 나가는 요청에 액세스 제어 허용 원점을 추가했습니다.

+0

다운로드했지만 여전히 요청을 허용 할 수 없습니다. 이후에해야 할 일이 있습니까? – mashkurm

0

서버를 실행해야합니다.

당신은 자신감이 설치되어있는 경우, 당신은 내가 해결책을 가지고

swagger project start 
관련 문제