Forum Discussion

ctardivo's avatar
ctardivo
New Member
6 years ago

RequestBody content media type not validating image extension

Hi,

I am building a ReSTful API using Python 3.5, Flask, Connexion and Swagger 3.0.

Writing the .yml swagger file I declared a POST method that accept an image with this code:

paths:
/myfunction:
post:
requestBody:
content:
image/png:
schema:
type: string
format: binary

 

What I expected using this code is to have a sort of input validation for the input file. However it seems that it works perfectly even with JPG and SVG files.

 

What are the main differences (if any) between

image/*

and

image/png

??

For sure I can implement a validation of the input file extension in the Python/Flask layer, however is it possible to enable this validation with the swagger specification?

  • Hi there! It looks like this question is more specific to Connexion's interpretation of the media type described. As Connexion is not one of our tools, we'd recommend filing a ticket in their repo.