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

[FromForm] parameter on minimal api doesn't get generated on Interface #515

Open
EdgeLee opened this issue Oct 30, 2024 · 3 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@EdgeLee
Copy link

EdgeLee commented Oct 30, 2024

Describe the bug
Consider the following endpoint using multipart form:

public record Request(string FirstName, string LastName);

public static async Task<Results<
	Ok,
	BadRequest<Error>
>>
UpdateEmployerProfile(
	[FromForm] Request request,
	[FromForm] string test,
	[FromForm] Guid employerId,
	IFormFile image,
{
}

Generated Interface

[System.CodeDom.Compiler.GeneratedCode("Refitter", "1.4.0.0")]
public partial interface IEmployerApi
{
    [Multipart]
    [Headers("Accept: application/json")]
    [Post("/api/employer/updateemployerprofile")]
    Task<IApiResponse> UpdateEmployerProfile(StreamPart image);
}

Noticed only the image parameter is generated but not parameters with [FromForm].

Support Key: 89ljsu/

OpenAPI Specifications

"/api/employer/updateemployerprofile": {
  "post": {
    "tags": [
      "employer"
    ],
    "operationId": "UpdateEmployerProfile",
    "requestBody": {
      "content": {
        "multipart/form-data": {
          "schema": {
            "required": [
              "employerId",
              "image",
              "request",
              "test"
            ],
            "type": "object",
            "properties": {
              "request": {
                "$ref": "#/components/schemas/UpdateEmployerProfileRequest"
              },
              "test": {
                "type": "string"
              },
              "employerId": {
                "type": "string",
                "format": "uuid"
              },
              "image": {
                "type": "string",
                "format": "binary"
              }
            }
          },
          "encoding": {
            "request": {
              "style": "form"
            },
            "test": {
              "style": "form"
            },
            "employerId": {
              "style": "form"
            },
            "image": {
              "style": "form"
            }
          }
        }
      }
    },
    "responses": {
      "200": {
        "description": "OK"
      },
      "400": {
        "description": "Bad Request",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    }
  }
},

Additional context
Ive tried using [FromQuery] and it works as intended.

@EdgeLee EdgeLee added the bug Something isn't working label Oct 30, 2024
@EdgeLee
Copy link
Author

EdgeLee commented Oct 30, 2024

I've forgot to mention that I tried manually editing the generated Interface to the following:

[System.CodeDom.Compiler.GeneratedCode("Refitter", "1.4.0.0")]
public partial interface IEmployerApi
{
    [Multipart]
    [Headers("Accept: application/json")]
    [Post("/api/employer/updateemployerprofile")]
    Task<IApiResponse> UpdateEmployerProfile(string EmployerId, string FirstName, string LastName, StreamPart image);
}

And I was able to get the values on the endpoint. Its just my changes will get overridden from the code gen.

@christianhelle
Copy link
Owner

@EdgeLee Thanks for taking the time to report this. Unfortunately, I'm too busy with other things to look into this. If you find a solution yourself and create a pull request, then I will find the time to review and make sure your fix gets merged in and released. Otherwise, this will have to wait a few weeks

@EdgeLee
Copy link
Author

EdgeLee commented Nov 1, 2024

Noted sir~ its fine, I just made a custom interface that overrides the base interface for the time being.

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

No branches or pull requests

2 participants