Swagger annotation for file parameter?

Yeah that would be tricky. If the property doesn’t exist the only way to add it to the Swagger metadata is with a filter, e.g:

Plugins.Add(new SwaggerFeature
{
    OperationFilter = op => {
        if (op.Nickname == typeof(UploadFile).Name && op.Method == HttpMethods.Post)
        {
            op.Parameters.Add(new SwaggerParameter {
                Name = "upload",
                ParamType = "body",
                Type = "file"
            });
        }
    },
});

Note: OperationFilter was added in the latest v4.0.54 release

1 Like