Honor contentType on file-type FormParams in curl codegen#816
Open
CrypticCortex wants to merge 1 commit intopostmanlabs:developfrom
Open
Honor contentType on file-type FormParams in curl codegen#816CrypticCortex wants to merge 1 commit intopostmanlabs:developfrom
CrypticCortex wants to merge 1 commit intopostmanlabs:developfrom
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #815
The curl codegen threads
contentTypethrough preprocessing fortype === 'file'FormParams (aroundcodegens/curl/lib/index.js:107), but snippet generation only applied the;type=<ct>suffix in the text-type branch. File-typeform parts always rendered without
;type=, even whencontentTypewas 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.contentTypesupport formultipart/form-dataparts. That PR threadscontentTypeonto eachsdk.FormParamper the OAS spec — for textparts 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.jsmirrors the existing text-type contentType test but withtype: 'file'. Full curl suite green (50 → 51 passing). Lint clean on changed files.