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

Inlined object fields #108

Merged
merged 6 commits into from
Nov 15, 2024
Merged

Inlined object fields #108

merged 6 commits into from
Nov 15, 2024

Conversation

jaredoconnell
Copy link
Contributor

Changes introduced with this PR

This allows single-field objects to be specified in the serialized data as the single field.
This is useful when writing schemas for externally written libraries like the Kubernetes lib. There is a Format type that has all private fields except for the format string itself. In this case the extra level of indentation does not add anything to the clarity of the input.

Example:

some_object:
  value: true

can now be done as:

some_object: true

since it only has one field.

The potential con of this feature is potential confusion. However, I think it's at least partially outweighed by the potential simplification of the serialized data inputs. In addition, I think the error messages that I added should help when the values are inlined.

This PR also includes some additional test cases for objects that are not directly related to these changes.


By contributing to this repository, I agree to the contribution guidelines.

schema/object.go Show resolved Hide resolved
schema/object.go Outdated Show resolved Hide resolved
@jaredoconnell jaredoconnell merged commit 1c26e77 into main Nov 15, 2024
3 checks passed
@jaredoconnell jaredoconnell deleted the inlined-object-fields branch November 15, 2024 20:34
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 this pull request may close these issues.

2 participants