Express 使用时在浏览器中抛出错误的招摇过市参考定义
我不太会招摇过市,至少不会把它加入到一个项目中。我有一个非常简单的crud express.js应用程序,并添加了一个swagger.json。(作为一个附带问题,是否有一种基于express js应用程序或文件自动生成这些文件的方法 我遵循了一些示例设置站点,我的swagger文档确实有效,但在使用它时浏览器中有一个错误Express 使用时在浏览器中抛出错误的招摇过市参考定义,express,swagger,swagger-ui,swagger-2.0,Express,Swagger,Swagger Ui,Swagger 2.0,我不太会招摇过市,至少不会把它加入到一个项目中。我有一个非常简单的crud express.js应用程序,并添加了一个swagger.json。(作为一个附带问题,是否有一种基于express js应用程序或文件自动生成这些文件的方法 我遵循了一些示例设置站点,我的swagger文档确实有效,但在使用它时浏览器中有一个错误 Errors Hide Resolver error at paths./api/maps/{name}.get.parameters.0.schema.$ref
Errors
Hide
Resolver error at paths./api/maps/{name}.get.parameters.0.schema.$ref
Could not resolve reference: #/definitions/name
这是我的完整swagger.json(如下)。错误出现在我的“按名称获取”部分,因此特别是这段代码?我不清楚该模式的用途,正如我所说的,它确实可以工作,并根据映射名称执行获取
"schema": {
"$ref": "#/definitions/name"
}
Full-swagger.json
{
"openapi": "3.0.0",
"info": {
"version": "1.0.0",
"title": "Map API For The World Of Elrue",
"description": "World Of Elrue Map Express JS API",
"license": {
"name": "MIT",
"url": "https://opensource.org/licenses/MIT"
}
},
"servers": [
{
"url": "/",
"description": "Local Dev, or from Heroku"
},
{
"url": "/api/",
"description": "With docker-compose and nginx proxy"
}
],
"tags": [
{
"name": "Maps",
"description": "API for maps in the system"
}
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {
"/api/maps": {
"get": {
"tags": [
"Maps"
],
"summary": "Get all maps in system",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/Maps"
}
}
}
},
"post": {
"tags": [
"Maps"
],
"summary": "Create a new map in system",
"requestBody": {
"description": "Map Object",
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/definitions/Map"
}
}
}
},
"produces": [
"application/json"
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/id"
}
},
"400": {
"description": "Failed. Bad post data."
}
}
}
},
"/api/maps/{name}": {
"parameters": [
{
"name": "name",
"in": "path",
"required": true,
"description": "Name of the map that we want to match",
"type": "string"
}
],
"get": {
"tags": [
"Maps"
],
"summary": "Get map with given Name",
"parameters": [
{
"in": "path",
"name": "name",
"required": true,
"description": "Map with name",
"schema": {
"$ref": "#/definitions/name"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/Map"
}
},
"404": {
"description": "Failed. Map not found."
}
}
},
"put": {
"summary": "Update Map with given ID",
"tags": [
"Maps"
],
"requestBody": {
"description": "Map Object",
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/definitions/Map"
}
}
}
},
"parameters": [
{
"in": "path",
"name": "id",
"required": true,
"description": "Map with new values of properties",
"schema": {
"$ref": "#/definitions/id"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/Map"
}
},
"400": {
"description": "Failed. Bad post data."
},
"404": {
"description": "Failed. Map not found."
}
}
},
"delete": {
"summary": "Delete Map with given ID",
"tags": [
"Maps"
],
"parameters": [
{
"in": "path",
"name": "id",
"required": true,
"description": "Delete Map with id",
"schema": {
"$ref": "#/definitions/id"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/id"
}
},
"404": {
"description": "Failed. Map not found."
}
}
}
}
},
"definitions": {
"id": {
"properties": {
"uuid": {
"type": "string"
}
}
},
"Map": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"sdesc": {
"type": "string"
},
"path": {
"type": "string"
}
}
},
"Maps": {
"type": "object",
"properties": {
"maps": {
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/Map"
}
}
}
}
}
}