You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I had another library that was dependent on RestSharp 106.5.4 so tried to use that version.
Trying to compile with that version of RestSharp failed with the following error
1>C:\git\sniper-regression\EbayApiRest.Order\Generated\Order\EbayApiRest.Order\Client\ApiClient.cs(137,51,137,69): error CS1503: Argument 2: cannot convert from 'System.Action<System.IO.Stream>' to 'byte[]'
The generated method that fails to compile
privateRestRequestPrepareRequest(Stringpath,RestSharp.Methodmethod,List<KeyValuePair<String,String>>queryParams,ObjectpostBody,Dictionary<String,String>headerParams,Dictionary<String,String>formParams,Dictionary<String,FileParameter>fileParams,Dictionary<String,String>pathParams,StringcontentType){varrequest=newRestRequest(path,method);// add path parameter, if anyforeach(varparaminpathParams)request.AddParameter(param.Key,param.Value,ParameterType.UrlSegment);// add header parameter, if anyforeach(varparaminheaderParams)request.AddHeader(param.Key,param.Value);// add query parameter, if anyforeach(varparaminqueryParams)request.AddQueryParameter(param.Key,param.Value);// add form parameter, if anyforeach(varparaminformParams)request.AddParameter(param.Key,param.Value);// add file parameter, if anyforeach(varparaminfileParams){request.AddFile(param.Value.Name,param.Value.Writer,param.Value.FileName,param.Value.ContentType);}if(postBody!=null)// http body (model or byte[]) parameter{request.AddParameter(contentType,postBody,ParameterType.RequestBody);}returnrequest;}
The line request.AddFile(param.Value.Name, param.Value.Writer, param.Value.FileName, param.Value.ContentType); fails to compile because in RestSharp (106.5.4) the method signature for this change.
The method signature from RestSharp that matches the closest is public IRestRequest AddFile(string name, Action<Stream> writer, string fileName, long contentLength, string contentType = null);. The generated method is just missing the contentLength paramater.
This contract does not pass validation on the command line as it appears the contract is using a reserved word (basePath) in the servers array. Though this contract does pass validation on https://apitools.dev/swagger-parser/online/#
I have an open ticket with ebay to fix their contract as I was able to edit it locally and change the variable in the servers array to foo and it passed validation and generated. Though it also appears that if you skip validation (--skip-validate-spec) the generated code is still correct.
(for JSON code), so it becomes more readable. If it is longer than about ten lines,
please create a Gist (https://gist.github.com) or upload it somewhere else and
link it here.
-->
Generate Code
Add to Visual Studio .NET Framework 4.5 project
Add packagest Newtonsoft.json (7.0.0), JsonSubTypes (1.2.0), and RestSharp (106.5.4)
Build in visual studio
The text was updated successfully, but these errors were encountered:
So I am just seeing that in the generated README.md you call out an issue with versions of RestSharp greater than 105.1.0 and point to this issue restsharp/RestSharp#742. That issue is now closed and that must be the new method signature that I am seeing in the later versions of RestSharp.
Seems that the line should be:
request.AddFile(param.Value.Name, param.Value.Writer, param.Value.FileName, param.Value.ContentLength, param.Value.ContentType);
As param.Value already have the value for ContentLength. Seems clear path to fix this one.
RestSharp dropped net45 support in version 106 so it wouldn't make sense to update the dependency in the v4.5 generator. This changed signature has already been fixed in #5870.
If you generate with targetFramework v4.5.2 you'll get a dependency on RestSharp 106 and the correct AddFile call.
csharp-netcore supports framework 4.7 as well so please give it a try with the latest master assuming you can upgrade framework to 4.7 from 4.5 or older versions in your environment.
Uh oh!
There was an error while loading. Please reload this page.
Bug Report Checklist
Description
Generated client does not compile with RestSharp verions 106.5.4.
In the generated readme I saw
I had another library that was dependent on RestSharp 106.5.4 so tried to use that version.
Trying to compile with that version of RestSharp failed with the following error
The generated method that fails to compile
The line
request.AddFile(param.Value.Name, param.Value.Writer, param.Value.FileName, param.Value.ContentType);
fails to compile because in RestSharp (106.5.4) the method signature for this change.The method signature from RestSharp that matches the closest is
public IRestRequest AddFile(string name, Action<Stream> writer, string fileName, long contentLength, string contentType = null);
. The generated method is just missing the contentLength paramater.openapi-generator version
4.3.1
OpenAPI declaration file content or url
Contract I am generating from
https://developer.ebay.com/api-docs/master/buy/order/openapi/3/buy_order_v1_beta_oas3.json
This contract does not pass validation on the command line as it appears the contract is using a reserved word (basePath) in the servers array. Though this contract does pass validation on https://apitools.dev/swagger-parser/online/#
I have an open ticket with ebay to fix their contract as I was able to edit it locally and change the variable in the servers array to
foo
and it passed validation and generated. Though it also appears that if you skip validation (--skip-validate-spec
) the generated code is still correct.(for JSON code), so it becomes more readable. If it is longer than about ten lines,
please create a Gist (https://gist.github.com) or upload it somewhere else and
link it here.
-->
Command line used for generation
open-api-codegen-cli.jar
java -DapiTests=false -DmodelTests=false -jar .\open-api-codegen-cli.jar generate -i "https://developer.ebay.com/api-docs/master/buy/order/openapi/3/buy_order_v1_beta_oas3.json" -c ".\.swagger-config.json" -g csharp -o "Generated/Orders" --package-name="EbayApiRest.Order" --ignore-file-override=".\.swagger-codegen-ignore" --skip-validation-spec
swagger-config.json
.swagger-codegen-ignore
Steps to reproduce
Generate Code
Add to Visual Studio .NET Framework 4.5 project
Add packagest Newtonsoft.json (7.0.0), JsonSubTypes (1.2.0), and RestSharp (106.5.4)
Build in visual studio
The text was updated successfully, but these errors were encountered: