jlandersen / vscode-kafka

Apache Kafka® extension for Visual Studio Code

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for value format validation

omerd-cyera opened this issue · comments

Hi,
Does this extension currently support body validation?
If not, It could be nice to have json format validation (eg: if you forgot to remove a trailing ,):
image
Currently, the message is sent with bad format.

Also, might be nice to support custom json-schema validations.
image

Would love to hear what you think.
And thanks for the great extension :)

Does this extension currently support body validation?

No.

Would love to hear what you think.

Indeed it should be nice, but I fear that it will not an easy task. The first thing to do is to study if we can use https://github.com/microsoft/vscode-json-languageservice to manage partial JSON validation, hover, completion, etc.

Yep, I think we can start with the first suggestion and see how it goes.
Ill update here when i find time to work on this. Thanks :)

Hey,
I finally got to work on this a little, I have a working POC using vscode-json-languageservice in KafkaFileDiagnostics.
Do you think its fine to parse the json section with the json language service on every KafkaFileDiagnostics.doDiagnostics?

Feels like a bad design to me. but not sure whats a better fitting solution looks like.
Maybe we can think about creating another, more specific JSONProducerBlock that caches the parsed JSONDocument.

Also seems like the way to add diagnostics in an embeded document is a little hacky, from what i can tell, I'm supposed to clone the document, and replace all the characters in it with " " except for the embeded part. That way the diagnostics align on the original document. Not sure if you have any experience with this sort of stuff, but would love to know if you have an alternative solution.

Thanks so muuch foe studying this super nice feature.

I think we should follow the same idea than vscode html language server which consumes html and CSS vscode language service since html can embedds CSS. I think we should have languages modes (today we will have JSON mode):

For instance for validation, you get all languages mode like html language server does https://github.com/microsoft/vscode/blob/11cea7dfb79b4bcbea2b99f3c955a7636ddeac58/extensions/html-language-features/server/src/htmlServer.ts#L280 and consumes doValidation like https://github.com/microsoft/vscode/blob/11cea7dfb79b4bcbea2b99f3c955a7636ddeac58/extensions/html-language-features/server/src/htmlServer.ts#L286

Here a sample with cssMode doValidation https://github.com/microsoft/vscode/blob/11cea7dfb79b4bcbea2b99f3c955a7636ddeac58/extensions/html-language-features/server/src/modes/cssMode.ts#L20

I suggest that you try to mimic the language mode used in vscode. See https://github.com/microsoft/vscode/blob/main/extensions/html-language-features/server/src/modes/cssMode.ts which support CSS features not only diagnostics but completion etc that we should support too for json