myesn

myEsn2E9

hi
github

Kiota: Generate API SDK based on OpenAPI

Introduction#

Kiota is a cross-platform command-line tool developed by Microsoft for generating API SDKs based on the OpenAPI Specification.

To provide comprehensive support for OpenAPI, it has chosen Microsoft.OpenAPI.NET as the underlying support.

Supported Languages#

It can generate client code for languages such as C#, CLI, Go, Java, PHP, Python, Ruby, Swift, and TypeScript. You can click on the link to see the supported client languages in more detail: https://github.com/microsoft/kiota#supported-languages

Installation#

The official documentation provides many installation methods, and I chose to install it using the .NET tool:

dotnet tool install --global Microsoft.OpenApi.Kiota

Usage#

Simply execute the kiota command to see the supported parameters. You can also refer to the documentation.

Example:

kiota generate --openapi https://petstore.swagger.io/v2/swagger.json --output d:\test --language TypeScript

image

If the API is updated, the corresponding SDK also needs to be updated. Note that currently, you can only specify the --output parameter to tell kiota which directory to update the SDK in. Even if you are in the output directory, you still need to specify a relative path ".".

kiota update --output .

You can also click on the link to view the client code generated by kiota for various languages: https://github.com/microsoft/kiota-samples

Other Tools#

  • NSwag is a Windows GUI tool for generating client code. Frequently used
  • Swagger Editor is an OpenAPI editor that can generate server and client code.

References#

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.