Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proposal: do not expose implementation details of yaml schemas #5117

Closed
kt3k opened this issue Jun 24, 2024 · 5 comments · Fixed by #5175
Closed

proposal: do not expose implementation details of yaml schemas #5117

kt3k opened this issue Jun 24, 2024 · 5 comments · Fixed by #5175

Comments

@kt3k
Copy link
Member

kt3k commented Jun 24, 2024

Currently YAML package exposes implementation details of schemas as public APIs such as Schema class or Type class. These seem too much details to be provided as public API. I propose we should make these APIs private.

@iuioiua
Copy link
Collaborator

iuioiua commented Jun 24, 2024

Can you please clarify which symbols you'd like to make private and which you'd like to keep public?

@kt3k
Copy link
Member Author

kt3k commented Jun 24, 2024

Keep public

  • stringify
  • parse
  • parseAll
  • StyleVariant
  • DumpOption
  • ParseOption

Make private

  • CORE_SCHEMA
  • DEFAULT_SCHEMA
  • EXTENDED_SCHEMA
  • FAILSAFE_SCHEMA
  • JSON_SCHEMA
  • KindType
  • RepresentFn
  • Type

@iuioiua
Copy link
Collaborator

iuioiua commented Jun 24, 2024

Nice! Related thoughts:

  1. Is it worth keeping parseAll()? Is there something special about YAML that justifies having the ability to parse multiple YAML documents within a single body of text? Neither TOML or JSON(C) have this ability. If the answer to these questions is "no", I suggest removing parseAll().
  2. Is DEFAULT_SCHEMA the correct default schema? According to the YAML spec, CORE_SCHEMA should be the default schema.

WDYT?

@kt3k
Copy link
Member Author

kt3k commented Jun 25, 2024

Is there something special about YAML that justifies having the ability to parse multiple YAML documents within a single body of text?

YAML spec defines the special syntax for storing multiple documents in single file. parseAll supports parsing it. ref https://yaml.org/spec/1.2.0/#id2600795

Is DEFAULT_SCHEMA the correct default schema? According to the YAML spec, CORE_SCHEMA should be the default schema.

The default schema is extended from core schema. It seems adding binary, omap, pairs, set, timestamp, and merge types.

I searched the usage of these types in github search, and it seems these types are very common in actual yaml files (!!binary, !!set, << (merge) ). So I think changing the default schema to CORE_SCHEMA would cause a lot of troubles.

@iuioiua
Copy link
Collaborator

iuioiua commented Jun 25, 2024

Ok. Valid points. Thanks for investigating further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants