Imagine buying complex furniture, but the instructions are a chaotic pile of sticky notes. That is exactly how programmers feel when trying to connect different web services (like weather apps or payment processors). They usually have to dig through messy documentation just to make two programs talk to each other.
The OpenAPI Specification (OAS) fixes this by acting as a universal, standardised "Instruction Manual."
Why It Matters
OpenAPI acts as a perfect bridge between humans and machines:
For Humans: It provides a clear map of what a service does, what information it needs, and what it returns.
For Computers: Because the rules are strict and predictable, software can "read" the manual and automatically connect to the service.
What Can You Do With It?
With an OpenAPI blueprint, developers can plug into tools that do the heavy lifting for them:
Create Visual Guides: Turn complex code into sleek, interactive websites where users can test the service with the click of a button.
Write Code Automatically: Instantly generate the "glue code" needed for apps or servers, saving hours of manual typing.
Automate Testing: Let tools read the blueprint to automatically double-check that the software works exactly as promised.
The Big Question: Can AI Work Backwards?
Here is where it gets interesting. If we have existing software but no instruction manual, can we use Generative AI to "reverse-engineer" one just by looking at the code? Doing so would instantly unlock all the automated benefits mentioned above for older projects.
In this post, we are putting this to the test: Can ChatGPT take a zipped folder of existing code and successfully work backwards to write the OpenAPI blueprint?
Step 1: A zipped file for an example Python Flask based simple payroll system (and it is simple): https://github.com/scottturnercanterbury/musical-meme.git
Step 2: Load the zipped file into ChatGPT and the following prompt was used "Unpack this zip file into individual files. Produce an OpenAPI specification based on these files starting with app.py"
It went through the process of unzipping, following the struct , ignoring virtual environment properties, etc.
Produce a YAML filr
Step 3: Using the prompt "Converted the OpenAPI specification in YAML to JSON and show"
{
"openapi": "3.1.0",
"info": {
"title": "Musical Meme Payroll Management System",
"version": "1.0.0",
"description": "A simple Flask-based payroll management application for managing employee records with salary tracking. This service is primarily HTML-rendering (server-side templates) and uses form submissions rather than JSON APIs."
},
"servers": [
{
"url": "http://localhost:5000"
}
],
"tags": [
{
"name": "Employees",
"description": "Employee payroll records"
}
],
"paths": {
"/": {
"get": {
"tags": ["Employees"],
"summary": "List employees",
"description": "Renders a page listing all employee salary records.",
"responses": {
"200": {
"description": "HTML page containing employee list",
"content": {
"text/html": {
"schema": {
"type": "string"
}
}
}
}
}
}
},
"/employees/add": {
"get": {
"tags": ["Employees"],
"summary": "Show add employee form",
"responses": {
"200": {
"description": "HTML form to add an employee",
"content": {
"text/html": {
"schema": {
"type": "string"
}
}
}
}
}
},
figure 1. An extract of the returned specification.
![]() |
| Figure 2 Swagger testing the specification |
![]() |
| figure 3: The schemas produced |


Comments
Post a Comment