Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Embed and expose examples in Rust #198

Merged
merged 2 commits into from
Jan 5, 2024
Merged

Embed and expose examples in Rust #198

merged 2 commits into from
Jan 5, 2024

Conversation

Swatinem
Copy link
Member

@Swatinem Swatinem commented Jan 5, 2024

This embeds all the example data in the built Rust crate, and adds a new examples() method on Schema to expose that to consuming Rust code.

This embeds all the example data in the built Rust crate, and adds a new `examples()` method on `Schema` to expose that to consuming Rust code.
@Swatinem Swatinem self-assigned this Jan 5, 2024
@Swatinem Swatinem requested a review from a team as a code owner January 5, 2024 09:48
Copy link
Member

@untitaker untitaker left a comment

Choose a reason for hiding this comment

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

awesome ty!

rust/lib.rs Outdated
@@ -146,22 +152,28 @@ pub fn get_schema(topic: &str, version: Option<u16>) -> Result<Schema, SchemaErr
let s = serde_json::from_str(schema).map_err(|_| SchemaError::InvalidSchema)?;
let compiled_json_schema = JSONSchema::compile(&s).map_err(|_| SchemaError::InvalidSchema)?;

// FIXME(swatinem): This assumes that there is only a single examples directory
Copy link
Member

Choose a reason for hiding this comment

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

there is, or am i misunderstanding what this means?

Copy link
Member Author

Choose a reason for hiding this comment

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

I expanded the FIXME comment:

    // FIXME(swatinem): This assumes that there is only a single `examples` entry in the definition.
    // If we would want to support multiple, we would have to either merge those in code generation,
    // or rather use a `fn examples() -> impl Iterator`.

@Swatinem Swatinem merged commit 4104407 into main Jan 5, 2024
15 checks passed
@Swatinem Swatinem deleted the swatinem/examples branch January 5, 2024 10:01
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.

2 participants