Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
280 views
in Technique[技术] by (71.8m points)

If you expose a Rest API, are you also supposed to provide the DTOs in popular languages?

If I expose a Rest end point that anyone can consume. For argument sake let's say it accepts a ticker symbol and I return a json string that has information on that, for example the ceo, stock price and year founded.

{
  "symbol": "Abc",
  "ceo": "Elon Musket",
  "stock price": "$50",
  "year founded": "2023"
}

Am I supposed to provide DTOs that can be consumed in Java, C# and other popular languages (for deserializing)? Is that a common practice? Or anyone who consumes my service is supposed to create their own DTOs?

question from:https://stackoverflow.com/questions/65865096/if-you-expose-a-rest-api-are-you-also-supposed-to-provide-the-dtos-in-popular-l

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

A DTO (Data Transfer Object) is a design pattern for any object used to transfer multiple data values between remote systems. JSON is a DTO, which is handled just fine by pretty much every language that would be able to receive it.

If you are worried about best REST API practices, check out the stackoverflow page on the exact topic.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...