Closed
Description
Describe the bug
Encoding a string like "123" into Yaml when singleLineStringStyle
is set to SingleLineStringStyle.Plain
makes its associated type in Yaml if it wasn't a string. For example, "123" becomes 123 as an Int, "123.1" becomes 123.1 as a Float, and "true" becomes true as a Boolean. This should become quoted (single or double) when this is the case, regardless of the SingleLineStringStyle.
Reproduction repo
https://github.com/russellbanks/Komac
Steps to reproduce
- Create a YamlConfiguration with plain single line string style:
YamlConfiguration(singleLineStringStyle = SingleLineStringStyle.Plain)
- Encode a string like "123" into Yaml with this configuration
- The string will be encoded as an an Integer rather than a String, and not escaped with quotes
Expected behaviour
# yaml-language-server: $schema=https://aka.ms/winget-manifest.installer.1.4.0.schema.json
PackageIdentifier: Package.Identifier
PackageVersion: "123" # or '123'
ManifestVersion: 1.4.0
Actual behaviour
# yaml-language-server: $schema=https://aka.ms/winget-manifest.installer.1.4.0.schema.json
PackageIdentifier: Package.Identifier
PackageVersion: 123 # Incorrect type. Expected "string". yaml-schema: https://aka.ms/winget-manifest.installer.1.4.0.schema.json
ManifestVersion: 1.4.0
Version information
0.49.0
Any other information
https://stackoverflow.com/a/22235064:
- Use quotes to force a string, e.g. if your key or value is 10 but you want it to return a String and not a Fixnum, write '10' or "10".
Metadata
Metadata
Assignees
Labels
No labels