AspNetCoreOData icon indicating copy to clipboard operation
AspNetCoreOData copied to clipboard

Visual Studio Connected Services don't work with OpenAPI generated with ASP.NET Core OData

Open vladimirlashko opened this issue 3 years ago • 4 comments
trafficstars

Assemblies affected ASP.NET Core OData 8.x

Describe the bug The client code generated with the Visual Studio Connected Services cannot be build due to errors with /$count segment

Reproduce steps You can reproduce it on your ODataRoutingSample:

  1. Launch it.
  2. Create Console application in the other instance of Visual Studio.
  3. On the created project: Add -> Connected Service -> Add a service reference -> Open API
  4. Specify http://localhost:64771/swagger/v1/swagger.json as an URL
  5. Click Finish
  6. Try to build the application

You will get a lot of build errors. The problem is in the $count sergment which produces $ in the function names (e.g. V1_Companies_$countAsync())

vladimirlashko avatar Apr 29 '22 11:04 vladimirlashko

~/Customers ~/Customers/$count are the correct url in OData. We should check $ is correct symbol in Open API?

xuzhg avatar May 03 '22 16:05 xuzhg

@vladimirlashko I test it. It seems the Open API Connect Service generates the proxy classes directly using the path item string.

So, There are some problems:

  1. /$count, $ref $metadata, $batch are OData key segments, but it can't be used to generate the C# method name.
  2. We have a lot of path templates, for example, the key template {key} or function parameter template, for example, param={param}, the code generated can't handle them correctly.

So, Can you file or transfer this to the connect service open API repo?

xuzhg avatar May 03 '22 18:05 xuzhg

Thank you for the detailed answer. My colleague have made the following NSwag issue - https://github.com/RicoSuter/NSwag/issues/3976 Did you mean this repo? Or we should find VS Connected Services repo?

vladimirlashko avatar May 10 '22 06:05 vladimirlashko

Or we should find VS Connected Services repo?

If you find that, let us know @vladimirlashko .... I don't think such repo exists. I have a few requests to make to them myself if it does however 😅

julealgon avatar May 10 '22 13:05 julealgon