easy-yapi
easy-yapi copied to clipboard
[Question] generic.param.as.json.body配置问题
generic.param.as.json.body=@org.springframework.web.bind.annotation.RequestBody
默认配置的请求参数,用@RequestBody修饰,但是我这个项目,不加任何注解修饰,该怎么配置啊
完全不用spring的注解?还是说只是不用RequestBody ?
用spring注解,应该是我们这个框架在外面统一转json了,但是我们在编码的时候,只需要注重代码开发就好,所以就不用RequestBody
@Validated @ThriftService(group = "xxx", service = "invoice") public class InvoiceServiceImpl implements InvoiceService { @Resource private InvoiceQryExe invoiceQryExe; /** * 发票记录列表 * * @param request 请求参数 * @return 发票记录列表 */ @Override public RecordDTO<ListInvoiceRecordDTO> getlist(VendorListInvoiceRecordRequest request) { InvoiceListParam param = ConverterUtils.parseObject(request, InvoiceListParam.class); return invoiceQryExe.listInvoiceRecord(param, request.getPage()); }
类似这样的,@ThriftService注解类似于@RestController,path后面拼接方法名 /vendor-invoice/getlist
我把 generic.param.as.json.body=@org.springframework.web.bind.annotation.RequestBody 改为 generic.param.as.json.body=true
因为方法的参数不加注解,所以我在导出的时候,导出的api没有json
大佬帮忙看下该怎么设置
不是很能完全理解你目前的情况,你有配置generic.class.has.api吗?
是不是需要设置generic.http.method=POST?
ref: https://easyyapi.com/documents/generic.html
都配置好了,也能正常的导出接口文档,但是导出的文档,json为空
这是我的配置:
这是我的页面代码 `@ThriftService(group = "xxx", service = "invoice") public class InvoiceServiceImpl implements InvoiceService { https://github.com/resource private InvoiceQryExe invoiceQryExe; /**
- 发票记录列表
- @param request 请求参数
- @return 发票记录列表 */ @OverRide public RecordDTO getlist(VendorListInvoiceRecordRequest request) { InvoiceListParam param = ConverterUtils.parseObject(request, InvoiceListParam.class); return invoiceQryExe.listInvoiceRecord(param, request.getPage()); }`
我试了一下,导出的文档看起来是正常的。
code:
@ThriftService(group = "xxx", service = "invoice")
public class InvoiceServiceImpl implements InvoiceService {
/**
* 发票记录列表
*
* @param request 请求参数
* @return 发票记录列表
*/
@Override
public RecordDTO getlist(VendorListInvoiceRecordRequest request) {
return null;
}
}
.easy.api.config:
# generic.class.has.api
generic.class.has.api=@com.itangcent.springboot.demo.test.ThriftService
# generic.path
generic.path[@com.itangcent.springboot.demo.test.ThriftService][email protected]#service
# generic.http.method
generic.http.method=POST
# generic.method.has.api
generic.path=groovy:it.name()
# generic.method.has.api
generic.method.has.api=true
## generic.param.as.json.body
#[email protected]
#generic.param.as.form.body=true
generic.param.as.json.body=true
我用的是apifox的插件,官方说基于easy-api插件开发的,可能有别的处理吧,所以可能导致导出的效果不一致吧
谢谢大佬~
大佬,还是想请教个问题, 我设置成了 generic.param.as.json.body=true 在方法的参数上加@RequestBody注解,就可以完美的导出,但是如果不加这个注解,导出接口的请求参数json显示为空 想问下,在生成api,生成json请求参数的时候,是怎么处理的
大佬,还是想请教个问题, 我设置成了 generic.param.as.json.body=true 在方法的参数上加@requestbody注解,就可以完美的导出,但是如果不加这个注解,导出接口的请求参数json显示为空 想问下,在生成api,生成json请求参数的时候,是怎么处理的
https://github.com/tangcent/easy-yapi/blob/a6fd9033f16f39f7dd2d5b419e0770a7360549be/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/generic/GenericRequestClassExporter.kt#L70-L87 他们那个插件好像没开源,不知道改成啥样了。
大佬,还是想请教个问题, 我设置成了 generic.param.as.json.body=true 在方法的参数上加@requestbody注解,就可以完美的导出,但是如果不加这个注解,导出接口的请求参数json显示为空 想问下,在生成api,生成json请求参数的时候,是怎么处理的
https://github.com/tangcent/easy-yapi/blob/a6fd9033f16f39f7dd2d5b419e0770a7360549be/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/generic/GenericRequestClassExporter.kt#L70-L87
他们那个插件好像没开源,不知道改成啥样了。
谢谢大佬~