Open nexgus opened 1 year ago
I want to design an API, say
POST /files
. By using this API the user can upload single or multiple files. Its content type must bemultipart/form-data
. Thanks tooatpp
, it functions excellent. Now, I try to useoatpp-swagger
to describe this API.I tried to use the following code but it does not work. In more detail, compile ok but not display the GUI as my imagination :-Q.
ENDPOINT_INFO(uploadMultipart) { info->summary = "Upload one or more files."; info->addConsumes<oatpp::swagger::Binary>("multipart/form-data"); }
I expect I can see something in Swagger GUI to allow a user to upload one or more files by using
multipart/form-data
but not.So, how should I do?
First, you should define MultipartDto as below:
class MultipartDto : public oatpp::DTO {
DTO_INIT(MultipartDto, DTO)
DTO_FIELD(oatpp::swagger::Binary, file, "file");
};
then the swagger:
ENDPOINT_INFO(uploadCodeConfig) {
info->summary = "Upload and Code Generate";
info->addConsumes<Object<MultipartDto>>("multipart/form-data");
}
hope this is helpful to you
It does work!! 3q
I want to design an API, say
POST /files
. By using this API the user can upload single or multiple files. Its content type must bemultipart/form-data
. Thanks tooatpp
, it functions excellent. Now, I try to useoatpp-swagger
to describe this API.I tried to use the following code but it does not work. In more detail, compile ok but not display the GUI as my imagination :-Q.
I expect I can see something in Swagger GUI to allow a user to upload one or more files by using
multipart/form-data
but not.So, how should I do?