spikard-codegen 0.15.6-rc.4

Code generation utilities for Spikard
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
#![allow(
    clippy::missing_errors_doc,
    clippy::missing_panics_doc,
    clippy::must_use_candidate,
    clippy::doc_markdown,
    clippy::too_long_first_doc_paragraph,
    clippy::module_name_repetitions,
    clippy::too_many_lines
)]
//! Spikard's HTTP annotation grammar, parsed out of scythe's `CustomAnnotation`
//! slice. Scythe captures every unknown `-- @<name> <value>` line verbatim;
//! spikard owns the vocabulary that turns those triples into route metadata.

use std::collections::BTreeMap;

use scythe_core::analyzer::AnalyzedQuery;
use scythe_core::parser::CustomAnnotation;
use scythe_core::parser::QueryCommand;
use serde::{Deserialize, Serialize};
use thiserror::Error;

/// Errors raised while parsing HTTP annotations. Each variant carries the
/// 1-based source line from the originating `CustomAnnotation` so messages can
/// point users at the offending SQL.
#[derive(Debug, Error, PartialEq, Eq)]
pub enum AnnotationParseError {
    #[error("line {line}: @http expects '<METHOD> <PATH>' (got '{value}')")]
    MalformedHttp { line: usize, value: String },

    #[error("line {line}: unknown HTTP method '{method}'")]
    UnknownMethod { line: usize, method: String },

    #[error("line {line}: duplicate @http directive (only one route per query)")]
    DuplicateHttp { line: usize },

    #[error("line {line}: @http_param expects '<name> <path|query|body|header>' (got '{value}')")]
    MalformedHttpParam { line: usize, value: String },

    #[error("line {line}: unknown @http_param binding '{binding}' (expected path/query/body/header)")]
    UnknownBinding { line: usize, binding: String },

    #[error("line {line}: @http_status expects comma-separated codes (got '{value}')")]
    MalformedHttpStatus { line: usize, value: String },

    #[error(
        "line {line}: @http_auth expects 'none', 'bearer[:<format>]', or 'api_key:<location>:<name>' (got '{value}')"
    )]
    MalformedHttpAuth { line: usize, value: String },

    #[error("line {line}: @http_auth api_key location must be header/query/cookie (got '{location}')")]
    UnknownApiKeyLocation { line: usize, location: String },

    #[error(
        "command :{command} cannot be mapped to HTTP (only :one, :opt, :many, :exec, :exec_rows, :grouped are supported)"
    )]
    IncompatibleCommand { command: String },

    #[error("command :{command} requires method {expected_methods:?} (got {actual_method})")]
    MethodCommandMismatch {
        command: String,
        expected_methods: Vec<&'static str>,
        actual_method: String,
    },
}

/// HTTP method extracted from `@http <METHOD> <PATH>`.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "UPPERCASE")]
pub enum HttpMethod {
    Get,
    Post,
    Put,
    Patch,
    Delete,
    Head,
    Options,
}

impl HttpMethod {
    pub const fn as_str(self) -> &'static str {
        match self {
            Self::Get => "GET",
            Self::Post => "POST",
            Self::Put => "PUT",
            Self::Patch => "PATCH",
            Self::Delete => "DELETE",
            Self::Head => "HEAD",
            Self::Options => "OPTIONS",
        }
    }

    fn from_str(s: &str) -> Option<Self> {
        match s.to_ascii_uppercase().as_str() {
            "GET" => Some(Self::Get),
            "POST" => Some(Self::Post),
            "PUT" => Some(Self::Put),
            "PATCH" => Some(Self::Patch),
            "DELETE" => Some(Self::Delete),
            "HEAD" => Some(Self::Head),
            "OPTIONS" => Some(Self::Options),
            _ => None,
        }
    }
}

/// Where an HTTP request parameter is sourced from.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum HttpParamBinding {
    Path,
    Query,
    Body,
    Header,
}

