简体   繁体   English

如何构造REST DTO?

[英]How to construct REST dto's?

I am in the process of building a REST api which accepts a set of arguments, processes it and gives a boolean response. 我正在构建一个REST api,该api接受一组参数,对其进行处理并给出布尔响应。

My question is how do I build a dto object. 我的问题是如何构建dto对象。 I can create a Java POJO in one of the applications and use it as REST parameter but that creates a dependency on this application. 我可以在其中一个应用程序中创建Java POJO,并将其用作REST参数,但这会对该应用程序产生依赖性。 Is there a better way to pass an object as REST parameter? 有没有更好的方法将对象作为REST参数传递?

note: the reason I am not using path params because my dto object might contain a list of objects as well and I am not sure how to pass that using path param. 注意:之所以我不使用路径参数,是因为我的dto对象也可能包含对象列表,而且我不确定如何使用路径参数来传递它。

You can create a library which contains the DTO class if dependency is your concern. 如果依赖关系是您所关心的,则可以创建一个包含DTO类的库。

After all the DTO is dependent on the REST API. 毕竟,DTO依赖于REST API。 If one changes the other must change too. 如果一个改变,另一个也必须改变。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM