Jinto Joseph
Jinto Joseph

Reputation: 1424

yaml extension error ( Incorrect type. Expected "string".yaml-schema: pubspec.yaml )

enter image description here

Recently I created a flutter project and opened the "YAML", getting some error from "YAML" extension. How can I solve this? Is the only solution to uninstall the extension or how to overcome this without uninstalling this extension?

Tried flutter clean, repair, etc. but nothing was helpful.

Errors are:

1 Incorrect type. Expected "string". yaml-schema: pubspec.yaml

2 Property flutter is not allowed. yaml-schema: pubspec.yaml

3 Property cupertino_icons is not allowed. yaml-schema: pubspec.yaml

4 Property flutter_test is not allowed. yaml-schema: pubspec.yaml

5 etc.

Using flutter version is 2.8.1

"YAML" (extension) version v1.5.0

Upvotes: 13

Views: 15305

Answers (8)

MoSwilam
MoSwilam

Reputation: 944

Removing Yaml extension did the trick for me, in fact I don't really see the need for it since VS Code supports YAML formats by default

Upvotes: 2

Usama Karim
Usama Karim

Reputation: 1438

Please update VSCode's YAML extension to at least 1.5.1 to resolve the error. Flutter will work as it is with the errors too.

Upvotes: 0

Mohamed Dernoun
Mohamed Dernoun

Reputation: 825

I reload the YAML extension and the error gone

Upvotes: 3

mailliwi
mailliwi

Reputation: 31

I fixed mine by reloading the extension. I went to my extensions tab and the YAML extension needed to be reloaded.

It does not show here but instead on the left of "Disable", there was a message telling me that I needed to reload the extension.

Upvotes: 0

AkbarB
AkbarB

Reputation: 530

For me, in the extensions of VsCode, I looked for YAML and I saw there is a "reload required" next to it. did the reload and the errors went away. It is all fixed now.

Upvotes: 0

Kalyan Biswas
Kalyan Biswas

Reputation: 408

i have uninstall yaml extention and reinstall and re-open vs code it fixes the issue for meenter image description here

Upvotes: 2

fastlorenzo
fastlorenzo

Reputation: 31

I'm having the same issue with VSCode since this afternoon, everything worked well before. I've tried forcing the schema via # yaml-language-server: $schema=<urlToTheSchema> and yaml.schemas setting, but no luck.

Edit: could be related to upgrading to yaml extension v1.5.0 (cf: https://github.com/redhat-developer/vscode-yaml/issues/708) Temporarily downgrading back to 1.4.0 no longer throws errors.

Upvotes: 3

flyx
flyx

Reputation: 39768

The YAML extension is using an incorrect schema to validate your YAML file. Ensure that:

  • your file does contain a correct # yaml-language-server: $schema=<urlToTheSchema> comment or at least does not contain a wrong one.
  • your yaml.schemas setting does not associate your file via glob pattern with an incorrect schema.

The correct schema would be https://json.schemastore.org/pubspec.json. See also Associating Schemas.

Upvotes: 1

Related Questions