What every call is held to: the pinned OpenAPI document (crate::world::contract), and the operations
the vendor's own SDKs call that the document does not have, each with the answers its sources name.
One operation so far: DELETE /v1/sprites/{name}/services/{service_name}. sprites-go (services.go,
DeleteService), sprites-js (src/services.ts, deleteService) and sprites-py (services.py,
delete_service) send it, and read 204 as done, 404 as "not found" and 409 as a conflict; the services
page (docs.fly.io/sprites/concepts/services.md, primary) says "delete removes the definition, not the logs".
The OpenAPI file (0.1.12) and the docs site's API reference list no such operation (retrieved 2026-10-22).
Anything else on that path is still a finding, as is any other operation the document lacks.
16const SERVICE_DELETE: &str = "/v1/sprites/{name}/services/{service_name}";
The answers the SDKs read for it (401 and 429 are any operation's).
18const SERVICE_DELETE_STATUSES: [u16; 5] = [204, 401, 404, 409, 429];
Whether this is the service delete, which only the SDKs know.
36fn finding(side: Side, message: String) -> Finding { 37 Finding { side, message } 38} 39 40fn service_delete_findings(response: Option<&Response>) -> Vec<Finding> { 41 let Some(r) = response else { return Vec::new() }; 42 let status = r.status().as_u16(); 43 if !SERVICE_DELETE_STATUSES.contains(&status) { 44 return vec![finding(Side::Response, format!("answers {status}, which the SDKs do not read for a service's DELETE (204, 404, 409)"))]; 45 } 46 if status == 204 && !r.body().is_empty() { 47 return vec![finding(Side::Response, "answers 204 with a body".to_string())]; 48 } 49 Vec::new() 50} 51 52impl Checker for Documented { 53 fn operation(&self, method: &Method, path: &str) -> Option<OperationRef> { 54 self.contract 55 .operation(method, path) 56 .or_else(|| is_service_delete(method, path).then(|| OperationRef { method: method.to_string(), template: SERVICE_DELETE.to_string(), id: None })) 57 } 58 59 fn check(&self, request: &Request, response: &Response) -> Vec<Finding> { 60 if is_service_delete(request.method(), request.uri().path()) { 61 return service_delete_findings(Some(response)); 62 } 63 self.contract.check(request, response) 64 } 65 66 fn check_request(&self, request: &Request) -> Vec<Finding> { 67 if is_service_delete(request.method(), request.uri().path()) { 68 return service_delete_findings(None); 69 } 70 self.contract.check_request(request) 71 } 72} 73 74#[cfg(test)] 75mod tests { 76 use super::*; 77 use cloud_mock::reply::{empty_response, json_response}; 78 use serde_json::json; 79 80 fn delete(path: &str) -> Request { 81 http::Request::builder().method("DELETE").uri(path).body(Vec::new()).unwrap() 82 } 83 84 #[test] 85 fn the_service_delete_is_known_with_the_sdks_statuses_only() { 86 let c = Documented::new(crate::world::contract()); 87 let req = delete("/v1/sprites/dev/services/web"); 88 assert_eq!(c.operation(req.method(), req.uri().path()).unwrap().template, SERVICE_DELETE); 89 assert!(c.check(&req, &empty_response(204)).is_empty()); 90 assert!(c.check(&req, &json_response(404, &json!({ "error": "not_found" }))).is_empty()); 91 assert_eq!(c.check(&req, &empty_response(200)).len(), 1); 92 assert_eq!(c.check(&req, &json_response(204, &json!({}))).len(), 1); 93 } 94 95 #[test] 96 fn other_operations_the_document_lacks_are_still_findings() { 97 let c = Documented::new(crate::world::contract()); 98 let req = delete("/v1/sprites/dev/services"); 99 assert!(c.operation(req.method(), req.uri().path()).is_none()); 100 assert_eq!(c.check_request(&req).len(), 1); 101 } 102}