OpenAPI Generator
The OpenAPI generator tool generates OpenAPI documents from scratch based on the prompts that you provide.
Tool details and limitations
- This tool is provided to assist users with the task of generating an OpenAPI document from scratch based on a natural language description, it should not be confused with the OAS creator tool, also available to the API Agent, which is used for generating an OpenAPI document from an existing database schema added to the API Agent sources.
- This tool relies on the Granite 3 foundation model available IBM watsonx for OpenAPI document generation.
- Given that this tool relies on the output of the foundation model based on the provided input description, like all AI models, the output is subject to errors.
- If the generated OpenAPI document does not match the description that is provided as input, try again and consider rephrasing the description.
- If the generated OpenAPI document that is displayed from the model contains errors, such as OpenAPI specification errors, or semantic errors, the tool automatically passes the document through the fix (auto-correct) operation of the OpenAPI Enhancer tool. If still errors are present after this correction, these will be reported in the chat window.
-
If the generated OpenAPI document contains JSON or YAML syntax errors that cannot be fixed (auto-corrected) by the OpenAPI Enhancer tool, the tool does not display the document. In this situation, the system displays the following message:
please re-phrase and try again
. Try rewording the input description before trying again, such as using a different ordering or combination of words in the input prompt. - All OpenAPI documents that are generated by this tool should be reviewed for correctness and accuracy before being used.
Generate an OpenAPI document from a natural language description
You can generate an OpenAPI 3.0 document from scratch in either JSON or YAML format, from a
natural language description given in English (one or more sentences) for the API or application
that you would like to generate. Simply start your chat prompt with Generate an openapi
for...
. The generated OpenAPI document contains component schemas relevant to the API or
application that is described, and path items for create, retrieve, update, and delete operations
for those schemas. Also, the generated document includes recommended operation-level security and
security schemas by default, unless explicitly prompted not to do so.
This operation shows with the following details: The generated OpenAPI 3.0 document in JSON or YAML format (By default, if the YAML format not specified in the input prompt message) that can be downloaded.
Parameter | Required | Description | Default |
---|---|---|---|
text |
Yes | The natural language description of the OpenAPI 3.0 specification to be generated Note:
The entire input prompt message is used as the text parameter value. It does not need to be referenced explicitly. |
None |
file_format
|
No | The Open API Generator tool supports the output format of the generated OpenAPI document file in JSON and YAML. | YAML |
- Example prompts
-
Generate an OpenAPI spec for a weather application
Generate an OpenAPI spec for a book library application
Generate an openapi for a blog application in yaml format
Generate an OpenAPI spec for a blog application. Include operations for searching for blogs by most recommended topics. Searching for blogs should not require any authentication
Generate an OpenAPI spec for a weather application. Include an operation to provide a 7-day forecast for a given location
Genrate an OpenAPI spec for a book library application. Include operations to add and remove books from the library. Also include an operation to search the books in the library with a title
Next action suggested
- Generate fastapi server code for the openapi file {@filename}
- Generate fastapi server code with database integration for the openapi file {@filename}