Change message params types to match JSON-RPC spec#373
Change message params types to match JSON-RPC spec#373dbaeumer merged 3 commits intomicrosoft:gh-pagesfrom
Conversation
Since the interface is supposed to describe message format to match [JSON-RPC spec](http://www.jsonrpc.org/specification), the params type must be specified as either `Array` or `Object`. From spec: > 4.2 Parameter Structures > > If present, parameters for the rpc call MUST be provided as a Structured value. Either by-position through an Array or by-name through an Object.
|
Analogous to jacobdufault/cquery#247, sending not structured values as params (which is currently allowed here via |
|
Although we use JSON-RPC as a transport layer we decided to limit the params to a single object. This is why on the specification level we ony support a single object. From a spec point of view we should change the property to |
|
I understand that such a limitation might be convenient, however I believe there's a large benefit to retaining the compositional nature of the protocol. It's beneficial to be able to reuse existing JSON-RPC libs and format as is - we could simply add a note, such as 'Array params are technically allowed, but practically unused in LSP' to maintain the compatibility with the JSON-RPC protocol. This would be a win-win, I believe. |
|
We do so in the json-rpc library we use and maintain. It allows to handle arrays correct according to the JSON-RPC spec. Limiting this in the protocol is IMO a fair thing to do and nothing we can change without starting to break since users can implement custom messages. I don't see why we should allow array parameters and then say that they very likely will not work. Implementors of the protocol can still use existing JSON-RPC libs since they will work as design with 0 / 1 parameter. |
|
I realize this is mostly nitpicking, but we should be more consistent here: we can't just say we use and define interface for JSON-RPC messages, yet do otherwise.
The thing is, someone could've implemented custom messages passing params as arrays, which is correct under current phrasing that we use JSON-RPC spec, and also currently (in contradiction to previous phrasing) specified If we were to limit legal params type only to That is why I meant that we could still allow for |
|
You do have a valid point with us claiming that we support JSON-RPC and that custom messages could send arrays. So I would opt to do the following:
|
|
@dbaeumer done, I mentioned in the section that |
Since the interface is supposed to describe message format to match JSON-RPC spec,
the params type must be specified as either
ArrayorObject.From spec: