Skip to content

Commit 10095e8

Browse files
committed
linter fixes
1 parent c3c6938 commit 10095e8

4 files changed

Lines changed: 22 additions & 8 deletions

File tree

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,15 @@ During the transition period the resolved schema **uses the `from` value** as th
323323
**Shorthand schema transition** (same transition for all operations):
324324

325325
```json
326-
{ "ucp_request": { "transition": { "from": "required", "to": "omit", "description": "Removed in v2." } } }
326+
{
327+
"ucp_request": {
328+
"transition": {
329+
"from": "required",
330+
"to": "omit",
331+
"description": "Removed in v2."
332+
}
333+
}
334+
}
327335
```
328336

329337
### Schema Composition

src/linter.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ fn check_annotation_value(
384384
message: format!(
385385
"invalid {} value type: expected string or transition object, got {}",
386386
key,
387+
json_type_name(val)
387388
),
388389
});
389390
}

src/resolver.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use serde_json::{Map, Value};
44

55
use crate::error::ResolveError;
66
use crate::types::{
7-
json_type_name, is_valid_schema_transition, Direction, ResolveOptions, SchemaTransitionInfo,
7+
is_valid_schema_transition, json_type_name, Direction, ResolveOptions, SchemaTransitionInfo,
88
Visibility, UCP_ANNOTATIONS,
99
};
1010

@@ -724,7 +724,9 @@ mod tests {
724724
assert!(result["properties"].get("id").is_some());
725725
let required = result["required"].as_array().unwrap();
726726
assert!(required.contains(&json!("id")));
727-
let transition = result["properties"]["id"].get("x-ucp-schema-transition").unwrap();
727+
let transition = result["properties"]["id"]
728+
.get("x-ucp-schema-transition")
729+
.unwrap();
728730
assert_eq!(transition["from"], "required");
729731
assert_eq!(transition["to"], "optional");
730732
assert_eq!(transition["description"], "Will become optional in v2.");
@@ -755,7 +757,9 @@ mod tests {
755757
assert!(result["properties"].get("id").is_some());
756758
let required = result["required"].as_array().unwrap();
757759
assert!(!required.contains(&json!("id")));
758-
assert!(result["properties"]["id"].get("x-ucp-schema-transition").is_some());
760+
assert!(result["properties"]["id"]
761+
.get("x-ucp-schema-transition")
762+
.is_some());
759763
assert_eq!(result["properties"]["id"]["deprecated"], true);
760764
}
761765

@@ -790,7 +794,10 @@ mod tests {
790794
assert!(result["properties"].get("id").is_some());
791795
let required = result["required"].as_array().unwrap();
792796
assert!(required.contains(&json!("id")));
793-
assert_eq!(result["properties"]["id"]["x-ucp-schema-transition"]["description"], "Removing in v2.");
797+
assert_eq!(
798+
result["properties"]["id"]["x-ucp-schema-transition"]["description"],
799+
"Removing in v2."
800+
);
794801
}
795802

796803
#[test]

src/types.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,7 @@ impl Visibility {
9292
/// Returns true if (from, to) is a valid schema transition: both are visibility
9393
/// values (omit, optional, required) and from != to.
9494
pub fn is_valid_schema_transition(from: &str, to: &str) -> bool {
95-
from != to
96-
&& Visibility::parse(from).is_some()
97-
&& Visibility::parse(to).is_some()
95+
from != to && Visibility::parse(from).is_some() && Visibility::parse(to).is_some()
9896
}
9997

10098
/// Options for schema resolution.

0 commit comments

Comments
 (0)