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

Metadata Usage #16

Closed
rgeber opened this issue Oct 27, 2023 · 4 comments · Fixed by #17
Closed

Metadata Usage #16

rgeber opened this issue Oct 27, 2023 · 4 comments · Fixed by #17

Comments

@rgeber
Copy link

rgeber commented Oct 27, 2023

Hello

Schema does include the Metadata type. However there is no information on how to use the type other then By default, jtd_derive doesn't generate any metadata.

Does this mean the feature is not supported at all or are there ways to add metadata to a struct?

cu
Roman

@uint
Copy link
Owner

uint commented Oct 30, 2023

Hi! Adding metadata is currently not supported.

What's your use case? Off the top of my head, would you expect to be able to do something like the following?

#[derive(JsonTypedef)]
#[typedef(metadata = "{codegen_ver: \"2\"}")]
struct Foo {
    x: u32,
}

@rgeber
Copy link
Author

rgeber commented Oct 30, 2023

Hi

Thanks for your reply.

My use case would be to store additional data for use by the frontend. E.g. a form builder.

This would be an idea:

#[derive(JsonTypedef)]
#[typedef(metadata = "{codegen_ver: \"2\"}")]
struct Foo {
   #[typedef(metadata = "{label: \"X coord\", required: true}")]
    x: u32,
}

cu
Roman

@uint
Copy link
Owner

uint commented Oct 30, 2023

Alright, I'll come up with something over the weekend.

@uint uint mentioned this issue Nov 5, 2023
@uint uint closed this as completed in #17 Nov 12, 2023
@uint
Copy link
Owner

uint commented Nov 12, 2023

Sorry for the delay.

I got 0.1.3 out with metadata support. I'll add proper docs sometime later (probably next weekend). For now, refer to these tests and LMK if anything's off!

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 a pull request may close this issue.

2 participants