ikappas / vscode-composer

PHP Composer for Visual Studio Code
MIT License
24 stars 7 forks source link

Release with schema fix is missing #21

Closed gizmecano closed 2 years ago

gizmecano commented 3 years ago

It seems that a new release (implementing #20 which fixes #19) is still missing right now (cf. https://github.com/ikappas/vscode-composer/issues/19#issuecomment-898704741 and https://github.com/ikappas/vscode-composer/pull/20#issuecomment-899283252). Apparently, the develop branch has not been merged with the master branch.

🤔

At this time, the most recent release available on Visual Studio Marketplace is still 0.7.1 (dated from 12 Nov 2017) and not any automatted update is detected.

Therefore, the error below always recurs when using the extension:

Unable to load schema from 'http://json.schemastore.org/composer': Request vscode/content failed unexpectedly without providing any details.

miquelbrazil commented 2 years ago

tl;dr: add "$schema": "https://raw.githubusercontent.com/composer/composer/master/res/composer-schema.json" to the top of your composer.json file.

Hey @gizmecano, a quick way to solve this is to add a $schema key to your composer.json file and reference a working JSON schema store document.

In the first line of your composer.json file add:

"$schema": "https://raw.githubusercontent.com/composer/composer/master/res/composer-schema.json"

This references the relocated Composer schema validator found on the JSON Schema Store.

As an added benefit, composer validate should still work even with the $schema key.

Unfortunately, you would need to add this line every time you create a composer.json document in a new project.

A more permanent fix would be to go into the installed VSCode Composer extension source and manually change the contributes.jsonValidation key in the package.json file:

Original

"jsonValidation": [
    {
        "fileMatch": "composer.json",
        "url": "http://json.schemastore.org/composer"
    }
]

Updated

"jsonValidation": [
    {
        "fileMatch": "composer.json",
        "url": "https://raw.githubusercontent.com/composer/composer/master/res/composer-schema.json"
    }
]

Now the validation will work correctly for every composer.json file, but keep in mind that this change will get blown away if you ever reinstall the extension later.

Out of curiosity, I did do some experimentation with using the json.schemas key in the User, Workspace and Project settings.json to see if it was possible to override the extension-defined schema but it doesn't look like that's possible.

Adding the following in the settings.json doesn't seem to have any effect:

"json.schemas": [
    {
        "fileMatch": [
            "composer.json",
            "/composer.json"
        ],
        "url": "https://raw.githubusercontent.com/composer/composer/master/res/composer-schema.json"
    }
]

Hope this helps.

peter279k commented 2 years ago

IMHO, the correct way is to release a new version and this issue will be resolved.

gizmecano commented 2 years ago

Thanks @miquelbrazil, you suggestion works fine, but I have to fully agree with @peter279k by considering this kind of fix can only be regarded as provisional.

miquelbrazil commented 2 years ago

I agree with you both @peter279k @gizmecano. I only posted this fix with the intention that it would be temporary until develop was pulled into main or a new tag released.

Considering there doesn't appear to be any activity in 4 years…I'm not sure how hopeful we can be about that.

ikappas commented 2 years ago

Working on a release as we speak ;)

ikappas commented 2 years ago

Version 0.8.0 is out with updated json schema validation, so I am closing this issue.