/// Authentication requirement attached to a route, mapping directly to
/// spikard's existing `SecuritySchemeInfo` enum (bearer-style HTTP auth or
/// API-key auth).
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
#[serde(tag = "kind", rename_all = "snake_case")]
pub enum AuthRequirement {
    None,
    Bearer {
        #[serde(skip_serializing_if = "Option::is_none")]
        format: Option<String>,
    },
    ApiKey {
        location: ApiKeyLocation,
        name: String,
    },
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum ApiKeyLocation {
    Header,
    Query,
    Cookie,
}

/// Parsed HTTP metadata for a single SQL query.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct HttpAnnotations {
    pub method: HttpMethod,
    /// Path normalized to spikard's canonical `{name}` form. Both `:id` and
    /// `{id}` are accepted in source and emitted as `{id}`.
    pub path: String,
    /// Explicit param-location overrides, keyed by parameter name. Names
    /// absent from this map fall back to inference rules (see
    /// [`bin_param_locations`](crate::sql::route)).
    pub param_bindings: BTreeMap<String, HttpParamBinding>,
    /// Name of the bundled body object when multiple body params exist.
    pub request_body_name: Option<String>,
    /// Status codes the route documents (defaults derived from the SQL
    /// `QueryCommand` when empty).
    pub status_codes: Vec<u16>,
    pub auth: Option<AuthRequirement>,
    pub tags: Vec<String>,
    pub summary: Option<String>,
    pub description: Option<String>,
}

/// Parse spikard's HTTP vocabulary out of the custom-annotation slice that
/// scythe captured. Returns `Ok(None)` when no `@http` directive is present —
/// queries without HTTP semantics co-exist in the same source tree.
pub fn parse_http_annotations(custom: &[CustomAnnotation]) -> Result<Option<HttpAnnotations>, AnnotationParseError> {
    let mut http: Option<(usize, HttpMethod, String)> = None;
    let mut param_bindings: BTreeMap<String, HttpParamBinding> = BTreeMap::new();
    let mut request_body_name: Option<String> = None;
    let mut status_codes: Vec<u16> = Vec::new();
    let mut auth: Option<AuthRequirement> = None;
    let mut tags: Vec<String> = Vec::new();
    let mut summary: Option<String> = None;
    let mut description: Option<String> = None;

    for ann in custom {
        match ann.name.as_str() {
            "http" => {
                if http.is_some() {
                    return Err(AnnotationParseError::DuplicateHttp { line: ann.line });
                }
                let (method_raw, path_raw) =
                    ann.value
                        .split_once(char::is_whitespace)
                        .ok_or_else(|| AnnotationParseError::MalformedHttp {
                            line: ann.line,
                            value: ann.value.clone(),
                        })?;
                let method = HttpMethod::from_str(method_raw).ok_or_else(|| AnnotationParseError::UnknownMethod {
                    line: ann.line,
                    method: method_raw.to_string(),
                })?;
                let path = normalize_path(path_raw.trim());
                if path.is_empty() {
                    return Err(AnnotationParseError::MalformedHttp {
                        line: ann.line,
                        value: ann.value.clone(),
                    });
                }
                http = Some((ann.line, method, path));
            }
            "http_param" => {
                let (name, binding_raw) = ann.value.split_once(char::is_whitespace).ok_or_else(|| {
                    AnnotationParseError::MalformedHttpParam {
                        line: ann.line,
                        value: ann.value.clone(),
                    }
                })?;
                let binding =
                    parse_binding(binding_raw.trim()).ok_or_else(|| AnnotationParseError::UnknownBinding {
                        line: ann.line,
                        binding: binding_raw.trim().to_string(),
                    })?;
                param_bindings.insert(name.trim().to_string(), binding);
            }
            "http_request_body" => {
                let trimmed = ann.value.trim();
                if !trimmed.is_empty() {
                    request_body_name = Some(trimmed.to_string());
                }
            }
            "http_status" => {
                for code_raw in ann.value.split(',') {
                    let trimmed = code_raw.trim();
                    if trimmed.is_empty() {
                        continue;
                    }
                    let code = trimmed
                        .parse::<u16>()
                        .map_err(|_| AnnotationParseError::MalformedHttpStatus {
                            line: ann.line,
                            value: ann.value.clone(),
                        })?;
                    status_codes.push(code);
                }
            }
            "http_auth" => {
                auth = Some(parse_auth(&ann.value, ann.line)?);
            }
            "http_tags" => {
                for tag in ann.value.split(',') {
                    let trimmed = tag.trim();
                    if !trimmed.is_empty() {
                        tags.push(trimmed.to_string());
                    }
                }
            }
            "http_summary" => {
                summary = Some(ann.value.trim().to_string()).filter(|s| !s.is_empty());
            }
            "http_description" => {
                description = Some(ann.value.trim().to_string()).filter(|s| !s.is_empty());
            }
            // Annotations spikard doesn't recognise are ignored here — they
            // belong to some other consumer layered on top of scythe.
            _ => {}
        }
    }

    let Some((_, method, path)) = http else {
        return Ok(None);
    };

    Ok(Some(HttpAnnotations {
        method,
        path,
        param_bindings,
        request_body_name,
        status_codes,
        auth,
        tags,
        summary,
        description,
    }))
}

/// Validate that the HTTP method declared on a query is compatible with the
/// scythe `QueryCommand`, and return the default status code for the (command,
/// method) pair when [`HttpAnnotations::status_codes`] is empty.
pub fn default_status_for(command: &QueryCommand, method: HttpMethod) -> Result<u16, AnnotationParseError> {
    let (allowed, default): (&[HttpMethod], u16) = match command {
        QueryCommand::One | QueryCommand::Opt | QueryCommand::Many | QueryCommand::Grouped => (&[HttpMethod::Get], 200),
        QueryCommand::Exec => (
            &[HttpMethod::Post, HttpMethod::Put, HttpMethod::Patch, HttpMethod::Delete],
            204,
        ),
        QueryCommand::ExecRows => (
            &[HttpMethod::Post, HttpMethod::Put, HttpMethod::Patch, HttpMethod::Delete],
            200,
        ),
        QueryCommand::ExecResult | QueryCommand::Batch => {
            return Err(AnnotationParseError::IncompatibleCommand {
                command: command.to_string(),
            });
        }
    };

    if !allowed.contains(&method) {
        return Err(AnnotationParseError::MethodCommandMismatch {
            command: command.to_string(),
            expected_methods: allowed.iter().map(|m| m.as_str()).collect(),
            actual_method: method.as_str().to_string(),
        });
    }
    Ok(default)
}

/// Convenience: parse the HTTP annotations on an `AnalyzedQuery` AND validate
/// the command/method combination in one call. Returns `Ok(None)` when the
/// query has no `@http` directive.
pub fn parse_for_query(query: &AnalyzedQuery) -> Result<Option<(HttpAnnotations, u16)>, AnnotationParseError> {
    let Some(http) = parse_http_annotations(&query.custom)? else {
        return Ok(None);
    };
    let default_status = default_status_for(&query.command, http.method)?;
    Ok(Some((http, default_status)))
}

fn parse_binding(s: &str) -> Option<HttpParamBinding> {
    match s.to_ascii_lowercase().as_str() {
        "path" => Some(HttpParamBinding::Path),
        "query" => Some(HttpParamBinding::Query),
        "body" => Some(HttpParamBinding::Body),
        "header" => Some(HttpParamBinding::Header),
        _ => None,
    }
}

fn parse_auth(value: &str, line: usize) -> Result<AuthRequirement, AnnotationParseError> {
    let trimmed = value.trim();
    if trimmed.eq_ignore_ascii_case("none") {
        return Ok(AuthRequirement::None);
    }
    if let Some(rest) = trimmed
        .strip_prefix("bearer")
        .or_else(|| trimmed.strip_prefix("Bearer"))
    {
        let rest = rest.trim();
        if rest.is_empty() {
            return Ok(AuthRequirement::Bearer { format: None });
        }
        if let Some(format) = rest.strip_prefix(':') {
            let format = format.trim();
            if format.is_empty() {
                return Ok(AuthRequirement::Bearer { format: None });
            }
            return Ok(AuthRequirement::Bearer {
                format: Some(format.to_string()),
            });
        }
        return Err(AnnotationParseError::MalformedHttpAuth {
            line,
            value: value.to_string(),
        });
    }
    if let Some(rest) = trimmed
        .strip_prefix("api_key")
        .or_else(|| trimmed.strip_prefix("apikey"))
    {
        let rest = rest
            .strip_prefix(':')
            .ok_or_else(|| AnnotationParseError::MalformedHttpAuth {
                line,
                value: value.to_string(),
            })?;
        let (location_raw, name) = rest
            .split_once(':')
            .ok_or_else(|| AnnotationParseError::MalformedHttpAuth {
                line,
                value: value.to_string(),
            })?;
        let location = match location_raw.trim().to_ascii_lowercase().as_str() {
            "header" => ApiKeyLocation::Header,
            "query" => ApiKeyLocation::Query,
            "cookie" => ApiKeyLocation::Cookie,
            other => {
                return Err(AnnotationParseError::UnknownApiKeyLocation {
                    line,
                    location: other.to_string(),
                });
            }
        };
        return Ok(AuthRequirement::ApiKey {
            location,
            name: name.trim().to_string(),
        });
    }
    Err(AnnotationParseError::MalformedHttpAuth {
        line,
        value: value.to_string(),
    })
}

