Skip to content

Fields inside untagged enum #9

@ctaggart

Description

@ctaggart

-- ❤️ --> Serde is amazing! Thank you for making it.

I wrote an assert_deserialized_without_ignored, hoping that it would catch anything that is ignored, but it misses many items. Did I misunderstand something?

pub fn assert_deserialize_without_ignored<P: AsRef<Path> + std::fmt::Debug>(paths: Vec<P>) -> Result<()> {
    for path in paths {
        println!("  test {:?}", path);
        let mut bytes = Vec::new();
        File::open(path)?.read_to_end(&mut bytes)?;
        let deserializer = &mut serde_json::Deserializer::from_slice(&bytes);
        let mut ignored = Vec::new();
        let _spec: OpenAPI = serde_ignored::deserialize(deserializer, |path| {
            let path = path.to_string();
            println!("    ignored {}", &path);
            ignored.push(path);
        })?;
        assert_eq!(0, ignored.len());
    }
    Ok(())
}

See ctaggart/autorust_openapi#3 (comment) for a specific case about x-nullable not showing up as ignored for https://github.com/Azure/azure-rest-api-specs/blob/master/specification/batch/data-plane/Microsoft.Batch/stable/2020-09-01.12.0/BatchService.json.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions