amazon-ion / ion-schema-rust

Rust implementation of Ion Schema
https://amazon-ion.github.io/ion-schema/sandbox
Apache License 2.0
13 stars 6 forks source link

Support the `document` core type #123

Closed jobarr-amzn closed 1 year ago

jobarr-amzn commented 1 year ago

ion-schema-rust does not seem to support the document core type, described in the Ion schema spec here.

Given this content adapted from the document example in the Ion Schema specification docs:

❯ cat document_example.isl
$ion_schema_1_0
schema_header::{
}

type::{
  name: IonSchema,
  type: document,
  ordered_elements: [
    { type: Header, occurs: optional },
    { type: Type,   occurs: range::[0, max] },
    { type: Footer, occurs: optional },
  ],
}

type::{
  name: Header,
  type: struct,
  annotations: [required::schema_header],
  fields: {
    imports: ImportList,
  },
}

type::{
  name: ImportList,
  type: list
}

type::{
  name: Type,
  type: struct,
  annotations: [required::type],
  fields: {
    name: symbol,
  },
}

type::{
  name: Footer,
  type: struct,
  annotations: [required::schema_footer],
}

schema_footer::{
}

ion-schema-rust fails because there is no known document type:

❯ ion beta schema validate \
--input document_example.isl \
--schema document_example.isl \
--directory . \
--type IonSchema
Error: Could not resolve type reference: "document" does not exist
desaikd commented 1 year ago

ion-schema-rust does support document core type. I tried reproducing this issue to see if there was any other bug here. It seems to work fine withis repository's example CLI. I tried the following command:

cargo run --package ion-schema --example schema load --directory <AUTHORITY-FOLDER> --schema <SCHEMA-FILE>

Output for the above command generates a Schema struct without any errors.

How was this issue produced? If you have used ion-cli then it is pointing to an earlier version of ion-schema-rust and hence this issue might be produced from there. I will be updating that to the latest version after a new release with latest GitHub changes for ion-schema-rust.

jobarr-amzn commented 1 year ago

Yeah, I used ion-cli. It looks like document support was added in this PR: https://github.com/amzn/ion-schema-rust/pull/116 .

jobarr-amzn commented 1 year ago

Closing in favor of https://github.com/amzn/ion-cli/issues/38