yapi icon indicating copy to clipboard operation
yapi copied to clipboard

go-swagger 生成的json导入的返回结果是错误的

Open mr3chen opened this issue 6 years ago • 2 comments

版本号

~

什么问题

go-swagger 生成的json导入的返回结果是错误的

如何复现此问题

导入如下json文件。 { "swagger": "2.0", "paths": { "/SayHello": { "post": { "description": "This will show all available pets by default.\nYou can get the pets that are out of stock", "consumes": [ "application/json" ], "produces": [ "application/json" ], "schemes": [ "http", "https", "ws", "wss" ], "tags": [ "pets", "users" ], "summary": "Lists pets filtered by some parameters.", "operationId": "SayHello", "parameters": [ { "name": "name", "in": "body", "schema": { "type": "string" } } ], "responses": { "200": { "$ref": "#/responses/SayHelloRsp" }, "422": { "$ref": "#/responses/validationError" }, "default": { "$ref": "#/responses/SayHelloRsp2" } } } } }, "definitions": { "SayHelloModel": { "type": "object", "properties": { "text": { "description": "文章", "type": "string" } } } }, "responses": { "SayHelloRsp": { "description": "The response message containing the greetings", "schema": { "$ref": "#/definitions/SayHelloModel" } }, "SayHelloRsp2": { "description": "The request message containing the user's name.", "headers": { "time": { "type": "string" } } } } }

什么浏览器

~

什么系统(Linux, Windows, macOS)

mr3chen avatar Feb 04 '20 06:02 mr3chen

问题解决了吗?我的也是解析错误。返回数据有问题。版本: 1.9.5。最终json如下: { "swagger": "2.0", "info": { "description": "xxx API接口文档", "title": "xxx", "contact": { "name": "API Support", "url": "http://www.swagger.io/support" }, "license": { "name": "Apache 2.0", "url": "http://www.apache.org/licenses/LICENSE-2.0.html" }, "version": "2.0" }, "host": "127.0.0.1:9009", "basePath": "/im/v2", "paths": { "/users/login": { "post": { "description": "用户登录接口", "produces": [ "application/json" ], "tags": [ "users" ], "summary": "登录", "parameters": [ { "description": "用户账号信息", "name": "UserLoginDot", "in": "body", "required": true, "schema": { "$ref": "#/definitions/dtos.UserLoginDot" } } ], "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/controllers.Res" }, { "type": "object", "properties": { "data": { "$ref": "#/definitions/dtos.UserDto" } } } ] } } } } }, "/users/page": { "post": { "description": "获取用户列表", "produces": [ "application/json" ], "tags": [ "users" ], "summary": "用户列表", "parameters": [ { "description": "用户列表深度翻页", "name": "PageQueryDto", "in": "body", "required": true, "schema": { "$ref": "#/definitions/dtos.PageQueryDto" } } ], "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/controllers.Res" }, { "type": "object", "properties": { "data": { "allOf": [ { "$ref": "#/definitions/dtos.PageListResDto" }, { "type": "object", "properties": { "list": { "$ref": "#/definitions/dtos.UserDto" } } } ] } } } ] } } } } } }, "definitions": { "controllers.Res": { "type": "object", "properties": { "code": { "type": "integer" }, "data": {}, "msg": { "type": "string" } } }, "dtos.PageListResDto": { "type": "object", "properties": { "count": { "description": "总数", "type": "integer" }, "list": { "description": "列表" }, "page": { "description": "页数", "type": "integer" }, "pagesize": { "description": "每页条数", "type": "integer" } } }, "dtos.PageQueryDto": { "type": "object", "properties": { "page": { "description": "页数", "type": "integer" }, "pagesize": { "description": "每页条数", "type": "integer" } } }, "dtos.UserDto": { "type": "object", "properties": { "addr": { "description": "用户地址", "type": "string" }, "age": { "description": "用户年龄", "type": "integer" }, "user_name": { "description": "用户名", "type": "string" } } }, "dtos.UserLoginDot": { "type": "object", "required": [ "pass_word", "user_name" ], "properties": { "pass_word": { "description": "密码", "type": "string" }, "user_name": { "description": "用户名", "type": "string" } } } } } 返回数据如下: 1640226131(1)

henrion-y avatar Dec 23 '21 02:12 henrion-y

俺也一样

thinkeng avatar Oct 29 '23 16:10 thinkeng