Prompts library
The API Agent prompts library provides a comprehensive guide on using prompts to perform various tasks, such as generating test cases, running test cases, listing test suites, creating OpenAPI specifications, generating code, and chaining prompts.
Guidelines for using prompts
- Avoid the words or tone that convey sarcasm or humor, as they can be misinterpreted.
- Use active voice, correct grammar and spelling, and keep your request clear and specific.
- Provide clear context and relevant keywords, and avoid vague or domain-specific terms. For
example,
generate test
orbuild api
. - If the system is unable to understand your request, it offers suggestions for the requests.
Prerequisites
Use the API Agent plug-in to perform tasks concerning API Connect.
- Ensure that you are logged in to API Agent. For login and operation instructions, see Getting started.
- You must have valid permissions to use the API Agent. For more information, see API Agent user roles.
- Ensure that you have the same permissions through the API Connect’s API
Manager interface. Even if you
have permission to use the API Agent plug-in, actions
fail if you do not have the necessary permissions to perform the same tasks through the API
Manager UI.Note: When performing tasks related to the API Connect catalog, the API Agent plug-in currently supports operations on the Sandbox catalog. As a result, the catalog name is not explicitly stated in the tasks.
Generating test cases
Check that the API is published before generating test cases. For more information, see Creating and publishing draft API.
-
In Visual Studio Code, enter the following prompt:
Generate test cases for <pulbished api name>
Note: The<published api name>
must contain the name of the API. Do not include the version information. For example, usepetstore
, do not usepetstore_1.0.0
. - Click Send. API Agent displays the proposed plan along with the proper arguments.
- Click Start. API Agent connects to smart
generation feature of test module, which creates test cases iteratively for the first 15 endpoints
in the available API file. The test cases are stored in a test suite suffixed with
AA_Test_Suite
along withapi name (AA_Test_Suite_<api_name>)
. After generation is completed, API Agent displays the status message indicating the number of test cases created along with the test suite name where it is created.
You can find the generated test cases in the Test module of the API Manager console.
Running test cases
-
In Visual Studio Code, enter the following prompt:
Run test cases for <pulbished api name>
Note: The<published api name>
must contain the name of the API. Do not combine the version information. For example,petstore
. - Click Send. API Agent displays the proposed plan along with the proper arguments.
- Click Start.
-
The Smart Generation feature of the API Connect test module generates the data for input parameters to run the test. After initiating the runs successfully, the API Agent displays the status message and the URLs of test results in Visual Studio Code.
-
Click the hyperlink to view the results of the individual test cases in the API Manager console.
- Optional: To delete the test case, enter the following
prompt:
delete test case <test_name> in suite <suite_name>
Listing test suites
pOrgId
, complete the following steps:- Enter the following prompt:
List test suites
- Click Send. API Agent displays the list
of test suits corresponding to a
pOrgId
. - Optional: To delete the test suite, enter the following
prompt:
delete test suite <suite_name>
Listing test cases
- Ensure that the test suites are available. If not available, follow the steps mentioned in the Generating test cases.
- To identify the available test suites, see the List test suites section.
- Enter the following
prompt:
List test cases for test suite <test suite name>
- Click Send. API Agent displays the list of test cases corresponding to a test suite.
Creating an OpenAPI
- To create an API specification for orders table, enter the following
prompt:
create openapi for orders table
orgenerate api spec for orders table
Note: There should not be any other table with the same name in any other schema within the database because it might lead to confusion or errors. - To create an API specification for orders table, enter the following prompt:
orcreate openapi for orders table with schema_name as purchase_order
create openapi for orders table in purchase_order schema
- To create an API specification for orders table by using object name and without schema name,
enter the following prompt:
create openapi for orders table with object_name as purchase_order_orders
- To create an API specification for orders table by using source ID, enter the following
prompt:
create openapi for orders table with source_id as 6c115670-a7e1-11ef-b576-fa5e88d5392d
- To extract the OpenAPI specification for the table name and transforms to code
generator-specific format, enter the following
prompt:
Extract the openapi spec for the given table name and transforms to Code generator specific format
- To create an API specification for orders table by using the source ID, run the following
command:
create api for orders table with source_id as 6c115670-a7e1-11ef-b576-fa5e88d5392d
Generating code
- To generate code for a simple server type, you can enter one of the following
prompts:
Generate some Python FastAPI server code based on the following openapi @my_file.yaml
orPlease build FastAPI backend code using the OpenAPI file @api_spec.yaml
orCan you develop a Python FastAPI server using the openapi specification provided in @service_definition.json
- To generate code for a database CRUD server type, you can enter one of the following
prompts:
Generate some Python FastAPI server code based on the following openapi @my_file.yaml that handles database operations
orPlease build FastAPI backend code, including some database integration, using the OpenAPI file @api_spec.yaml
orCan you develop a database driven Python FastAPI server using the openapi specification provided in @service_definition.json
Sequential prompts
- To create and run test cases, enter the following
prompt:
create test cases for the petstore api and run the test cases
- To list draft or published APIs or products, enter the following prompt:
list draft apis, draft products, published apis and published products
list published apis
- To create a draft API and generate FastAPI server code, enter the following
prompt:
create draft api from file @openapi.yaml and generate fastapi server code from the same api file
create draft api using @file_name
- To review security of an API, enter the following
prompt:
review security of api API_NAME:VERSION
- To review security and validate an API, enter the following
prompts:
review security of api API_NAME:VERSION
validate api API_NAME:VERSION
To know more information about chaining multiple tools together, see APIConnect Task tool.