首页 > 解决方案 > VisualStudio/NSwag 无法解析 Swagger.ui 兼容 Json?

问题描述

我正在使用 Visual Studio 添加服务参考功能添加新的 OpenAPI 服务参考。
结果:
“添加服务引用失败。无法从https://10.183.177.223:9002/v2/api-docs 下载元数据文件。”

但 Swagger-ui.html 运行良好并从https://10.183.177.233:9002/v2/api-docs获取其资源

之前添加 web 服务引用从来没有任何问题......我做错了什么?

如果我手动添加 JSON 文件。我在构建以下错误时得到:

命令 ""../tools/Win/NSwag.exe" openapi2csclient /className:SoluMAPIClient /namespace:test_integrate_SoluM_API /input:C:\Users\pascherp\source\repos\test 集成 SoluM API\test 集成 SoluM API\OpenAPIs\ SoluMAPI.json /output:obj\SoluMAPIClient.cs " 以代码 -1 退出

和 w 警告

    "TagScheduleTime": {
  "type": "object",
  "required": [ "displayPage", "endTime", "startTime" ],
  "properties": {
    "displayPage": {
      "type": "integer",
      "format": "int32",
      "example": 1,
      "minimum": 1,
      "maximum": 3
    },
    "startTime": {
      "example": "2017-01-01 00:00",
      "$ref": "#/definitions/LocalDateTime"
    },
    "endTime": {
      "example": "2017-01-01 23:59",
      "$ref": "#/definitions/LocalDateTime"  //<--- Reference could not be resolved
    }
  }
},

Swagger 怎么能很好地运行它,但 VS 不是?我可以为此责怪 Api 提供者吗?:)

标签: visual-studioopenapiservice-referencenswag

解决方案


推荐阅读