chore: add #[non_exhaustive] to remaining public structs (#768)
* chore: add #[non_exhaustive] to remaining public structs * chore: add #[non_exhaustive] to remaining public types * chore: enable exhaustive_structs/enums clippy lints * test: add untagged ServerResult deserialization regression tests
This commit is contained in:
parent
ee1c63c53f
commit
6a3b32d3ab
1 changed files with 430 additions and 211 deletions
|
|
@ -49,6 +49,7 @@ const_string!(ArrayTypeConst = "array");
|
|||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
||||
#[serde(untagged)]
|
||||
#[expect(clippy::exhaustive_enums, reason = "intentionally exhaustive")]
|
||||
pub enum PrimitiveSchema {
|
||||
/// Enum property (explicit enum schema)
|
||||
Enum(EnumSchema),
|
||||
|
|
@ -70,6 +71,7 @@ pub enum PrimitiveSchema {
|
|||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
#[expect(clippy::exhaustive_enums, reason = "intentionally exhaustive")]
|
||||
pub enum StringFormat {
|
||||
/// Email address format
|
||||
Email,
|
||||
|
|
@ -344,6 +346,7 @@ impl NumberSchema {
|
|||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[expect(clippy::exhaustive_structs, reason = "intentionally exhaustive")]
|
||||
pub struct IntegerSchema {
|
||||
/// Type discriminator
|
||||
#[serde(rename = "type")]
|
||||
|
|
@ -510,6 +513,7 @@ impl BooleanSchema {
|
|||
/// Represent single entry for titled item
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
||||
#[expect(clippy::exhaustive_structs, reason = "intentionally exhaustive")]
|
||||
pub struct ConstTitle {
|
||||
#[serde(rename = "const")]
|
||||
pub const_: String,
|
||||
|
|
@ -530,6 +534,7 @@ impl ConstTitle {
|
|||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
||||
#[expect(clippy::exhaustive_structs, reason = "intentionally exhaustive")]
|
||||
pub struct LegacyEnumSchema {
|
||||
#[serde(rename = "type")]
|
||||
pub type_: StringTypeConst,
|
||||
|
|
@ -595,6 +600,7 @@ impl TitledSingleSelectEnumSchema {
|
|||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
||||
#[serde(untagged)]
|
||||
#[expect(clippy::exhaustive_enums, reason = "intentionally exhaustive")]
|
||||
pub enum SingleSelectEnumSchema {
|
||||
Untitled(UntitledSingleSelectEnumSchema),
|
||||
Titled(TitledSingleSelectEnumSchema),
|
||||
|
|
@ -603,6 +609,7 @@ pub enum SingleSelectEnumSchema {
|
|||
/// Items for untitled multi-select options
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
||||
#[expect(clippy::exhaustive_structs, reason = "intentionally exhaustive")]
|
||||
pub struct UntitledItems {
|
||||
#[serde(rename = "type")]
|
||||
pub type_: StringTypeConst,
|
||||
|
|
@ -613,6 +620,7 @@ pub struct UntitledItems {
|
|||
/// Items for titled multi-select options
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
||||
#[expect(clippy::exhaustive_structs, reason = "intentionally exhaustive")]
|
||||
pub struct TitledItems {
|
||||
// MCP spec requires "anyOf" for multi-select enums (allows any combination)
|
||||
// Alias "oneOf" for compatibility with schemars
|
||||
|
|
@ -718,6 +726,7 @@ impl TitledMultiSelectEnumSchema {
|
|||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
||||
#[serde(untagged)]
|
||||
#[expect(clippy::exhaustive_enums, reason = "intentionally exhaustive")]
|
||||
pub enum MultiSelectEnumSchema {
|
||||
Untitled(UntitledMultiSelectEnumSchema),
|
||||
Titled(TitledMultiSelectEnumSchema),
|
||||
|
|
@ -741,6 +750,7 @@ pub enum MultiSelectEnumSchema {
|
|||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
||||
#[serde(untagged)]
|
||||
#[expect(clippy::exhaustive_enums, reason = "intentionally exhaustive")]
|
||||
pub enum EnumSchema {
|
||||
Single(SingleSelectEnumSchema),
|
||||
Multi(MultiSelectEnumSchema),
|
||||
|
|
@ -749,9 +759,11 @@ pub enum EnumSchema {
|
|||
|
||||
/// Marker type for single-select enum builder
|
||||
#[derive(Debug)]
|
||||
#[expect(clippy::exhaustive_structs, reason = "intentionally exhaustive")]
|
||||
pub struct SingleSelect;
|
||||
/// Marker type for multi-select enum builder
|
||||
#[derive(Debug)]
|
||||
#[expect(clippy::exhaustive_structs, reason = "intentionally exhaustive")]
|
||||
pub struct MultiSelect;
|
||||
/// Builder for EnumSchema
|
||||
/// Allows to create various enum schema types (single/multi select, titled/untitled)
|
||||
|
|
@ -1077,6 +1089,7 @@ impl EnumSchema {
|
|||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[expect(clippy::exhaustive_structs, reason = "intentionally exhaustive")]
|
||||
pub struct ElicitationSchema {
|
||||
/// Always "object" for elicitation schemas
|
||||
#[serde(rename = "type")]
|
||||
|
|
@ -1221,6 +1234,7 @@ impl ElicitationSchema {
|
|||
/// .build();
|
||||
/// ```
|
||||
#[derive(Debug, Default)]
|
||||
#[expect(clippy::exhaustive_structs, reason = "intentionally exhaustive")]
|
||||
pub struct ElicitationSchemaBuilder {
|
||||
pub properties: BTreeMap<String, PrimitiveSchema>,
|
||||
pub required: Vec<String>,
|
||||
|
|
|
|||
Loading…
Reference in a new issue