MCPcopy Create free account
hub / github.com/baerwang/openapi-rs / querystring_vs_regular_query_parameters

Function querystring_vs_regular_query_parameters

tests/tests.rs:1624–1692  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1622
1623 #[test]
1624 fn querystring_vs_regular_query_parameters() -> Result<(), Box<dyn std::error::Error>> {
1625 // Test that both query and querystring can coexist
1626 let content = r#"
1627openapi: 3.2.0
1628info:
1629 title: Mixed Parameter Types API
1630 version: '1.0.0'
1631paths:
1632 /search:
1633 get:
1634 summary: Search with mixed parameter types
1635 parameters:
1636 - name: format
1637 in: query
1638 description: Response format
1639 schema:
1640 type: string
1641 enum: [json, xml, csv]
1642 default: json
1643 - name: filters
1644 in: querystring
1645 description: Complex filter object
1646 required: false
1647 content:
1648 application/json:
1649 schema:
1650 type: object
1651 properties:
1652 category:
1653 type: string
1654 price_range:
1655 type: object
1656 properties:
1657 min:
1658 type: number
1659 max:
1660 type: number
1661 - name: debug
1662 in: query
1663 description: Enable debug mode
1664 schema:
1665 type: boolean
1666 default: false
1667 responses:
1668 '200':
1669 description: OK
1670 "#;
1671
1672 let openapi: OpenAPI = OpenAPI::yaml(content)?;
1673 let search_path = openapi.paths.get("/search").unwrap();
1674 let get_op = search_path.operations.get("get").unwrap();
1675
1676 let params = get_op.parameters.as_ref().unwrap();
1677 assert_eq!(params.len(), 3);
1678
1679 // First is regular query
1680 assert_eq!(params[0].name.as_ref().unwrap(), "format");
1681 assert_eq!(params[0].r#in.as_ref().unwrap(), &In::Query);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected