Skip to content

OpenAPI

Hyperterse automatically generates OpenAPI 3.0 specifications from your query definitions. This enables integration with API clients, testing tools, and documentation platforms.

The OpenAPI specification is available at /docs:

Terminal window
curl http://localhost:8080/docs

This returns a complete OpenAPI 3.0 JSON specification.

Open http://localhost:8080/docs in your browser to see the raw specification, or use a tool like Swagger UI.

For each query, Hyperterse generates:

  • Path: /query/{query-name}
  • Method: POST
  • Request Schema: Based on input definitions
  • Response Schema: Based on data definitions
  • Description: From query description

Given this query:

queries:
get-user-by-id:
use: main_db
description: 'Retrieve a user by their unique ID'
statement: 'SELECT id, name, email FROM users WHERE id = {{ inputs.userId }}'
inputs:
userId:
type: int
description: 'Unique user identifier'

Hyperterse generates:

{
"openapi": "3.0.0",
"info": {
"title": "Hyperterse API",
"version": "1.0.0"
},
"paths": {
"/query/get-user-by-id": {
"post": {
"summary": "Retrieve a user by their unique ID",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["userId"],
"properties": {
"userId": {
"type": "integer",
"description": "Unique user identifier"
}
}
}
}
}
},
"responses": {
"200": {
"description": "Successful response",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": { "type": "boolean" },
"error": { "type": "string" },
"results": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": { "type": "integer" },
"name": { "type": "string" },
"email": { "type": "string" }
}
}
}
}
}
}
}
}
}
}
}
}
}

Run Swagger UI pointing to your Hyperterse server:

Terminal window
docker run -p 8081:8080 \
-e SWAGGER_JSON_URL=http://host.docker.internal:8080/docs \
swaggerapi/swagger-ui

Open http://localhost:8081 to browse your API.

You can also embed the OpenAPI spec in your own Swagger UI deployment.

Hyperterse types map to OpenAPI types:

HyperterseOpenAPI
stringstring
intinteger (format: int64)
floatnumber (format: double)
booleanboolean
uuidstring (format: uuid)
datetimestring (format: date-time)

Use the OpenAPI spec to generate typed API clients:

Terminal window
npx openapi-typescript http://localhost:8080/docs --output api.ts
Terminal window
# Using openapi-python-client
openapi-python-client generate --url http://localhost:8080/docs
Terminal window
# Using oapi-codegen
oapi-codegen -package api http://localhost:8080/docs > api.go

All query endpoints return a consistent format:

{
"success": true,
"error": "",
"results": [...]
}

This is documented in the OpenAPI spec for all endpoints.

Error responses follow the same structure:

{
"success": false,
"error": "validation error for field 'userId': required input is missing",
"results": []
}