TypeError未能找到服务器,Swagger Editor:找不到ERROR服务器或发生错误

我是Swagger工具的新手.我尝试用swagger编辑器测试我的Restfull应用程序.我使用基本身份验证来访问Web服务.

在Swagger-UI中,预览看起来是正确的,即Content-Type:application / json和json在body中.但是当我从Swagger编辑器向服务器发送GET请求时,我收到了一个错误.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": "abc@gmail.com",

"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"

}

}

}

}

}

请帮我.

提前致谢.

最佳答案 我得到了解决方案.

它的CORS问题.我的浏览器阻止了cors请求.我安装了Chrome扩展程序,可将Access-Control-Allow-Origin添加到传出请求中.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值