打开 VS Code,然后点击 Gemini Code Assist 对话图标。您应该会看到对话窗口。
第 2 步:输入 Apigee 句柄以使用 Apigee 工具
在对话窗口中输入 @Apigee。您会看到 Apigee 提示的列表。
选择创建 API 规范。
第 3 步:输入提示
在输入字段中,输入并提交以下说明以完成提示:
@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.
第 4 步:查看规范
等待 Gemini Code Assist 生成规范。生成规范后,对话窗口会显示有关生成规范的信息,包括从 API Hub 和 API 端点中提取的企业上下文摘要。Cloud Code 中的其他标签页会显示规范代码和 Swagger 界面,其中包含有关新 API 规范的端点、架构和其他信息。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-05。"],[[["\u003cp\u003eThis tutorial demonstrates how to use Gemini Code Assist in Cloud Code to design an API and create an Apigee API proxy from a generated API specification.\u003c/p\u003e\n"],["\u003cp\u003eYou'll learn how to use natural language prompts to create an API, view and modify the generated spec, and test it using a local mock server.\u003c/p\u003e\n"],["\u003cp\u003eThe tutorial covers the optional step of registering your final API to API hub for developer access.\u003c/p\u003e\n"],["\u003cp\u003eYou can also save the designed API, create an Apigee API proxy bundle from the API spec, and continue developing the proxy.\u003c/p\u003e\n"],["\u003cp\u003eThe necessary prerequisites include setting up Gemini for Google Cloud API, Apigee API Admin access, local development in Cloud Code, and familiarity with OpenAPI specifications.\u003c/p\u003e\n"]]],[],null,["# Tutorial: Use Gemini Code Assist to design, develop, and test APIs in Apigee\n\n*This page\napplies to **Apigee** and **Apigee hybrid**.*\n\nOverview\n--------\n\nThis tutorial guides you through the process of using the `@Apigee` tool in\nGemini Code Assist to\ncreate and edit an API spec. You'll use a natural language prompt to design and create an API for\nmanaging dental office appointments. Once the spec is ready, you can also test it and create an\nApigee API proxy from it.\n\nFor more information on creating and editing API specs using Gemini Code Assist, see\n[Design and edit APIs](/apigee/docs/api-platform/local-development/vscode/develop-design-edit-apis).\n\nBefore you begin\n----------------\n\nTo complete this tutorial, you'll need:\n\n- A Google Cloud project set up for local development in Google Cloud. See [Set up Apigee API Management in Cloud Code for VS Code](/apigee/docs/api-platform/local-development/setup). Make sure to set up Gemini Code Assist for your project. See [Use Gemini Code Assist with Apigee](/apigee/docs/api-platform/local-development/setup#gemini).\n- To make sure your user account has the required roles listed in [Required roles to use Gemini Code Assist in Apigee](/apigee/docs/api-platform/local-development/setup#required-roles-to-use-gemini-code-assist-in-apigee) for each task.\n- Familiarity with [OpenAPI specs](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md), so that you can review the generated spec.\n\nStep 1: Open Gemini Code Assist Chat\n------------------------------------\n\nOpen VS Code and click the Gemini Code Assist chat icon. You should see the chat window.\n\nStep 2: Enter the Apigee handle to use the\nApigee tool\n------------------------------------------------------\n\nType `@Apigee` in the chat window. You'll see a list of Apigee prompts.\nSelect **Create an API specification**.\n\nStep 3: Enter the prompt\n------------------------\n\nIn the input field, enter and submit this description to complete the prompt: \n\n\n`@Apigee Create an API specification for patients to schedule their own appointments with a dental\noffice. Include multiple dentists and a dental appointment type, which can be regular checkup or\nother.`\n| **Note:** Do not copy and paste over the `@Apigee` handle. Instead, complete the prompt by pasting in the text starting with `for patients to\n| schedule...`.\n\nStep 4: View the spec\n---------------------\n\nWait while Gemini Code Assist generates the spec. Once it's available, the chat window\nshows information about the generated spec, including a summary of enterprise context leveraged\nfrom your API hub and API endpoints. Other tabs in Cloud Code\nshow the spec code and the Swagger interface with the endoints, schema, and other information\nabout the new API spec.\n\nStep 5: Modify the spec\n-----------------------\n\nModify the spec to include multiple dental office locations. First, make sure that the\nYAML file containing the spec is in the currently active tab in your editor. Then, in the chat window,\nenter the\nApigee handle again and select the Apigee tool: `@Apigee`. Enter this\nprompt: \n\n`@Apigee Update the API specification for the dental scheduling API. Add multiple dental\noffice locations.`\n\nThe changes to the spec are shown, with diffs highlighted, in the editing tab. You can also\nmodify the spec by typing your updates directly in the editing tab and saving the file.\n\nStep 6: Publish your API to API hub\n-----------------------------------\n\nOnce your API is reviewed and final, make it available to developers by registering it\nwith API hub:\n\n1. Click **Publish to API hub**.\n2. Follow the prompts to publish/register the API. See [Register an API](/apigee/docs/apihub/manage-apis#register-an-api) for information on registering with API hub and the information you need to provide.\n\nStep 7: Test the API using a local mock server\n----------------------------------------------\n\nTest the API using the local\n[mock server](/apigee/docs/api-platform/local-development/vscode/develop-design-edit-apis#use-the-local-mock-server),\nwhich emulates responses for the API. The local mock server does not require publishing to\nAPI Hub.\n\nThe local mock server should already be selected in the **Servers** dropdown. \n\nOnce the local mock server is selected, open the **POST** path and click **Try it out**.\n\nProvide the \"city\", \"country\", and \"postalCode\" values in the request body for the\n`addresses` entity: \n\n```\n{\n \"city\": \"string\",\n \"country\": \"string\",\n \"postalCode\": \"string\",\n \"state\": \"string\",\n \"streetAddress\": \"string\"\n }\n```\n\nClick **Execute** to see a mock response from the API in the **Responses** section.\n\nStep 8: Create an API proxy bundle from this spec\n-------------------------------------------------\n\n(Optional) To create an Apigee\n[API proxy bundle](/apigee/docs/api-platform/fundamentals/understanding-apis-and-api-proxies#howdoyoucreateanapiproxy)\nfrom this spec, click the **Create API proxy bundle** button and enter a proxy name.\nAfter creation, you should see the new proxy under **apiproxies** in your Apigee\nworkspace. See\n[Developing API proxies](/apigee/docs/api-platform/local-development/vscode/develop-apiproxies)\nfor information on working with API proxies in Cloud Code. \n\nNext steps\n----------\n\n- Learn more about [designing and editing APIs using Cloud Code](/apigee/docs/api-platform/local-development/vscode/develop-design-edit-apis).\n- Learn more about Gemini Code Assist features you can use in Apigee. See [Use Gemini](/apigee/docs/api-platform/get-started/gemini-code-assist)."]]