A Kotlin reference implementation of the Ion Schema Specification. This is currently alpha software and all aspects of it are subject to change.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github
data/test
gradle/wrapper
src/software/amazon/ionschema
test/software/amazon/ionschema
.travis.yml
CODE_OF_CONDUCT.md
CONTRIBUTING.md
LICENSE
NOTICE
README.md
build.gradle
gradlew

README.md

Ion Schema Kotlin

A reference implementation of the Ion Schema Specification, written in Kotlin.

Build Status Maven Central Javadoc

This is currently alpha software and all aspects of it are subject to change.

Getting Started

The following code provides a simple example of how to use this API from Java. The Customer type is a struct that requires firstName and lastName fields as strings, while the middleName field is optional.

Before running, replace <base_path> with the path containing "/data/test".

import software.amazon.ion.IonSystem;
import software.amazon.ion.IonValue;
import software.amazon.ion.system.IonSystemBuilder;
import software.amazon.ionschema.AuthorityFilesystem;
import software.amazon.ionschema.IonSchemaSystem;
import software.amazon.ionschema.Schema;
import software.amazon.ionschema.Type;

public class IonSchemaGettingStarted {
    private static IonSystem ION = IonSystemBuilder.standard().build();

    public static void main(String[] args) {
        IonSchemaSystem iss = IonSchemaSystem.Builder.standard()
                .withAuthority(new AuthorityFilesystem("<base_path>/data/test"))
                .build();

        Schema schema = iss.loadSchema("/schema/Customer.isl");
        Type type = schema.getType("Customer");

        checkValue(type, "{ firstName: \"Susie\", }");
        checkValue(type, "{ firstName: \"Susie\", lastName: \"Smith\" }");
        checkValue(type, "{ firstName: \"Susie\", middleName: \"B\", lastName: \"Smith\" }");
    }

    private static void checkValue(Type type, String str) {
        IonValue value = ION.singleValue(str);
        System.out.println(str + ": " + type.isValid(value));
    }
}

Helping out

The issues identified below represent the next steps for this project. Most are relatively small and self-contained; larger efforts are shown below in bold.

  • #1 add/verify support for schema import
  • #2 provide validation details when a value is invalid
  • #3 add support for open/closed content
  • #4 implement the annotations constraint
  • #5 implement the timestamp_offset constraint
  • #6 implement the timestamp_precision constraint
  • #7 verify the element constraint works for structs
  • #8 update valid_values constraint to support timestamp ranges
  • #9 assert that constraints are compatible with the type on which they are specified
  • #10 define a schema for ISL
  • #11 add support for the document type

License

This library is licensed under the Apache 2.0 License.