RFC: Ion Schema 2.0

Summary

This RFC proposes a new major version of the Ion Schema Language: Ion Schema 2.0.

Ion Schema 2.0 will be fully interoperable with Ion Schema 1.0.

Ion Schema 2.0 introduces the following changes:

Motivation

Ion Schema Language (ISL) is a grammar and constraints for narrowing the universe of Ion values. A schema consists of zero or more types, and a type is a collection of zero or more constraints over the Ion data model.

Ion Schema Language is declarative and is intended to be portable across platforms and programming environments. Therefore, a schema document must have the same behavior on all equivalently configured Ion Schema implementations. If an implementation does not support all features used in a particular schema document, the implementation must error when it attempts to load that schema.

As Ion Schema has been used by customers, customers have asked for some new functionality to address feature gaps, and we identified some misfeatures and points of ambiguity that needed to be addressed. However, we realized that it is impossible to evolve the Ion Schema Language in a way that preserves the portability/compatibility goal. This is because:

Description of Changes

Compatibility with Ion Schema 1.0

The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this section are to be interpreted as described in RFC 2119.

Ion Schema 2.0 will be fully interoperable with Ion Schema 1.0.

Appendix — Below the Line/Out of Scope for Ion Schema 2.0

Schema/Type versioning

Some users have asked about schema versioning, but they have described multiple different versioning strategies. Based on the use cases that we have learned about, there does not appear to be a one-size-fits-all solution for schema versioning. Ion Schema will need to have its own versioning strategy for ion-schema-schemas, and we believe that it is possible via name mangling or a custom authority implementation. (One user had already indicated that name mangling is sufficient for their use case.)

We plan to add documentation and examples to suggest some methods for managing multiple versions of schemas, but we do not plan to add any features to Ion Schema 2.0 specifically to support versioned schemas and/or types.

See ion-schema #66.

User-Defined Constraints

We considered adding support for user-defined constraints. In Ion Schema 1.0, it is only possible to add a user-defined constraint by creating a custom Ion Schema implementation. In Ion Schema 2.0, this remains possible. Any user-defined constraint would be treated as open content by an implementation that does not support that user-defined constraint.

However, it would be possible to introduce a feature in Ion Schema Language that would allow users to indicate that certain open content fields are actually a user-defined constraint.

Ultimately, we chose to defer this because we are not sure if it is the right thing to do, and we believe we can safely introduce it in a new minor version of the Ion Schema Language by extending the open-content mechanism proposed in Open Content.

See ion-schema #68 for spec support for user-defined constraints and ion-schema-kotlin #33 for API support of user-defined constraints.

Other Language Features

There are several features that we thought of, but they were ultimately excluded because no one has actually asked for the feature (yet). All of these features could safely be introduced in a later minor version of Ion Schema, so excluding them is not a one-way door.

Code Generation

We would like to create tools for generating code from an Ion Schema, but we concluded it is an orthogonal concern that does not belong in the Ion Schema Language specification. You can comment on code generation for JVM in ion-schema-kotlin #146 or C/C++ code generation in ion-schema #49, or open a new issue for a new code generation target.