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

The client parameter type's names occur wrong when multipart is include. #231

Open
safakkesikci opened this issue Nov 27, 2023 · 6 comments
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@safakkesikci
Copy link

safakkesikci commented Nov 27, 2023

image

sample openapi:
animal.json

sample refitter config file:
Animal.refitter
{
"openApiPath": "./animal.json",
"namespace": "Animal",
"naming": {
"useOpenApiTitle": false
},
"multipleInterfaces": "ByTag",
"operationNameTemplate": "{operationName}Async",
"outputFolder": "../Clients",
"outputFilename": "Animal.cs",
"codeGeneratorSettings": {
"requiredPropertiesMustBeDefined": true,
"generateDataAnnotations": true,
"anyType": "object",
"dateType": "System.DateTimeOffset",
"dateTimeType": "System.DateTimeOffset",
"timeType": "System.TimeSpan",
"timeSpanType": "System.TimeSpan",
"arrayType": "System.Collections.Generic.ICollection",
"dictionaryType": "System.Collections.Generic.IDictionary",
"arrayInstanceType": "System.Collections.ObjectModel.Collection",
"dictionaryInstanceType": "System.Collections.Generic.Dictionary",
"arrayBaseType": "System.Collections.ObjectModel.Collection",
"dictionaryBaseType": "System.Collections.Generic.Dictionary",
"propertySetterAccessModifier": "",
"generateImmutableArrayProperties": false,
"generateImmutableDictionaryProperties": false,
"handleReferences": false,
"jsonSerializerSettingsTransformationMethod": null,
"generateJsonMethods": false,
"enforceFlagEnums": false,
"inlineNamedDictionaries": false,
"inlineNamedTuples": true,
"inlineNamedArrays": false,
"generateOptionalPropertiesAsNullable": false,
"generateNullableReferenceTypes": false,
"generateNativeRecords": false,
"generateDefaultValues": true,
"inlineNamedAny": false,
"excludedTypeNames": []
}
}

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

@safakkesikci thanks for taking the time to report this

I'm unfortunately not at all experienced in working with multipart/form-data in Refit or multipart/form-data requests in general

Do you know what should the HTTP request look like for this?

"requestBody": {
  "content": {
    "multipart/form-data": {
      "schema": {
        "type": "object",
        "properties": {
          "Name": {
            "type": "string"
          },
          "AnimalClassFile": {
            "type": "string",
            "format": "binary"
          },
          "AnimalCrowdFile": {
            "type": "string",
            "format": "binary"
          }
        }
      },
      "encoding": {
        "Name": {
          "style": "form"
        },
        "AnimalClassFile": {
          "style": "form"
        },
        "AnimalCrowdFile": {
          "style": "form"
        }
      }
    }
  }
}

and what should the Refit method look like?

@safakkesikci
Copy link
Author

safakkesikci commented Nov 27, 2023

Hello. When I try to generate client csharp and csharp-dotnet2 via editor.swagger.io, it occurs as follows.
ps: of course type is byte array not streampart. It may not be easy to change since there are different libraries :/

csharp-client-generated (1).zip
AnimalResponse AnimalsPost (string name = null, byte[] animalClassFile = null, byte[] animalCrowdFile = null);
{
...

csharp-dotnet2-client-generated (1).zip
public AnimalResponse AnimalsPost (string name, byte[] animalClassFile, byte[] animalCrowdFile)
{
...

@christianhelle
Copy link
Owner

@safakkesikci is this a client for an API you developed yourself? If so, if it's an ASP.NET API, what does the code look like for accepting multipart/form-data parameters?

@christianhelle
Copy link
Owner

@safakkesikci one thing is generating the Refit client, but I also want to make sure that it also works 😄

@safakkesikci
Copy link
Author

Hello, I tried to go the reverse way :) I created a helloworld webapi project and created a client from the controller with the GenerateAspNetCoreClient package using Refit and examined the document.

example project https://github.com/safakkesikci/refitclienttest
I added AnimalController and created a client with the GenerateAspNetCoreClient package.

swagger.json

I hope it's helpful.

@christianhelle
Copy link
Owner

Hello, I tried to go the reverse way :) I created a helloworld webapi project and created a client from the controller with the GenerateAspNetCoreClient package using Refit and examined the document.

example project https://github.com/safakkesikci/refitclienttest I added AnimalController and created a client with the GenerateAspNetCoreClient package.

swagger.json

I hope it's helpful.

@safakkesikci Yes this is really helpful! I'll 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