-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
[REQ][Rust] Add additionalProperties to the generated code #20965
Comments
For now, I have copied the original file and modified it in my project. But this is not very sustainable, when the original file changes in he future |
@Vardaleb would you mind opening a PR for this? |
@Vardaleb About your PR, I've been working on the same issue on my side, and your fix adds the field to all the models, whereas we should know from the I encountered 2 types of additionalProperties, so here is my proposed fix: {{!### in the struct}}
{{#composedSchemas.allOf}}
{{#additionalProperties}}
#[serde(flatten)]
pub additional_properties: std::collections::HashMap<String, serde_json::Value>,
{{/additionalProperties}}
{{/composedSchemas.allOf}}
{{^composedSchemas.allOf}}
{{#isAdditionalPropertiesTrue}}
#[serde(flatten)]
pub additional_properties: std::collections::HashMap<String, serde_json::Value>,
{{/isAdditionalPropertiesTrue}}
{{/composedSchemas.allOf}}
{{!### in new()}}
{{!### allOf is an array}}
{{#composedSchemas.allOf}}
{{#additionalProperties}}
additional_properties: std::collections::HashMap::new(),
{{/additionalProperties}}
{{/composedSchemas.allOf}}
{{^composedSchemas.allOf}}
{{#isAdditionalPropertiesTrue}}
additional_properties: std::collections::HashMap::new(),
{{/isAdditionalPropertiesTrue}}
{{/composedSchemas.allOf}} In my test case, I have a map of String to String and a map of String to JSON. Maybe in the second case, we could use And there might be other ways to set |
Is your feature request related to a problem? Please describe.
Some openAPI specs do not contain every property they actually return. Right now it is not possible to access those properties
Describe the solution you'd like
The solution would be to include all undefined properties in the generated code, by modifying the
model.mustache
file like this:The text was updated successfully, but these errors were encountered: