data-api-builder icon indicating copy to clipboard operation
data-api-builder copied to clipboard

[CLI]: Preserve comments in config file when using `dab add` and `dab update`

Open ayush3797 opened this issue 2 years ago • 2 comments

Whenever dab add, dap update or any CLI command which does modifications to the config file is issued, the comments which are present in the config file are lost. Need to fix this behaviour.

ayush3797 avatar Jan 28 '23 04:01 ayush3797

Need to know more about the usage of comments in the config Json file.

For Example:

if we have a comment stating the reason why we have enabled rest calls for an entity and then if we disable the rest api calls, and the comments are preserved, it won't make sense.

Here is a link which states that it's better to keep Json data only and suggests we use a new key-value pair to represent comment with key as "_comments".

Some suggested to remove comments before passed into JSON encoder, which is what we are currently doing. And these comments are stripped off once the Encoder outputs the JSON after dab add or dab update.

abhishekkumams avatar Apr 27 '23 10:04 abhishekkumams

if we have a comment stating the reason why we have enabled rest calls for an entity and then if we disable the rest api calls, The fact the comments may be out of sync with what the code/config does is not a problem we can solve right now. It's true for every language that supports comments.

Here is a link which state I think the link got lost somewhere. can you post it again?

In general VSCode supports the jsonc format, which is JSON with comments, so it make sense we support it too, in case comments are needed in a config file: https://code.visualstudio.com/Docs/languages/json#_json-with-comments

yorek avatar May 15 '23 15:05 yorek