Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multipart/form-data #229

Open
Stono opened this issue Oct 10, 2024 · 0 comments
Open

multipart/form-data #229

Stono opened this issue Oct 10, 2024 · 0 comments

Comments

@Stono
Copy link

Stono commented Oct 10, 2024

Hi,
This is an extension of the closed question: #69

I'm trying to migrate away from the nestjs swagger annotations to using zod instead, which on the whole is working - apart from multipart-form.

So previously I had:

export class ImageClassificationRequest {
  @ApiProperty({
    enum: availableClassificationModels,
    type: String,
    description: 'The model to use for image classification'
  })
  
  public model!: KnownImageClassificationModel
  @ApiProperty({
    type: 'string',
    format: 'binary'
  })
  public image!: string
}

In swagger I get a file input:

Screenshot 2024-10-10 at 13 16 42

However if i try and use binary format string with zod:

const binarySchema = extendApi(z.string(), {
  format: 'binary'
})

export class ImageClassificationRequest extends createZodDto(
  z.strictObject({
    model: classificationModelsZodType.describe(
      'The model to use for image classification'
    ),
    image: binarySchema.describe('The image to classify')
  })
) {}

Swagger just becomes a string:

Screenshot 2024-10-10 at 13 17 45

Any help would be appreciated!

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

No branches or pull requests

1 participant