feat: add multipart/form-data support for file uploads#4
Open
fdarian wants to merge 2 commits intoDokploy:mainfrom
Open
feat: add multipart/form-data support for file uploads#4fdarian wants to merge 2 commits intoDokploy:mainfrom
fdarian wants to merge 2 commits intoDokploy:mainfrom
Conversation
- Add detection utilities for zod-form-data schemas (instanceofZodFormDataFile, schemaContainsFileField) - Add safe optionality check to avoid triggering zfd preprocessing - Auto-detect multipart/form-data when file fields present - Generate proper OpenAPI schema with type: string, format: binary for files - Add multipart/form-data to OpenApiContentType - Add comprehensive tests for file upload scenarios - Fix jest config to run tests (disable diagnostics for pre-existing TS errors) - Add zod-form-data@2 as devDependency for testing
9d285da to
d95a785
Compare
Author
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.
Resolves #3
Summary
zod-form-datafile fields and set content type tomultipart/form-data{ type: "string", format: "binary" }OpenAPI schema for file fieldsChanges
src/utils/zod.tsisSchemaOptional()— Checks optionality without triggering zfd preprocessing (which callssafeParseinternally)instanceofZodFormDataFile()— Detectszfd.file()schemas by matching thepipe(transform -> custom)pattern in Zod v4 (with Zod v3ZodEffectsfallback)schemaContainsFileField()— Checks if an object schema contains any file fieldssrc/generator/schema.tsgenerateFormDataSchema()— Replaces file fields withz.string().meta({ format: 'binary' })so zod-openapi generates the correct binary formatgetRequestBodyObject()— Auto-detects multipart/form-data when file fields are presentsrc/generator/paths.tssafeParse(undefined)withisSchemaOptional()to avoid triggering zfd preprocessingsrc/types.ts'multipart/form-data'toOpenApiContentTypeTest plan
zfd.formData()withzfd.file()fieldsapplication/json