Skip to content

ParameterValue enum with fields does not follow serde rename #159

@spoorn

Description

@spoorn

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

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