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 endpoint [FromForm] decorated argument is missing from signature #222

Open
fearef opened this issue Nov 20, 2023 · 1 comment
Open
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@fearef
Copy link

fearef commented Nov 20, 2023

Describe the bug
I have a receiving API endpoint with following signature:

[HttpPost("[action]/{bucketName}/{directory}", Name = nameof(UploadFileAsync))]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
public async Task<IActionResult> UploadFileAsync(string bucketName,
	[FromRoute] string directory,
	[FromForm] UploadFileArgs uploadFileArgs,
	IFormFile file,
	CancellationToken cancellationToken)

using refitter CLI i get the following contract generated for the controller:

 /// <summary>
 /// Returns information about file
 /// </summary>
 [System.CodeDom.Compiler.GeneratedCode("Refitter", "0.7.5.0")]
 public interface IFileApi
 {
     [Headers("Accept: application/json")]
     [Get("/v1/File/GetFileInfo/{bucketName}/{objectName}")]
     Task<FileInfo> GetFileInfoAsync(string bucketName, string objectName, CancellationToken cancellationToken = default);

     [Headers("Accept: application/octet-stream")]
     [Get("/v1/File/DownloadFile/{bucketName}/{objectName}")]
     Task DownloadFileAsync(string bucketName, string objectName, [Query] string versionId, CancellationToken cancellationToken = default);

     [Multipart]
     [Headers("Accept: application/json")]
     [Post("/v1/File/UploadFile/{bucketName}/{directory}")]
     Task UploadFileAsync(string bucketName, string directory, StreamPart file, CancellationToken cancellationToken = default);

     [Headers("Accept: application/json")]
     [Post("/v1/File/CopyFile/{fromBucketName}/{filePath}/{toDirectory}")]
     Task CopyFileAsync(string fromBucketName, string filePath, string toDirectory, [Query] string toBucketName, CancellationToken cancellationToken = default);

     [Headers("Accept: application/json")]
     [Post("/v1/File/MoveFile/{fromBucketName}/{fromFilePath}/{toFilePath}")]
     Task MoveFileAsync(string fromBucketName, string fromFilePath, string toFilePath, [Query] string toBucketName, CancellationToken cancellationToken = default);

     [Delete("/v1/File/DeleteFile/{bucketName}/{filePath}")]
     Task DeleteFileAsync(string bucketName, string filePath, CancellationToken cancellationToken = default);
 }

The endpoint in question is missing the long[] OrganizationalUnitIds which is a single property of the [FromForm] UploadFileArgs uploadFileArgs argument in the receiving endpoint. In line 545 of openApi spec the request body is defined as follows:

"requestBody": {
                    "content": {
                        "multipart/form-data": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "OrganizationalUnitIds": {
                                        "type": "array",
                                        "items": {
                                            "type": "integer",
                                            "format": "int64"
                                        }
                                    },
                                    "file": {
                                        "type": "string",
                                        "format": "binary"
                                    }
                                }
                            },
                            "encoding": {
                                "OrganizationalUnitIds": {
                                    "style": "form"
                                },
                                "file": {
                                    "style": "form"
                                }
                            }
                        }
                    }
                }

Support Key: [h/tnek2]
The support key is a unique identifier generated on the machine which is used when logging telemetry data. This feature is introduced in v0.5.4 and is shown in the output when running Refitter.

openapispec.json

@fearef fearef added the bug Something isn't working label Nov 20, 2023
@christianhelle
Copy link
Owner

@fearef Thanks for taking the time to report this. I'll look into it and see what I can do

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants