Azure / autorest.csharp

Extension for AutoRest (https://github.com/Azure/autorest) that generates C# code
MIT License
142 stars 165 forks source link

Generated files via autorest v3 do not match with files generated by older version of autorest #4313

Open rakshith210 opened 7 months ago

rakshith210 commented 7 months ago

Describe the issue or request I'm in the process of migrating autorest from a very old version(0.17.3) to the latest autorest v3. Upon generating files with new autorest v3 with same swagger json, I'm not seeing two kinds of files.

  1. Public partial class file
  2. Interfaces for all the clients generated.

I'm only able to see all the clients generated i.e., internal partial class files and the model files.

Below are the commands I'm using to generate these files:

Old Autorest: AutoRest -CodeGenerator Azure.CSharp -modeler CompositeSwagger -Input -OutputDirectory -Namespace

New Autorest: autorest --input-file= --csharp --generation1-convenience-client --output-folder= --namespace=

Can someone help me understand on how I can go about in generating the same set of files as before? Are there any flags that I'm missing?

chunyu3 commented 7 months ago

hello @rakshith210 First I want to confirm that your SDK is data-plane. Right? You specified --generation1-convenience-client, so you will generate our previous version data-plane SDK(HLC) which does not generate public class.

Can you upgrade to our latest data-plane SDK (DPG)?

rakshith210 commented 7 months ago

@chunyu3 - I believe I did try generating the clients via DPG. Isn't it the default option? However, the issue I faced with that was that it didn't generate any models files so ended up generating files via HLC. Let me know if I was missing something ?

chunyu3 commented 3 months ago

hello @rakshith210 When generate DPG from swagger, we only generate protocol method without models. If you want to generate convenience methods and models, you need to upgrade to typespec, and generate DPG from typespec.

PerryCodes commented 3 months ago

What a shame. It looks like this tool actually used to be useful for a variety of uses - not just Azure. That doesn't seem to be the case anymore. I've seen someone in the same boat mention Kiota, so I'm going to look into using that to automatically generate clients.