Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dubbo入参对象没有解析 #17

Open
hfq-yangyang-yangyang opened this issue Jun 7, 2018 · 9 comments
Open

dubbo入参对象没有解析 #17

hfq-yangyang-yangyang opened this issue Jun 7, 2018 · 9 comments

Comments

@hfq-yangyang-yangyang
Copy link

入参对象没有解析出来

ChannelOutput offlineRefund(OfflineRefundInput)线下退款
最好将OfflineRefundInput内部属性解析并展示出来。

json片段:
"/h/com.huifenqi.jedi.resultprocess.facade.RefundFacade/offlineRefund": {
"post": {
"tags": [
"RefundFacade"
],
"summary": "线下退款",
"description": "ChannelOutput offlineRefund(com.huifenqi.jedi.resultprocess.params.OfflineRefundInput)线下退款",
"operationId": "offlineRefund",
"parameters": [
{
"name": "offlineRefundInput",
"in": "formData",
"required": false,
"type": "string"
}
],
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/ChannelOutput"
}
}
}
}
},

@Sayi
Copy link
Owner

Sayi commented Jun 7, 2018

升级swagger-dubbo到2.0.1版本试试。

基于 @JKTerrific 的PR #16 做了一点点的修改。

@hfq-yangyang-yangyang
Copy link
Author

swagger-dubbo到2.0.1版本

返回的json参数 没有显示到swagger页面上,显示以下

Response Body
no content
Response Code
0
Response Headers
{
"error": "no response from server"
}

@Sayi
Copy link
Owner

Sayi commented Jun 7, 2018

no response from server

这是服务端没响应,看看服务是否正常启动了,是否有异常日志。

@hfq-yangyang-yangyang
Copy link
Author

你这个return是有数据的,到swagger页面就没有了

@RequestMapping(value = "/{interfaceClass}/{methodName}", produces = "application/json; charset=utf-8")
@responsebody
public ResponseEntity invokeDubbo(@PathVariable("interfaceClass") String interfaceClass,
@PathVariable("methodName") String methodName, HttpServletRequest request,
HttpServletResponse response) throws Exception {
return invokeDubbo(interfaceClass, methodName, null, request, response);
}

@Sayi
Copy link
Owner

Sayi commented Jun 7, 2018

可以把api-docs暴露的JSON数据发给我吗?

@hfq-yangyang-yangyang
Copy link
Author

找的问题了,还是SwaggerDubboController 跨域问题

@Sayi
Copy link
Owner

Sayi commented Jun 7, 2018

文档上有推荐的跨域做法,如果Spring版本过低,自己写个拦截器 对/sawgger-dubbo/api-docs 设置跨域。

@hfq-yangyang-yangyang
Copy link
Author

由于swagger作为独立服务不集成到项目中(尽可能降低耦合),

springboot 跨域 DubboHttpController和SwaggerDubboController 都要加上,否则会有上面的问题

@sunwulovelove1
Copy link

sunwulovelove1 commented Jan 25, 2021

我也遇到这个情况了
POST 请求时,传递RequestBody

看了一下代码:
com.deepoove.swagger.dubbo.web.DubboHttpController#invokeDubbo(java.lang.String, java.lang.String, java.lang.String, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)

里面解析使用:
request.getParameter

POST/RequestBody 下无法获取到值。

debug过程:

获取到传入
Object suggestPrameterValue = this.suggestPrameterValue(parameterTypes[i], parameterClazz[i], request.getParameter(parameterNames[i])); 中:

request.getParameter(parameterNames[i])) 无法获取到参数,suggestPrameterValue null

将request 解析
IOUtils.read(new BufferedReader(new InputStreamReader(request.getInputStream()))) 可以获取到requestbody里面的内容

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants