Azure-Samples / azure-iot-central-samples-csharp

An sample project that interacts with Azure IoT Central rest APIs.
MIT License
7 stars 8 forks source link

How to generate SDK (c#)? #8

Closed banchmaxedgedenergy closed 1 year ago

banchmaxedgedenergy commented 1 year ago

Hi guys, I was trying to generate SDK by openapi data. I found iot central api swagger json here: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/iotcentral/data-plane

Maybe it's not correct one and I have to use something else. If so, please point me to the correct one.

Anyway, with that swagger json, Autorest generates some clients (like entity managers: device manager, template manager etc), but models are not generated. At the same time I see in you repo autogenerated files with models and more granular clients. How did you build those files (I mean everything that is located in folder ./SDK).

Thanks!

yang-hai-feng commented 1 year ago

Using --generation1-convenience-client, for example with latest API swagger:

autorest readme.md --csharp --tag=package-2022-10-31-preview --csharp-sdks-folder="~/sdk/csharp" --generation1-convenience-client --namespace="Microsoft.Azure.IoTCentral.Preview" --public-clients=true

The latest autorest by default using v3 contract, had some changes on generated SDKs, I have created a new PR demonstrated how to use new generated SDKs.

banchmaxedgedenergy commented 1 year ago

Thank you for response!

Do you think it's worth to add small readme or change current one to show that generation process, otherwise people like me can't replicate sdk auto generation with what presented in the current readme version.

Cheers!

yang-hai-feng commented 1 year ago

Yeah, will update the readme file with how to generate your SDK based on API version.