midwayjs / midway

🍔 A Node.js Serverless Framework for front-end/full-stack developers. Build the application for next decade. Works on AWS, Alibaba Cloud, Tencent Cloud and traditional VM/Container. Super easy integrate with React and Vue. 🌈
https://www.midwayjs.org/
MIT License
7.34k stars 573 forks source link

关于使用dto来创建swagger #1284

Closed zerogu closed 3 years ago

zerogu commented 3 years ago

定义dto文件 image

在Controller的代码里 image

最后在生成的swagger里会变成 image

变成到一个common的键值对对象里 求问大佬,这符合预期么

czy88840616 commented 3 years ago

试试新版本 1.2.0

zerogu commented 3 years ago

试试新版本 1.2.0

大佬,我试了下 "@midwayjs/swagger": "^1.1.0", "swagger-ui-dist": "^4.0.0-beta.4",

访问/swagger-ui/json,会报错 (0 , decorator_1.getClassExtendedMetadata) is not a function

 at SwaggerMetaGenerator.generateSwaggerDefinition (/Users/zero/www/bili_live/node-mlive/node_modules/@midwayjs/swagger/dist/lib/generator.js:139:64)

查了下这个getClassExtendedMetadata,发现大佬并没有定义过...

czy88840616 commented 3 years ago

decorator 包更新了的。

zerogu commented 3 years ago

decorator 包更新了的。

把包整个更新了下

1、清理子包的 node_modules,比如(lerna clean --yes)
2、删除主包的 node_modules(比如 rm -rf node_modules)
3、删除 package-lock.json 或者 yarn.lock
4、重新安装依赖( npm install && lerna bootstrap)

发现swagger页面在展示DTO参数时还是老样子....在一个键值对里

czy88840616 commented 3 years ago

明天来看,今天实在太忙了。

czy88840616 commented 3 years ago

我想了下好像不对。。。DTO 现在只支持 BODY 请求,query 请求的确是不支持的。

zerogu commented 3 years ago

我想了下好像不对。。。DTO 现在只支持 BODY 请求,query 请求的确是不支持的。

好!感谢大佬!现在也已经挺好使的了

czy88840616 commented 3 years ago

一直想重构下,等3.x的功能差不多了就重写一个新的。