Generate Swagger / OpenAPI documentation
Generate an API-description document from supplied source code.
{
"title": "Generate Swagger / OpenAPI documentation",
"description": "",
"method": "POST",
"baseUrl": "https://app.docuwriter.ai",
"endpoint": "/api/generate-swagger-api",
"headers": [
{
"key": "Authorization",
"value": "Bearer YOUR_API_TOKEN",
"type": "string",
"required": true
},
{
"key": "Accept",
"value": "application/json",
"type": "string",
"required": true
},
{
"key": "Content-Type",
"value": "application/json",
"type": "string",
"required": true
}
],
"queryParams": [],
"pathParams": [],
"bodyType": "json",
"requestBody": "{\n \"source_code\": \"app.get(\\\"/health\\\", (req, res) => res.json({status: \\\"ok\\\"}));\",\n \"filename\": \"server.js\"\n}",
"formData": [],
"rawBody": "",
"responses": {
"200": {
"description": "HTTP 200: success: true; data.generation contains generated text; data.generation_id is the numeric saved ID; data.version_number and data.definitive_version_number identify version metadata. Additional response fields: data.content, data.openapi_json, data.filenames. The OpenAPI JSON is returned as a string inside the JSON envelope. Parse it and validate the schema and endpoint behavior before use; do not assume a specific OpenAPI version solely from the endpoint name. Illustrative JSON example; sample values are fictional. Some optional or additional resource fields may be omitted.",
"body": "{\n \"success\": true,\n \"data\": {\n \"generation\": \"{\\\"openapi\\\":\\\"3.0.3\\\",\\\"info\\\":{\\\"title\\\":\\\"Example API\\\",\\\"version\\\":\\\"1.0.0\\\"},\\\"paths\\\":{}}\",\n \"generation_id\": 456,\n \"version_number\": 1,\n \"definitive_version_number\": 1,\n \"filenames\": [\n \"api.js\"\n ],\n \"content\": \"{\\\"openapi\\\":\\\"3.0.3\\\",\\\"info\\\":{\\\"title\\\":\\\"Example API\\\",\\\"version\\\":\\\"1.0.0\\\"},\\\"paths\\\":{}}\",\n \"openapi_json\": \"{\\\"openapi\\\":\\\"3.0.3\\\",\\\"info\\\":{\\\"title\\\":\\\"Example API\\\",\\\"version\\\":\\\"1.0.0\\\"},\\\"paths\\\":{}}\"\n }\n}"
},
"401": {
"description": "Missing or invalid account API token.Missing or invalid account API token. Example JSON response.",
"body": "{\n \"message\": \"Unauthenticated.\"\n}"
},
"400": {
"description": "Example: supplied code exceeds the processing budget.",
"body": "{\n \"success\": false,\n \"message\": \"The provided code is too large for processing. Please reduce the amount of code and try again.\"\n}"
}
}
}
Request fields
| Field | Requirement |
|---|---|
source_code |
Supply either source_code plus filename, or a files array with 1–1000 objects containing filename (maximum 255 characters) and source_code. |
name |
Optional name: string up to 255 characters |
additional_instructions |
additional_instructions: string. |
| Behavior | Prefer one input form per request. |
Usage notes
- Generation is synchronous and may take time.
- The account must satisfy the generator’s current plan/credit checks (403 if denied).
- Invalid fields return 422; code exceeding the processing token budget returns 400; upstream or output failures can return 500.
- There is no idempotency-key contract: inspect generation history after an uncertain timeout before retrying. Errors and retries.
Updated