Swagger节点应用程序停止

时间:2019-01-08 07:55:55

标签: node.js swagger-2.0

我有一个Swagger Node应用程序,在swagger yaml中,我将路由器定义为示例

/test: x-swagger-router-controller: test post: summary: Test description: Test operationId: Test tags: - Test consumes: - application/x-www-form-urlencoded produces: - application/json parameters: - name: testdata in: formData description: The string value of a token required: true type: string

当我这样发布信息时,我可以得到回复

curl -X POST \ http://localhost:5000/test \ -H 'Content-Type: application/x-www-form-urlencoded' \ -H 'cache-control: no-cache' \ -d 'testdata=dasdasda&undefined='

当我这样张贴时(如预期的那样)我会出错

curl -X POST \ http://localhost:5000/test \ -H 'Content-Type: application/json' \ -H 'cache-control: no-cache'

curl -X POST \ http://localhost:5000/test \ -H 'Content-Type: application/x-www-form-urlencoded' \ -H 'cache-control: no-cache'

发布后我的应用程序停止

curl -X POST \ http://localhost:5000/test \ -H 'cache-control: no-cache'

能给我一个提示是什么问题

解决了添加新中间件的问题,并检查url是否为localhost:5000 / test来检查body是否为空,但我认为这是一种解决方法,不是最终解决方案

0 个答案:

没有答案
相关问题