()
| 2304 | |
| 2305 | #[test] |
| 2306 | fn validate_querystring_parameter_must_be_json() -> Result<(), Box<dyn std::error::Error>> { |
| 2307 | use openapi_rs::model::parse::OpenAPI; |
| 2308 | use openapi_rs::validator::query; |
| 2309 | use std::collections::HashMap; |
| 2310 | |
| 2311 | let content = r#" |
| 2312 | openapi: 3.2.0 |
| 2313 | info: |
| 2314 | title: Test API |
| 2315 | version: '1.0.0' |
| 2316 | paths: |
| 2317 | /search: |
| 2318 | get: |
| 2319 | parameters: |
| 2320 | - name: filter |
| 2321 | in: querystring |
| 2322 | content: |
| 2323 | application/json: |
| 2324 | schema: |
| 2325 | type: object |
| 2326 | responses: |
| 2327 | '200': |
| 2328 | description: OK |
| 2329 | "#; |
| 2330 | |
| 2331 | let openapi: OpenAPI = OpenAPI::yaml(content)?; |
| 2332 | |
| 2333 | // Valid JSON should pass |
| 2334 | let mut query_params = HashMap::new(); |
| 2335 | query_params.insert("filter".to_string(), r#"{"status":"active"}"#.to_string()); |
| 2336 | assert!(query("/search", &query_params, &openapi).is_ok()); |
| 2337 | |
| 2338 | // Invalid JSON should fail |
| 2339 | query_params.insert("filter".to_string(), "invalid-json".to_string()); |
| 2340 | assert!(query("/search", &query_params, &openapi).is_err()); |
| 2341 | |
| 2342 | Ok(()) |
| 2343 | } |
| 2344 | } |
nothing calls this directly
no outgoing calls
no test coverage detected