diff --git a/crates/oapi-macros/src/endpoint/server.rs b/crates/oapi-macros/src/endpoint/server.rs index 74e5ac780..49bd6f0cf 100644 --- a/crates/oapi-macros/src/endpoint/server.rs +++ b/crates/oapi-macros/src/endpoint/server.rs @@ -191,13 +191,13 @@ impl Server { /// Add url to the target [`Server`]. pub fn url>(mut self, url: U) -> Self { self.url = url.into(); -self + self } /// Add or change description of the [`Server`]. pub fn description>(mut self, description: S) -> Self { self.description = Some(description.into()); -self + self } /// Add parameter to [`Server`] which is used to substitute values in [`Server::url`]. @@ -304,21 +304,21 @@ impl ServerVariable { Default::default() } /// Add default value for substitution. - pub fn default_value>(mut self, default_value: S) -> Self { - self.default_value = default_value.into(); -self + pub fn default_value(mut self, default: impl Into) -> Self { + self.default_value = Some(default.into()); + self } /// Add or change description of substituted parameter. - pub fn description>(mut self, description: S) -> Self { + pub fn description(mut self, description: impl Into) -> Self { self.description = Some(description.into()); -self + self } /// Add or change possible values used to substitute parameter. pub fn enum_values, V: Into>(mut self, enum_values: I) -> Self { self.enum_values = enum_values.into_iter().map(|value| value.into()).collect(); -self + self } } diff --git a/crates/oapi-macros/src/schema/enum_variant.rs b/crates/oapi-macros/src/schema/enum_variant.rs index bb492a40a..cb4c13b45 100644 --- a/crates/oapi-macros/src/schema/enum_variant.rs +++ b/crates/oapi-macros/src/schema/enum_variant.rs @@ -255,7 +255,7 @@ impl ToTokens for UntaggedEnum { tokens.extend(quote! { #oapi::oapi::schema::Object::new() .nullable(true) - .default(Some(serde_json::Value::Null)) + .default_value(serde_json::Value::Null) #symbol }) } diff --git a/crates/oapi/src/lib.rs b/crates/oapi/src/lib.rs index 83d8b82b0..66684ae5d 100644 --- a/crates/oapi/src/lib.rs +++ b/crates/oapi/src/lib.rs @@ -267,7 +267,7 @@ impl ToSchema for Option { impl ToSchema for PhantomData { fn to_schema(_components: &mut Components) -> RefOr { - Schema::Object(Object::default()).into() + Schema::Object(Default::default()).into() } } diff --git a/crates/oapi/src/openapi/schema/all_of.rs b/crates/oapi/src/openapi/schema/all_of.rs index d06162c49..ce6fe2262 100644 --- a/crates/oapi/src/openapi/schema/all_of.rs +++ b/crates/oapi/src/openapi/schema/all_of.rs @@ -25,8 +25,8 @@ pub struct AllOf { pub description: Option, /// Default value which is provided when user has not provided the input in Swagger UI. - #[serde(skip_serializing_if = "Option::is_none")] - pub default: Option, + #[serde(rename = "default", skip_serializing_if = "Option::is_none")] + pub default_value: Option, /// Example shown in UI of the value for richer documentation. #[serde(skip_serializing_if = "Option::is_none")] @@ -89,7 +89,7 @@ impl AllOf { /// Add or change default value for the object which is provided when user has not provided the input in Swagger UI. pub fn default_value(mut self, default: Value) -> Self { - self.default = Some(default); + self.default_value = Some(default); self } diff --git a/crates/oapi/src/openapi/schema/any_of.rs b/crates/oapi/src/openapi/schema/any_of.rs index b4fc6b788..777c4e923 100644 --- a/crates/oapi/src/openapi/schema/any_of.rs +++ b/crates/oapi/src/openapi/schema/any_of.rs @@ -25,8 +25,8 @@ pub struct AnyOf { pub description: Option, /// Default value which is provided when user has not provided the input in Swagger UI. - #[serde(skip_serializing_if = "Option::is_none")] - pub default: Option, + #[serde(rename = "default", skip_serializing_if = "Option::is_none")] + pub default_value: Option, /// Example shown in UI of the value for richer documentation. #[serde(skip_serializing_if = "Option::is_none")] @@ -89,7 +89,7 @@ impl AnyOf { /// Add or change default value for the object which is provided when user has not provided the input in Swagger UI. pub fn default_value(mut self, default: Value) -> Self { - self.default = Some(default); + self.default_value = Some(default); self } diff --git a/crates/oapi/src/openapi/schema/array.rs b/crates/oapi/src/openapi/schema/array.rs index 869008db3..4b28b940c 100644 --- a/crates/oapi/src/openapi/schema/array.rs +++ b/crates/oapi/src/openapi/schema/array.rs @@ -34,8 +34,8 @@ pub struct Array { pub example: Option, /// Default value which is provided when user has not provided the input in Swagger UI. - #[serde(skip_serializing_if = "Option::is_none")] - pub default: Option, + #[serde(rename = "default", skip_serializing_if = "Option::is_none")] + pub default_value: Option, /// Max length of the array. #[serde(skip_serializing_if = "Option::is_none")] @@ -69,7 +69,7 @@ impl Default for Array { description: Default::default(), deprecated: Default::default(), example: Default::default(), - default: Default::default(), + default_value: Default::default(), max_items: Default::default(), min_items: Default::default(), xml: Default::default(), @@ -125,8 +125,8 @@ impl Array { } /// Add or change default value for the object which is provided when user has not provided the input in Swagger UI. - pub fn default(mut self, default: Value) -> Self { - self.default = Some(default); + pub fn default_value(mut self, default: Value) -> Self { + self.default_value = Some(default); self } diff --git a/crates/oapi/src/openapi/schema/mod.rs b/crates/oapi/src/openapi/schema/mod.rs index c5fb9ade7..3872476da 100644 --- a/crates/oapi/src/openapi/schema/mod.rs +++ b/crates/oapi/src/openapi/schema/mod.rs @@ -62,7 +62,7 @@ pub enum Schema { impl Default for Schema { fn default() -> Self { - Schema::Object(Object::default()) + Schema::Object(Default::default()) } } diff --git a/crates/oapi/src/openapi/schema/object.rs b/crates/oapi/src/openapi/schema/object.rs index 558ca4089..2b0a22573 100644 --- a/crates/oapi/src/openapi/schema/object.rs +++ b/crates/oapi/src/openapi/schema/object.rs @@ -43,8 +43,8 @@ pub struct Object { pub description: Option, /// Default value which is provided when user has not provided the input in Swagger UI. - #[serde(skip_serializing_if = "Option::is_none")] - pub default: Option, + #[serde(rename = "default", skip_serializing_if = "Option::is_none")] + pub default_value: Option, /// Enum variants of fields that can be represented as `unit` type `enums` #[serde(rename = "enum", skip_serializing_if = "Option::is_none")] @@ -213,7 +213,7 @@ impl Object { /// Add or change default value for the object which is provided when user has not provided the input in Swagger UI. pub fn default_value(mut self, default: Value) -> Self { - self.default = Some(default); + self.default_value = Some(default); self } diff --git a/crates/oapi/src/openapi/schema/one_of.rs b/crates/oapi/src/openapi/schema/one_of.rs index 6fd9724d0..8b9fcb099 100644 --- a/crates/oapi/src/openapi/schema/one_of.rs +++ b/crates/oapi/src/openapi/schema/one_of.rs @@ -25,8 +25,8 @@ pub struct OneOf { pub description: Option, /// Default value which is provided when user has not provided the input in Swagger UI. - #[serde(skip_serializing_if = "Option::is_none")] - pub default: Option, + #[serde(rename = "default", skip_serializing_if = "Option::is_none")] + pub default_value: Option, /// Example shown in UI of the value for richer documentation. #[serde(skip_serializing_if = "Option::is_none")] @@ -89,7 +89,7 @@ impl OneOf { /// Add or change default value for the object which is provided when user has not provided the input in Swagger UI. pub fn default_value(mut self, default: Value) -> Self { - self.default = Some(default); + self.default_value = Some(default); self }