api-platform FileUpload handler swagger_context

I would like to see an upload field in my swagger, instead it is not valid with the second annotation.

I have following Annotation for my MediaObject -> From this guide: https://api-platform.com/docs/core/file-upload/

And then I added the context as described in the issue -> https://github.com/api-platform/docs/issues/143


 *             "swagger_context"={
 *                 "description"="request accordingly: https://api-platform.com/docs/core/file-upload/#making-a-request-to-the-media_objects-endpoint",
 *                 "consumes"={
 *                      "multipart/form-data"
 *                 },
 *                 "parameters"={
 *                      {
 *                          "in"="formData",
 *                          "name"="file",
 *                          "type"="file",
 *                          "schema"={
 *                              "type"="object",
 *                              "properties"={
 *                                  "file"={
 *                                      "type"="string",
 *                                      "format"="binary"
 *                                  }
 *                              }
 *                          }
 *                      },
 *                  }
 *             },


enter image description here

Now all works fine, but now is that validation (with https://validator.swagger.io/) of my swagger.json not valid.

I always get the following error;

"messages": ["attribute paths. '/ api / media_objects' (post). [file] .schema is unexpected", "attribute definitions.File.properties is not longer of type` object` "]

Someone has an idea what is not right here, or what exactly I am doing wrong, I understand what is wrong, but if I put properties in [] brackets, there is a parsing error on the part of api platform.

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *