Skip to content

Object and enum types should be defined in $defs#155

Merged
jack-berg merged 3 commits into
open-telemetry:mainfrom
jack-berg:schema-and-subschemas
Jan 15, 2025
Merged

Object and enum types should be defined in $defs#155
jack-berg merged 3 commits into
open-telemetry:mainfrom
jack-berg:schema-and-subschemas

Conversation

@jack-berg
Copy link
Copy Markdown
Member

More cleanup as we approach stability.

Here I ensure the schema consistently uses JSON schema's schema / subschema options with a new schema modeling rule:

In order to promote stylistic consistency and allow for reuse of concepts, object and enum types should be defined in either as a top level schema document or as a subschema in a schema document's $defs.

The stylistic consistency part is obvious.

"allow for reuse of concepts" is less obvious. When a type is defined in $defs we can reference as many times as needed in properties. When a type is defined directly in a property (or inline if you prefer), that type can only describe the requirements for that single property.

This guidance applies to object and enum types. This means that excluded are all primitives and arrays.

@jack-berg jack-berg requested a review from a team as a code owner January 14, 2025 20:40
@jack-berg jack-berg changed the title Object and enum types should be defined in Object and enum types should be defined in $defs Jan 14, 2025
Comment thread README.md Outdated
Copy link
Copy Markdown
Member

@marcalff marcalff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, see minor changes.

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.

3 participants