Skip to content

Fix TypeError when OpenAPI Path Item Object contains non-HTTP-verb fields#1843

Merged
pmcelhaney merged 3 commits intomainfrom
copilot/fix-typeerror-non-http-verbs
Apr 13, 2026
Merged

Fix TypeError when OpenAPI Path Item Object contains non-HTTP-verb fields#1843
pmcelhaney merged 3 commits intomainfrom
copilot/fix-typeerror-non-http-verbs

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 13, 2026

Summary

Path Item Objects that include summary, description, servers, or parameters fields (all valid per the OpenAPI spec) caused a TypeError: Cannot use 'in' operator to search for 'operationId' in <string> during code generation. The generator was blindly iterating all keys of a path item and passing each value to OperationCoder, which expects an operation object — not a string or array.

Original Prompt

Bug: Non-HTTP-Verbs (like Summary/Description) for a Path Item Object Field lead to TypeError

Using an OpenAPI spec with summary or description at the path level (e.g. paths./test.summary: "Test Summary") causes:

❌ Cannot use 'in' operator to search for 'operationId' in Test Summary

All fields in a path item are assumed to be HTTP operation objects, but the OpenAPI Path Item Object spec explicitly allows summary, description, servers, and parameters.

Manual acceptance tests

  • An OpenAPI spec with summary and description on a path item starts counterfact without a TypeError
  • Routes for the affected path (e.g. GET /test) are generated and respond correctly
  • Specs without non-HTTP-verb path fields are unaffected
  • Path-level parameters and servers fields also do not cause errors

Tasks

  • src/typescript-generator/generate.ts — Added an HTTP_VERBS set (get, put, post, delete, options, head, patch, trace) and guard in pathDefinition.forEach to skip non-verb keys:

    const HTTP_VERBS = new Set(["get", "put", "post", "delete", "options", "head", "patch", "trace"]);
    
    pathDefinition.forEach((operation, requestMethod: string) => {
      if (!HTTP_VERBS.has(requestMethod)) return;
      // ...
    });
  • test/typescript-generator/generate.test.ts — Added regression test: spec with path-level summary + description resolves without throwing and generates the expected route file

  • .changeset/fix-path-item-non-http-verb-fields.md — Patch-level changeset entry

Copilot AI changed the title [WIP] Fix TypeError for non-HTTP-verb fields in path item objects Fix TypeError when OpenAPI Path Item Object contains non-HTTP-verb fields Apr 13, 2026
Copilot AI requested a review from pmcelhaney April 13, 2026 20:50
@pmcelhaney pmcelhaney marked this pull request as ready for review April 13, 2026 22:15
@pmcelhaney pmcelhaney added this pull request to the merge queue Apr 13, 2026
Merged via the queue into main with commit af406dd Apr 13, 2026
8 of 11 checks passed
@pmcelhaney pmcelhaney deleted the copilot/fix-typeerror-non-http-verbs branch April 13, 2026 22:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Non-HTTP-Verbs (like Summary/Description) for a Path Item Object Field lead to TypeError

2 participants