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

an example to manually impl JsonSchema for merge strategies #390

Merged
merged 2 commits into from
Jan 28, 2021

Conversation

clux
Copy link
Member

@clux clux commented Jan 25, 2021

an addon, and illustration of the more manual parts of #129

an addon, and illustration of the more manual parts of #129
@kazk
Copy link
Member

kazk commented Jan 25, 2021

Not directly related to this PR, but I think Arnavion/k8s-openapi#86 can be done with similar impl JsonSchema for newtype wrapping k8s_openapi type. Can you try it? I'll look into it later if not.

@clux
Copy link
Member Author

clux commented Jan 25, 2021

Ah, yes, that might work as well. I'll have a go, but a bit busy till Wednesday. CURIOSITY WINS

@clux
Copy link
Member Author

clux commented Jan 25, 2021

Ah, read that issue a bit more. Yeah, I think it would work with something like:

// Newtype on PodSpec to allow implementing JsonSchema on k8s_openapi types
#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Clone)]
struct PodSpec(k8s_openapi::api::core::v1::PodSpec);
impl JsonSchema for PodSpec {
    fn schema_name() -> String {
        "PodSpec".into()
    }
    fn json_schema(_: &mut SchemaGenerator) -> Schema {
        schemars::schema::Schema::deserialize(k8s_openapi::api::core::v1::PodSpec::schema()).unwrap()
    }
}

although not something that can be done atm as k8s_openapi::...::PodSpec::schema() is just a hypothetical thing.

EDIT: well, seems i was wrong. but let's discuss over at the referenced openapi issue.

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