Skip to content

Commit

Permalink
[C#ApiServer] Fix [FromQuery] manquant pour les arrays et [FromForm] …
Browse files Browse the repository at this point in the history
…en trop pour IFormFile
  • Loading branch information
JabX committed May 14, 2024
1 parent b8c0ca5 commit 785bb3a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions TopModel.Generator.Csharp/CSharpApiServerGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,22 @@ private string GetParam(IProperty param)
{
var sb = new StringBuilder();

if (param.Endpoint.IsMultipart && !param.IsQueryParam() && !param.IsRouteParam())
var type = Config.GetType(param, nonNullable: param.IsJsonBodyParam() || param.IsRouteParam() || param.IsQueryParam() && !param.Endpoint.IsMultipart && Config.GetValue(param, Classes) != "null");

if (param.Endpoint.IsMultipart && !param.IsQueryParam() && !param.IsRouteParam() && type != "IFormFile")
{
sb.Append("[FromForm] ");
}
else if (param.IsJsonBodyParam())
{
sb.Append("[FromBody] ");
}
else if (type.EndsWith("[]"))
{
sb.Append("[FromQuery] ");
}

sb.Append($@"{Config.GetType(param, nonNullable: param.IsJsonBodyParam() || param.IsRouteParam() || param.IsQueryParam() && !param.Endpoint.IsMultipart && Config.GetValue(param, Classes) != "null")} {param.GetParamName().Verbatim()}");
sb.Append($@"{type} {param.GetParamName().Verbatim()}");

if (param.IsQueryParam() && !param.Endpoint.IsMultipart)
{
Expand Down

0 comments on commit 785bb3a

Please sign in to comment.