swagger-typescript-api icon indicating copy to clipboard operation
swagger-typescript-api copied to clipboard

Improve implicit FormFata detection. Add tests.

Open aphofstede opened this issue 3 weeks ago • 2 comments

Avoid matching "File" type usage too broadly. Fixes https://github.com/acacode/swagger-typescript-api/issues/1538


[!NOTE] Use precise regex matching to detect actual File/binary request bodies as FormData and add tests covering custom formats and false positives.

  • Schema Routes (src/schema-routes/schema-routes.ts):
    • Refine implicit FormData detection: replace simple substring check with escaped regex that matches whole File/binary types (including arrays/unions) while avoiding false positives (e.g., FileType).
  • Tests (tests/spec/implicitFormData/):
    • Add OpenAPI schema (schema.json), test (basic.test.ts), and snapshot verifying:
      • File/binary properties trigger FormData.
      • Custom formats mapping to non-File types (e.g., FileType) do not.
      • Custom formats mapping to File do.
      • Component names containing "File" do not trigger FormData.

Written by Cursor Bugbot for commit 4a3990578536e439a2e8fbd89273fe00d0f78bdc. This will update automatically on new commits. Configure here.

aphofstede avatar Dec 02 '25 18:12 aphofstede