spectral: Error: Mapping key must be a string scalar rather than number

Looking for a way to turn off that error caused by OAS response code keys that the linter interprets as numbers. It’s kind of misleading, and in large specs it produces a lot of useless report lines. I can’t find anything in docs about disabling the errors generated by parser.

petstore.txt linter_report.txt

Thanks

P.S. Looks like key validation logic was recently introduced in @spectral/yaml in https://github.com/stoplightio/yaml/commit/2712bee8ef672127ade17c3d6d17a9771383f532 and the workaround is to roll back to 3.4.0 version of @spectral/yaml.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 20 (7 by maintainers)

Most upvoted comments

I am not using JSON so I frankly don’t care if it does not support numbers as keys. If I would convert yaml to json, I am pretty sure the tool used to do that would handle such cases.

So if YAML supports numeric keys, this rule should be made rather optional or dependant on the source file type.

I agree with @pkuczynski: ideally, valid OpenAPI YAML would not be throwing these errors.