Skip to content

Latest commit

 

History

History
49 lines (31 loc) · 2.11 KB

api-client-sdk-integration-dotnet.md

File metadata and controls

49 lines (31 loc) · 2.11 KB

API Client SDK Integration

You can create a client SDK from APIs registered on API Center using Visual Studio Code. This section will guide you through the integration process.

To use this feature, you need to install the API Center extension in Visual Studio Code. In addition to that, you may be asked to install the Microsoft Kiota extension.

  1. Open the API Center extension, navigate down to the API definition, and right-mouse click on the API definition. Then choose the "Generate API Client" option.

    Context Menu: Generate API Client

  2. When the pop-up modal appears, click the "Open" button.

    Pop-up: Open Microsoft Kiota

  3. When the Kiota extension opens, make sure that everything is selected and click the ▶️ button to generate an API client.

    Microsoft Kiota: Generate API Client

  4. The prompt asks several questions in the order. Enter the following values:

    1. Choose a name for the client class 👉 PetStoreClient
    2. Choose a name for the client class namespace 👉 WebApp.ApiClients
    3. Enter an output path relative to the root of the project 👉 dotnet/src/WebApp/ApiClients
    4. Pick a language 👉 CSharp - stable
  5. After the client is generated, you can see the client class in the specified output path.

    Generated API Client

  6. Copy some codes to make the client SDK work.

    # Bash
    ./infra/scripts/copy-files.sh
    
    # PowerShell
    ./infra/scripts/Copy-Files.ps1
  7. Run the following command to run the web application.

dotnet watch run --project dotnet/src/WebApp
  1. Open the browser and navigate to https://localhost:5001.

  2. You can see the list of pets from the PetStore API.

    Web Application: PetStore API