Skip to content

Parsing Avro unions with schema references #103

Closed

Description

@rayokota

The docs state that the Schema::parse_list can parse a set of schemas that depend on one another, but all schemas in the set need to be named.

How would I parse a set of schemas where one schema is a union that depends on other named schemas such as the following?

        let union = r#"["myschema1", "myschema2"]"#;

        let myschema1 = r#"
        {
            "type": "record",
            "name": "myschema1",
            "fields": [ {"name": "name", "type": "string"} ]
        }
        "#;

        let myschema2 = r#"
        {
            "type": "record",
            "name": 'myschema2',
            "fields": [ {"name": "age", "type": "int"} ]
        }
        "#;

It seems the Schema::parse_with_names(value: &Value, names: Names) method would work for this use case, but it is not currently public. Would it be possible to make that method public?

Activity

  1. martin-g commented on Jan 17, 2025

    @martin-g
    Member

    Please send a Pull Request with this snippet as a test case and making the method public!

  2. rayokota commented on Jan 18, 2025

    @rayokota
    ContributorAuthor

    Thanks @martin-g , I added a new method Schema:: parse_str_with_list that can be used to parse a root schema with a list of named schemas. #104

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions