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

ParameterValue enum with fields does not follow serde rename #159

Open
spoorn opened this issue Jan 10, 2025 · 0 comments
Open

ParameterValue enum with fields does not follow serde rename #159

spoorn opened this issue Jan 10, 2025 · 0 comments

Comments

@spoorn
Copy link

spoorn commented Jan 10, 2025

Enum fields like allow_reserved in ParameterValue is not following the serde rename:

okapi/okapi/src/openapi3.rs

Lines 276 to 298 in d3bc658

// maybe this should just been inlined into Parameter as fields?
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
#[cfg_attr(feature = "impl_json_schema", derive(JsonSchema))]
#[serde(untagged, rename_all = "camelCase")]
#[allow(clippy::large_enum_variant)] // Removing this requires breaking changes to API.
pub enum ParameterValue {
Schema {
#[serde(default, skip_serializing_if = "Option::is_none")]
style: Option<ParameterStyle>,
#[serde(default, skip_serializing_if = "Option::is_none")]
explode: Option<bool>,
#[serde(default, skip_serializing_if = "is_false")]
allow_reserved: bool,
schema: SchemaObject,
#[serde(default, skip_serializing_if = "Option::is_none")]
example: Option<Value>,
#[serde(default, skip_serializing_if = "Option::is_none")]
examples: Option<Map<String, Example>>,
},
Content {
content: Map<String, MediaType>,
},
}

It needs rename_all_fields specified to work on the enum fields: https://serde.rs/container-attrs.html

This causes it to fail OpenAPI spec validation

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

No branches or pull requests

1 participant