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

Implement JsonSchemaAs for OneOrMany instead of JsonSchema #760

Merged
merged 1 commit into from
Jun 30, 2024

Commits on Jun 28, 2024

  1. Implement JsonSchemaAs for OneOrMany instead of JsonSchema

    Currently, there is an `impl JsonSchema for WrapSchema<OneOrMany<...>>`.
    This works fine if you only directly need `OneOrMany` but causes errors
    if you want to nest it (e.g. `Option<OneOrMany<_>>`).
    
    This PR changes the impl to a `JsonSchemaAs` impl, which is the correct
    approach. I think I just missed these ones during a rebase. In any case,
    the change should be fully backwards compatible due to the blanket
    schema impl.
    
    I have added a snapshot test. The actual snapshot doesn't matter - the
    real test is that the struct below compiles
    
        #[serde_as]
        #[derive(Serialize, Deserialize, JsonSchema)]
        struct Test {
    	#[serde_as(as = "Option<OneOrMany<_>>")]
    	optional_vec: Option<Vec<String>>,
        }
    swlynch99 committed Jun 28, 2024
    Configuration menu
    Copy the full SHA
    dee706a View commit details
    Browse the repository at this point in the history