btp-setup-automator icon indicating copy to clipboard operation
btp-setup-automator copied to clipboard

different approach to schema association with use case files

Open qmacro opened this issue 3 years ago • 2 comments
trafficstars

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

qmacro avatar Oct 08 '22 12:10 qmacro

Need to add a similar config for the parameters.json data and schema

qmacro avatar Oct 11 '22 11:10 qmacro

@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?

lechnerc77 avatar Oct 15 '22 09:10 lechnerc77

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 avatar Oct 25 '22 16:10 qmacro

@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?

lechnerc77 avatar Dec 09 '22 11:12 lechnerc77

Closing as per discussion with @lechnerc77 ; was as much an experiment in thinking about this as anything else.

qmacro avatar Mar 17 '23 15:03 qmacro