首页 > 解决方案 > 引用另一个文件时无法导入 JSON 文件

问题描述

我正在使用 NSwag.OpenaPiDocument.FromJsonAsync() 加载 JSON 文件。JSON 文件分为几个文件。不幸的是,我收到了这个错误:

Could not resolve the JSON path 'parameters.json#/tagsParam' with the full JSON path 'C:\Users\ribuss\Desktop\Swagger\json\petstore-separate\spec\parameters.json#/tagsParam'

我正在尝试导入以下文件(通过调用 swagger.json 的方法)

在我的应用程序中,我使用以下命令:

NSwag.OpenApiDocument.FromJsonAsync(content, "C:/Users/ribuss/Desktop/Swagger/json/petstore-separate/spec/swagger.json").Result; // content is the full json text of swagger.json

编辑:

这是不起作用的架构:

{
  "tagsParam": {
    "name": "tags",
    "in": "query",
    "description": "tags to filter by",
    "required": false,
    "type": "array",
    "collectionFormat": "csv",
    "items": {
      "type": "string"
    }
  },
  "limitsParam": {
    "name": "limit",
    "in": "query",
    "description": "maximum number of results to return",
    "required": false,
    "type": "integer",
    "format": "int32"
  }
}

我已经通过使用定义更改了架构,它现在正在工作。

标签: c#jsonswaggeropenapinswag

解决方案


推荐阅读