-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Context
Following up on #1 — I ran openapi2cli against the Gorgias REST API (111 endpoints, 223 schemas) and found additional systematic generator bugs beyond the Calendly ones.
Spec: Gorgias OpenAPI 3.0.3 (downgraded from 3.1.0 for compatibility)
Environment: openapi2cli 1.0.0, Python 3.12, NixOS
Bugs Found
1. Path parameter name mangling (P1)
Multi-word path params like {customer_id} get their underscores stripped when assigned:
# Generated (broken):
path_params["customerid"] = customer_id
# Expected:
path_params["customer_id"] = customer_idmake_request() does exact {placeholder} matching, so customerid never matches {customer_id}. 20+ nested resource endpoints broken (customers/*/custom-fields, tickets/*/messages, etc).
2. Query parameter kebab-casing (P1)
Same issue as #1 but for query params — underscored API params (order_by, customer_id, created_datetime) get hyphenated in the generated code:
# Generated (broken):
query_params["order-by"] = order_by
# Expected:
query_params["order_by"] = order_by46 occurrences in Gorgias CLI. Confirmed by live API test: underscored params → 200, hyphenated → 400.
3. Non-path fields routed to path_params (P2)
Body fields like external_id, integration_id, app_id are incorrectly placed in path_params when the field name contains id. The heuristic seems to be "if name contains 'id', put in path_params" but should check against actual URL placeholders.
Affected: external_id in customer/ticket/macro updates, integration_id and app_id in widget updates, message_id in ticket message creates, source_tags_ids in tag merges.
4. --data overwrites individually-set body fields (P2)
# Generated (clobbers --query and --type):
if query is not None:
body_data["query"] = query
if type is not None:
body_data["type"] = type
if data is not None:
body_data = json.loads(data) # ← overwrites above
# Expected:
body_data.update(json.loads(data)) # ← merges52 occurrences in Gorgias CLI.
5. Multipart upload endpoints get JSON serialization (P1)
Endpoints with multipart/form-data content type (e.g. /api/upload) are generated with the same json_data=body_data pattern as JSON endpoints. make_request() has no files parameter support.
6. Binary download responses decoded as text (P2)
make_request() falls back to response.text for non-JSON responses, which corrupts binary payloads from file download endpoints.
7. Query vs body parameter routing for non-GET methods (P2)
Some POST/PUT endpoints have both query params and request body (e.g. PUT /api/customers/merge has source_id and target_id as query params). The generator routes everything to body_data, ignoring the in: query spec field.
Impact
For the Gorgias spec, these bugs made ~50% of generated commands non-functional out of the box. I wrote post-processing fixes but the bugs should be fixed in the generator.
Suggested Fix Approach
- Path/query param naming: Use the exact
namefrom the OpenAPI spec, don't transform case - Parameter routing: Use
in: path|query|bodyfrom the spec, not name heuristics --datapattern: Use.update()instead of=- Content type awareness: Check
requestBody.contentformultipart/form-dataand generatefiles=support - Binary mode: Add a
binaryflag for endpoints that return non-JSON content types
Happy to contribute a PR if helpful. These are the same class of issues as #1 but confirmed across a much larger spec surface.