/// Normalize an `@http` path so colon-prefixed placeholders (`:id`) become the
/// brace-wrapped form (`{id}`) that spikard uses canonically. The brace form
/// passes through unchanged.
fn normalize_path(raw: &str) -> String {
    let mut out = String::with_capacity(raw.len());
    let bytes = raw.as_bytes();
    let mut i = 0;
    while i < bytes.len() {
        let b = bytes[i];
        if b == b':' && i + 1 < bytes.len() && is_ident_start(bytes[i + 1]) {
            out.push('{');
            i += 1;
            while i < bytes.len() && is_ident_continue(bytes[i]) {
                out.push(bytes[i] as char);
                i += 1;
            }
            out.push('}');
        } else {
            out.push(b as char);
            i += 1;
        }
    }
    out
}

const fn is_ident_start(b: u8) -> bool {
    b.is_ascii_alphabetic() || b == b'_'
}

const fn is_ident_continue(b: u8) -> bool {
    b.is_ascii_alphanumeric() || b == b'_'
}

#[cfg(test)]
mod tests {
    use super::*;
    use scythe_core::parser::CustomAnnotation;

    fn ann(name: &str, value: &str, line: usize) -> CustomAnnotation {
        CustomAnnotation {
            name: name.to_string(),
            value: value.to_string(),
            line,
        }
    }

    #[test]
    fn returns_none_when_no_http_directive() {
        let custom = vec![ann("http_auth", "bearer", 1)];
        assert_eq!(parse_http_annotations(&custom).unwrap(), None);
    }

    #[test]
    fn parses_basic_get_route() {
        let custom = vec![ann("http", "GET /users/{id}", 3)];
        let h = parse_http_annotations(&custom).unwrap().unwrap();
        assert_eq!(h.method, HttpMethod::Get);
        assert_eq!(h.path, "/users/{id}");
    }

    #[test]
    fn normalizes_colon_placeholders_to_braces() {
        let custom = vec![ann("http", "GET /users/:id/orders/:order_id", 1)];
        let h = parse_http_annotations(&custom).unwrap().unwrap();
        assert_eq!(h.path, "/users/{id}/orders/{order_id}");
    }

    #[test]
    fn leaves_brace_placeholders_unchanged() {
        let custom = vec![ann("http", "GET /users/{id}/orders/{order_id}", 1)];
        let h = parse_http_annotations(&custom).unwrap().unwrap();
        assert_eq!(h.path, "/users/{id}/orders/{order_id}");
    }

    #[test]
    fn rejects_duplicate_http_directives() {
        let custom = vec![ann("http", "GET /a", 1), ann("http", "GET /b", 2)];
        assert!(matches!(
            parse_http_annotations(&custom).unwrap_err(),
            AnnotationParseError::DuplicateHttp { line: 2 }
        ));
    }

    #[test]
    fn rejects_unknown_method() {
        let custom = vec![ann("http", "FETCH /users", 4)];
        assert!(matches!(
            parse_http_annotations(&custom).unwrap_err(),
            AnnotationParseError::UnknownMethod { line: 4, .. }
        ));
    }

    #[test]
    fn parses_param_bindings() {
        let custom = vec![
            ann("http", "POST /users", 1),
            ann("http_param", "id path", 2),
            ann("http_param", "email body", 3),
            ann("http_param", "limit query", 4),
        ];
        let h = parse_http_annotations(&custom).unwrap().unwrap();
        assert_eq!(h.param_bindings.get("id"), Some(&HttpParamBinding::Path));
        assert_eq!(h.param_bindings.get("email"), Some(&HttpParamBinding::Body));
        assert_eq!(h.param_bindings.get("limit"), Some(&HttpParamBinding::Query));
    }

    #[test]
    fn rejects_unknown_binding() {
        let custom = vec![ann("http", "POST /x", 1), ann("http_param", "id foo", 5)];
        assert!(matches!(
            parse_http_annotations(&custom).unwrap_err(),
            AnnotationParseError::UnknownBinding { line: 5, .. }
        ));
    }

    #[test]
    fn parses_status_codes() {
        let custom = vec![ann("http", "GET /a", 1), ann("http_status", "200, 404", 2)];
        let h = parse_http_annotations(&custom).unwrap().unwrap();
        assert_eq!(h.status_codes, vec![200, 404]);
    }

    #[test]
    fn parses_bearer_auth() {
        let custom = vec![ann("http", "GET /a", 1), ann("http_auth", "bearer", 2)];
        let h = parse_http_annotations(&custom).unwrap().unwrap();
        assert_eq!(h.auth, Some(AuthRequirement::Bearer { format: None }));
    }

    #[test]
    fn parses_bearer_with_format() {
        let custom = vec![ann("http", "GET /a", 1), ann("http_auth", "bearer:jwt", 2)];
        let h = parse_http_annotations(&custom).unwrap().unwrap();
        assert_eq!(
            h.auth,
            Some(AuthRequirement::Bearer {
                format: Some("jwt".to_string()),
            })
        );
    }

    #[test]
    fn parses_api_key_auth() {
        let custom = vec![
            ann("http", "GET /a", 1),
            ann("http_auth", "api_key:header:X-API-Key", 2),
        ];
        let h = parse_http_annotations(&custom).unwrap().unwrap();
        assert_eq!(
            h.auth,
            Some(AuthRequirement::ApiKey {
                location: ApiKeyLocation::Header,
                name: "X-API-Key".to_string(),
            })
        );
    }

    #[test]
    fn parses_none_auth() {
        let custom = vec![ann("http", "GET /a", 1), ann("http_auth", "none", 2)];
        let h = parse_http_annotations(&custom).unwrap().unwrap();
        assert_eq!(h.auth, Some(AuthRequirement::None));
    }

    #[test]
    fn rejects_unknown_auth_scheme() {
        let custom = vec![ann("http", "GET /a", 1), ann("http_auth", "oauth2:scopes", 7)];
        assert!(matches!(
            parse_http_annotations(&custom).unwrap_err(),
            AnnotationParseError::MalformedHttpAuth { line: 7, .. }
        ));
    }

    #[test]
    fn parses_tags_and_summary() {
        let custom = vec![
            ann("http", "GET /a", 1),
            ann("http_tags", "users, admin ", 2),
            ann("http_summary", "List users", 3),
            ann("http_description", "Returns every user", 4),
        ];
        let h = parse_http_annotations(&custom).unwrap().unwrap();
        assert_eq!(h.tags, vec!["users", "admin"]);
        assert_eq!(h.summary.as_deref(), Some("List users"));
        assert_eq!(h.description.as_deref(), Some("Returns every user"));
    }

    #[test]
    fn ignores_unrelated_annotations() {
        let custom = vec![
            ann("http", "GET /a", 1),
            ann("gql_field", "user.email", 2),
            ann("queue", "background", 3),
        ];
        let h = parse_http_annotations(&custom).unwrap().unwrap();
        assert_eq!(h.method, HttpMethod::Get);
    }

    #[test]
    fn default_status_one_get() {
        assert_eq!(default_status_for(&QueryCommand::One, HttpMethod::Get).unwrap(), 200);
    }

    #[test]
    fn default_status_exec_post() {
        assert_eq!(default_status_for(&QueryCommand::Exec, HttpMethod::Post).unwrap(), 204);
    }

    #[test]
    fn default_status_exec_rows_put() {
        assert_eq!(
            default_status_for(&QueryCommand::ExecRows, HttpMethod::Put).unwrap(),
            200
        );
    }

    #[test]
    fn rejects_batch_command() {
        assert!(matches!(
            default_status_for(&QueryCommand::Batch, HttpMethod::Get),
            Err(AnnotationParseError::IncompatibleCommand { .. })
        ));
    }

    #[test]
    fn rejects_exec_result_command() {
        assert!(matches!(
            default_status_for(&QueryCommand::ExecResult, HttpMethod::Post),
            Err(AnnotationParseError::IncompatibleCommand { .. })
        ));
    }

    #[test]
    fn rejects_one_with_post() {
        assert!(matches!(
            default_status_for(&QueryCommand::One, HttpMethod::Post),
            Err(AnnotationParseError::MethodCommandMismatch { .. })
        ));
    }

    #[test]
    fn rejects_exec_with_get() {
        assert!(matches!(
            default_status_for(&QueryCommand::Exec, HttpMethod::Get),
            Err(AnnotationParseError::MethodCommandMismatch { .. })
        ));
    }
}