-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Open
Labels
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
In the latest version of the generator the following definition:
openapi: "3.0.0"
info:
version: 1.0.0
title: Bug
paths: {}
components:
schemas:
MyModel:
type: object
required:
- my_field
properties:
my_field:
type: object
additionalProperties:
type: string
nullable: trueWill produce the following Rust model:
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct MyModel {
#[serde(rename = "my_field")]
pub my_field: std::collections::HashMap<String, String>,
}This fails to decode JSON which has additional null properties, for example:
{
"my_field": {
"extra_field": null
}
}The proper type to use for my_field would be:
HashMap<String, Option<String>>I've created a possible fix for this problem in this commit.