CLI: list --sort by method/tag, show merges path-level parameters

list: new --sort flag accepts path (default), method, or tag. All sort
modes maintain alias-first grouping for cross-alias queries. method sort
orders GET/POST/PUT/PATCH/DELETE/etc. tag sort uses first tag as primary
key with path and method as tiebreakers.

show: merge path-item-level parameters into operation parameters per
OpenAPI 3.x spec. Path-level params apply to all operations unless
overridden by an operation-level param with the same (name, in) pair.
Uses the operation_ptr to derive the parent path-item pointer and
resolve_json_pointer to access the raw spec.
This commit is contained in:
teernisse
2026-02-12 16:14:01 -05:00
parent 8455bca71b
commit a36997982a
2 changed files with 78 additions and 11 deletions

View File

@@ -388,13 +388,37 @@ async fn execute_all_aliases(args: &Args, robot_mode: bool) -> Result<(), Swagge
let filtered_count = all_entries.len();
// Sort: alias ASC, path ASC, method_rank ASC
all_entries.sort_by(|a, b| {
a.alias
.cmp(&b.alias)
.then_with(|| a.path.cmp(&b.path))
.then_with(|| method_rank(&a.method).cmp(&method_rank(&b.method)))
});
// Sort: alias first for grouping, then apply user's --sort preference
match args.sort.as_str() {
"method" => {
all_entries.sort_by(|a, b| {
a.alias
.cmp(&b.alias)
.then_with(|| method_rank(&a.method).cmp(&method_rank(&b.method)))
.then_with(|| a.path.cmp(&b.path))
});
}
"tag" => {
all_entries.sort_by(|a, b| {
let tag_a = a.tags.first().map(String::as_str).unwrap_or("");
let tag_b = b.tags.first().map(String::as_str).unwrap_or("");
a.alias
.cmp(&b.alias)
.then_with(|| tag_a.cmp(tag_b))
.then_with(|| a.path.cmp(&b.path))
.then_with(|| method_rank(&a.method).cmp(&method_rank(&b.method)))
});
}
// "path" or default
_ => {
all_entries.sort_by(|a, b| {
a.alias
.cmp(&b.alias)
.then_with(|| a.path.cmp(&b.path))
.then_with(|| method_rank(&a.method).cmp(&method_rank(&b.method)))
});
}
}
// ---- Limit ----
if !args.all {