Skip to content

Honor contentType on file-type FormParams in curl codegen#816

Open
CrypticCortex wants to merge 1 commit intopostmanlabs:developfrom
CrypticCortex:fix/curl-codegen-file-formdata-content-type
Open

Honor contentType on file-type FormParams in curl codegen#816
CrypticCortex wants to merge 1 commit intopostmanlabs:developfrom
CrypticCortex:fix/curl-codegen-file-formdata-content-type

Conversation

@CrypticCortex
Copy link
Copy Markdown

@CrypticCortex CrypticCortex commented May 8, 2026

Closes #815

The curl codegen threads contentType through preprocessing for type === 'file' FormParams (around codegens/curl/lib/index.js:107), but snippet generation only applied the ;type=<ct> suffix in the text-type branch. File-type
form parts always rendered without ;type=, even when contentType was set.

Mirrors the same check into the file-type branch so generated snippets emit -F 'attachment=@"/path/to/file";type=image/png' when contentType is present. curl supports ;type= for file parts identically to text parts.

Context

Surfaced in PaloAltoNetworks/docusaurus-openapi-docs#1369 (merged), which adds OpenAPI encoding.contentType support for multipart/form-data parts. That PR threads contentType onto each sdk.FormParam per the OAS spec — for text
parts the snippet picks it up, for binary file parts it drops it. Their PR explicitly documents this as a "Known limitation" pending an upstream fix here. This PR is that upstream fix.

Test

Regression test in codegens/curl/test/unit/convert.test.js mirrors the existing text-type contentType test but with type: 'file'. Full curl suite green (50 → 51 passing). Lint clean on changed files.

The curl codegen correctly threaded contentType through preprocessing
for type === 'file' FormParams, but dropped it during snippet
generation. The contentType check was only applied to the text-type
branch, so file-type form parts always rendered without ;type=<ct>
even when contentType was explicitly set on the param.

Apply the same contentType check inside the file-type branch so
generated snippets emit -F 'key=@"/path/to/file";type=image/png'
when the param has contentType set. curl supports ;type= for file
parts the same way it does for text parts.

Adds a regression test mirroring the existing text-type contentType
test but with type: 'file'. Full curl suite green (51 passing).

Closes postmanlabs#815
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.

curl codegen: file-type FormParam contentType ignored — ';type=' not emitted for multipart file parts

1 participant