简体   繁体   English

REST API中的原始值与查找值

[英]Raw vs Lookup values in REST API

We are implementing REST API on our project and we can not reach a consensus about a response data. 我们正在我们的项目上实现REST API,我们无法就响应数据达成共识。

So we have some "code" entities. 因此,我们有一些“代码”实体。 These entities contain fields Code (simple alphanumeric identifier) and Description of this code (some describing text). 这些实体包含“代码”(简单的字母数字标识符)和“此代码的描述”(某些描述文本)字段。 On some pages of current client application we need to show lookup values based on the user settings (eg Code - Description or Description - Code). 在当前客户端应用程序的某些页面上,我们需要显示基于用户设置的查找值(例如,“代码-说明”或“描述-代码”)。 Should REST API return configured values or it should return only raw code values? REST API应该返回配置值还是仅返回原始代码值? My opinion is that representation is a client's responsibility. 我的意见是代理是客户的责任。

What do you think? 你怎么看?

I would return both code and description. 我将同时返回代码和描述。 If the client do not want to use the description provided by the server, they can simply ignore it. 如果客户端不想使用服务器提供的描述,则可以简单地忽略它。


If you need internationalization, support the Accept-Language HTTP header to provide a description according to the desired language. 如果需要国际化,请支持Accept-Language HTTP标头以根据所需的语言提供描述。

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

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