Skip to main content

OpenAPI Specification Generator

note

For a deep-dive into database-first OpenAPI design — type mapping, the Base/Create/Full component triad, and how schema constraints inform path structure — see Your Database Is Already an API.

TalkingSchema's AI copilot derives a production-grade OpenAPI 3.1 specification from your entity relationship diagram. Every table becomes a components/schema, every relationship informs response nesting, and standard CRUD paths are generated with typed request bodies, response envelopes, and pagination parameters. The AI explicitly calls out assumptions it makes — such as inferred endpoint semantics — so you can correct them before committing to the contract.

Outputs are provided as YAML or JSON code blocks, with an option to download as a .yaml or .json file coming soon


How to Generate an OpenAPI Spec​

Standard CRUD spec​

Generate an OpenAPI 3.1 YAML spec for CRUD endpoints based on this schema.
For each resource: GET /{resource} (list with pagination), POST /{resource},
GET /{resource}/{id}, PATCH /{resource}/{id}, DELETE /{resource}/{id}.
Include components/schemas with all field types, nullable flags, and enums.

Selective endpoints​

Generate OpenAPI 3.1 paths only for: suppliers (read-only), products
(full CRUD), and purchase_orders (create + read, no update or delete).
Explain any assumptions about resource nesting.

With authentication​

Generate an OpenAPI 3.1 spec with Bearer token authentication applied
to all endpoints. Include a securitySchemes component and apply
security: [bearerAuth: []] globally.

Example Output​

Using the Global Sustainable Supply Chain (GSSC) schema — showing the suppliers and products resources:

openapi: "3.1.0"
info:
title: Global Sustainable Supply Chain API
version: "1.0.0"
description: >
REST API for managing suppliers, products, purchase orders, shipments,
and inventory across a multi-warehouse supply chain network.

servers:
- url: https://api.example.com/v1

security:
- bearerAuth: []

components:
securitySchemes:
bearerAuth:
type: http
scheme: bearer
bearerFormat: JWT

schemas:
CarbonTier:
type: string
enum: [A, B, C, D]
description: Supplier sustainability certification tier (A = highest, D = lowest)

SupplierBase:
type: object
properties:
company_name:
type: string
maxLength: 200
country:
type: string
maxLength: 100
carbon_tier:
$ref: "#/components/schemas/CarbonTier"
certification:
type: string
maxLength: 100
nullable: true
is_active:
type: boolean
default: true

Supplier:
allOf:
- $ref: "#/components/schemas/SupplierBase"
- type: object
properties:
supplier_id:
type: string
format: uuid
readOnly: true
created_at:
type: string
format: date-time
readOnly: true
updated_at:
type: string
format: date-time
readOnly: true
required:
- supplier_id
- company_name
- country
- carbon_tier
- created_at
- updated_at

SupplierCreate:
allOf:
- $ref: "#/components/schemas/SupplierBase"
required:
- company_name
- country
- carbon_tier

ProductBase:
type: object
properties:
sku:
type: string
maxLength: 50
name:
type: string
maxLength: 200
category:
type: string
maxLength: 100
unit_weight_kg:
type: number
format: double
nullable: true
unit_cost_usd:
type: number
format: double
minimum: 0
carbon_intensity_score:
type: number
format: double
minimum: 0
maximum: 999.99
nullable: true
description: CO₂ emissions in kg per unit produced
supplier_id:
type: string
format: uuid
is_active:
type: boolean
default: true

Product:
allOf:
- $ref: "#/components/schemas/ProductBase"
- type: object
properties:
product_id:
type: string
format: uuid
readOnly: true
created_at:
type: string
format: date-time
readOnly: true
updated_at:
type: string
format: date-time
readOnly: true

PaginatedSuppliers:
type: object
properties:
data:
type: array
items:
$ref: "#/components/schemas/Supplier"
total:
type: integer
page:
type: integer
per_page:
type: integer

ErrorResponse:
type: object
properties:
error:
type: string
message:
type: string
required:
- error

paths:
/suppliers:
get:
operationId: listSuppliers
summary: List all suppliers
tags: [Suppliers]
parameters:
- name: page
in: query
schema:
type: integer
default: 1
- name: per_page
in: query
schema:
type: integer
default: 20
maximum: 100
- name: carbon_tier
in: query
schema:
$ref: "#/components/schemas/CarbonTier"
- name: is_active
in: query
schema:
type: boolean
responses:
"200":
description: Paginated list of suppliers
content:
application/json:
schema:
$ref: "#/components/schemas/PaginatedSuppliers"
post:
operationId: createSupplier
summary: Create a new supplier
tags: [Suppliers]
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/SupplierCreate"
responses:
"201":
description: Supplier created
content:
application/json:
schema:
$ref: "#/components/schemas/Supplier"
"400":
description: Validation error
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"

/suppliers/{supplier_id}:
parameters:
- name: supplier_id
in: path
required: true
schema:
type: string
format: uuid
get:
operationId: getSupplier
summary: Get supplier by ID
tags: [Suppliers]
responses:
"200":
description: Supplier record
content:
application/json:
schema:
$ref: "#/components/schemas/Supplier"
"404":
description: Not found
patch:
operationId: updateSupplier
summary: Partially update a supplier
tags: [Suppliers]
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/SupplierBase"
responses:
"200":
description: Updated supplier
content:
application/json:
schema:
$ref: "#/components/schemas/Supplier"
delete:
operationId: deleteSupplier
summary: Delete a supplier
tags: [Suppliers]
responses:
"204":
description: Deleted successfully

Customizing the Output​

RequirementPrompt addition
JSON instead of YAML"Output as JSON instead of YAML"
Nested resource paths"Use nested paths: /suppliers/{id}/products instead of flat /products"
Exclude delete endpoints"Do not generate DELETE paths for any resource"
Add response envelope"Wrap all responses in a data/meta envelope: { data: T, meta: { request_id: string } }"
OpenAPI 3.0 instead of 3.1"Target OpenAPI 3.0.3 for compatibility with AWS API Gateway"
Add examples"Include a realistic example object for each schema component"

Frequently Asked Questions​

Does the spec include relationship endpoints?​

By default, TalkingSchema generates flat resource endpoints. Ask explicitly for nested paths: "Generate nested endpoints for purchase_order_items under /purchase-orders/{id}/items."

Can the spec be used with code generators?​

Yes. The output is valid OpenAPI 3.1 YAML that works with openapi-generator, oapi-codegen (Go), openapi-typescript, and Swagger Codegen to scaffold client SDKs and server stubs.

Does the AI explain its assumptions?​

Yes. The AI notes assumptions it makes about resource naming, HTTP method semantics, and relationships. Review and adjust these before using the spec as a binding API contract.