dify The creation of a customization tool is provided, although this customization tool is required to follow the OpenAPI-Swagger specification.
An example of a canonical empty template is shown below:
{ "openapi": "3.1.0", "info": { "title": "Untitled". "description": "Your OpenAPI specification", "version": "v1.0.0" }, "servers": [ { "url": "" } ], "paths": {}, "components": { "schemas": {} } }
Generating the OpenAPI-Swagger Specification
We used chatgpt to help me convert the invoked curl command into an openapi schema with the following prompt:
Please convert the curl request command to openapi version 3.1.0 json schema without the response message. curl --location 'https://cloud.dify.ai/generate_image/' --header 'Content-Type: application/json' --data '{"prompt": "A cute little floral kitten, fashionable, wearing a colorful polka dot bow triangle headscarf on her head, big blush, very cute, high saturation, cute doo-doo, plush and soft, wearing a headscarf clashing color system cheongsam, wool felted style, neck with you echoing the color of the scarf, very cute, a bouquet of flowers in her arms, upper half of the body portraits, gifting poses, kawaii, picture Simple, high saturation, relaxing atmosphere, silky picture quality, medium view, standard lens, simple style, 32k HD image, cute, blue sky and white clouds background, subtle"}' Please refer to the following example for the json schema { "openapi": "3.1.0", "info": { "title": "Get weather data", "description": "Retrieves current weather data for a location.", "version": "v1.0.0" }, "servers": [ { "url": "" } ], "paths": {}, "components": { "schemas": {} } }
The generated results are as follows.
{ "openapi": "3.1.0", "info": { "title": "Generate Image API", "description": "API to generate an image based on a given prompt.", "version": "v1.0.0" }, "servers": [ { "url": "https://cloud.dify.ai" } ], "paths": { "/generate_image/": { "post": { "summary": "Generate an image based on a prompt", "operationId": "generateImage", "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/GenerateImageRequest" } } } }, "responses": {} } } }, "components": { "schemas": { "GenerateImageRequest": { "type": "object", "properties": { "prompt": { "type": "string", "description": "The prompt describing the image to be generated." } }, "required": [ "prompt" ] } } } }