使用驼峰式大小写吗

使用驼峰式大小写吗

本文介绍了我应该为 oauth2 使用驼峰式大小写吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我试图在 nestjs 中实现一个 oauth2 服务器并且我一直在阅读规范 [RFC 6749]
在规范中,所有查询参数名称甚至json响应都使用snake_case之类的.

So i'm trying to implement an oauth2 server in nestjs and i've been reading the specification [RFC 6749]
In the spec, all the query parameter names and even json response use snake_case like.

access_token
refresh_token
client_id
client_secret
redirect_uri
expires_in

问题是,我所有其余的代码库都使用驼峰命名法,而对一堆与 oauth 相关的类使用 snake_case 会使这些与代码库的其余部分不一致.

The problem is, all the rest of my codebase use camelCase and using snake_case for a bunch of oauth related classes would make these inconsistent with rest of the code base.

那么,我应该将所有 oauth 参数更改为驼峰式大小写还是会被视为不符合规范".

So, should I change all oauth parameters to camelCase or would that be considered "Not conforming to specification".

推荐答案

参数的拼写必须与规范中定义的完全一致,您不能随意重命名它们并且仍然符合规范.

The parameters are required to be spelled exactly as defined in the specification, you can't arbitrarily rename them and still be conforming to the specification.

accessTokenaccess_token 是一个完全不同的参数,任何实现该规范的客户端都希望您使用正确的名称,access_token,如规范中所定义.就客户端而言,提供名为 accessToken 的参数与提供名为 foobar 的参数没有什么不同.

accessToken is a completely different parameter than access_token, and any client implementing the specification will expect you to use the correct name, access_token, as defined in the spec. Serving up a parameter called accessToken is no different than serving up a parameter called foobar, as far as clients are concerned.

这篇关于我应该为 oauth2 使用驼峰式大小写吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 00:55