Skip to content

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

Commit

Keep CLI operation tables stable with OpenAPI header metadata

syntaqxcommitted Parenta8f62b9Browse files
1 file+15−10/1 viewed
+15−1
172172 writeln!(text, " scope: {scope},").unwrap();
173173 let params: Vec<&Value> = op["parameters"]
174174 .as_array()
175− .map(|l| l.iter().collect())
175+ .map(|l| l.iter().filter(|p| matches!(p["in"].as_str(), Some("path" | "query"))).collect())
176176 .unwrap_or_default();
177177 if params.is_empty() {
178178 writeln!(text, " params: &[],").unwrap();
247247 use super::*;
248248
249249 #[test]
250+ fn header_metadata_does_not_change_cli_operation_arguments() {
251+ let mut doc = generate::openapi();
252+ let with_headers = generate::table(&doc);
253+ for item in doc["paths"].as_object_mut().unwrap().values_mut() {
254+ for operation in item.as_object_mut().unwrap().values_mut() {
255+ if let Some(parameters) = operation["parameters"].as_array_mut() {
256+ parameters.retain(|p| matches!(p["in"].as_str(), Some("path" | "query")));
257+ }
258+ }
259+ }
260+ assert_eq!(with_headers, generate::table(&doc));
261+ }
262+
263+ #[test]
250264 fn ops_table_is_current() {
251265 let doc = generate::openapi();
252266 let want = generate::table(&doc);

Comments

Sign in to comment.