btp-setup-automator
btp-setup-automator copied to clipboard
different approach to schema association with use case files
Associating JSON schemas with specific JSON files by adding a $schema property in the JSON data itself seems to be a VS Code specific approach (one of a number of options) - for example, association is done differently in WebStorm.
I wanted to see how it "feels" to be able to avoid adding the $schema property into every use case file, to make the association. Instead, I've added workspace specific configuration to do this instead:
"json.schemas": [
{
"fileMatch": [
"*usecase.json"
],
"url": "https://raw.githubusercontent.com/SAP-samples/btp-setup-automator/main/libs/btpsa-usecase.json"
}
]
But in order to be able to match multiple use case files within the set of subdirectories within usecases/, using the limited file match syntax, I've had to think about modifying the use case filenames, so that they all end in usecase.json, which seems like a nice pattern to have anyway. I've just done this with two of the use case files for now:
usecases/released/discoverycenter/3239-customui/usecase.json
and also:
usecases/released/default.usecase.json
which was, originally:
usecases/released/default.json
Need to add a similar config for the parameters.json data and schema
@qmacro Thanks for the contribution. One question: the main identification now happens in the .vscode/settings.json, which means that the new setup will then work out of the box for VSCode users but not any more for Webstorms user. Is my understanding correct?
Sorry for the delay in replying, @lechnerc77. My understanding that the current $schema property based association (basically adding a magic property to the JSON that we want to constrain with a schema) is a VS Code specific thing. Associating JSON Schemas with JSON content in WebStorm is also done with configuration (like the approach in this PR with configuration in settings.json).
@qmacro : I would like to add your VSCode configuration to the project including a bit of documentation based on your explanation. I would however not change the reference to the JSON schema in the JSON files for the use cases and parameters, as this might be a disruptive change for non VSCode users.
Is that okay for you?
Closing as per discussion with @lechnerc77 ; was as much an experiment in thinking about this as anything else.