Tutorial: Use Gemini Code Assist to design, develop, and test APIs in Apigee

This page applies to Apigee and Apigee hybrid.

Overview

This tutorial guides you through the process of using the @Apigee tool in Gemini Code Assist to create and edit an API spec. You'll use a natural language prompt to design and create an API for managing dental office appointments. Once the spec is ready, you can also test it and create an Apigee API proxy from it.

For more information on creating and editing API specs using Gemini Code Assist, see Design and edit APIs.

Before you begin

To complete this tutorial, you'll need:

Step 1: Open Gemini Code Assist Chat

Open VS Code and click the Gemini Code Assist chat icon. You should see the chat window.

Cloud Code Gemini Code Assist chat

Step 2: Enter the Apigee handle to use the Apigee tool

Type @Apigee in the chat window. You'll see a list of Apigee prompts. Select Create an API specification.

Cloud Code Gemini Code Assist chat window with Apigee tool

Step 3: Enter the prompt

In the input field, enter and submit this description to complete the prompt:

@Apigee Create an API specification for patients to schedule their own appointments with a dental office. Include multiple dentists and a dental appointment type, which can be regular checkup or other.

Cloud Code Gemini Code Assist chat window with creation prompt

Step 4: View the spec

Wait while Gemini Code Assist generates the spec. Once it's available, the chat window shows information about the generated spec, including a summary of enterprise context leveraged from your API hub and API endpoints. Other tabs in Cloud Code show the spec code and the Swagger interface with the endoints, schema, and other information about the new API spec.

Cloud Code Gemini Code Assist chat showing spec endpoints

Step 5: Modify the spec

Modify the spec to include multiple dental office locations. First, make sure that the YAML file containing the spec is in the currently active tab in your editor. Then, in the chat window, enter the Apigee handle again and select the Apigee tool: @Apigee. Enter this prompt:

@Apigee Update the API specification for the dental scheduling API. Add multiple dental office locations.

The changes to the spec are shown, with diffs highlighted, in the editing tab. You can also modify the spec by typing your updates directly in the editing tab and saving the file.

Cloud Code Gemini Code Assist edited code

Step 6: Publish your API to API hub

Once your API is reviewed and final, make it available to developers by registering it with API hub:

  1. Click Publish to API hub.
  2. Follow the prompts to publish/register the API. See Register an API for information on registering with API hub and the information you need to provide.

Step 7: Test the API using a local mock server

Test the API using the local mock server, which emulates responses for the API. The local mock server does not require publishing to API Hub.

The local mock server should already be selected in the Servers dropdown.
Cloud Code Gemini Code Assist local mock server in dropdown

Once the local mock server is selected, open the POST path and click Try it out.

Provide the "city", "country", and "postalCode" values in the request body for the addresses entity:

{
    "city": "string",
    "country": "string",
    "postalCode": "string",
    "state": "string",
    "streetAddress": "string"
  }

Click Execute to see a mock response from the API in the Responses section.

Step 8: Create an API proxy bundle from this spec

(Optional) To create an Apigee API proxy bundle from this spec, click the Create API proxy bundle button and enter a proxy name. After creation, you should see the new proxy under apiproxies in your Apigee workspace. See Developing API proxies for information on working with API proxies in Cloud Code.

Next steps