OpenAPI
Hyperterse automatically generates OpenAPI 3.0 specifications from your query definitions. This enables integration with API clients, testing tools, and documentation platforms.
Accessing OpenAPI specs
Section titled “Accessing OpenAPI specs”Runtime endpoint
Section titled “Runtime endpoint”The OpenAPI specification is available at /docs:
curl http://localhost:8080/docsThis returns a complete OpenAPI 3.0 JSON specification.
View in browser
Section titled “View in browser”Open http://localhost:8080/docs in your browser to see the raw specification, or use a tool like Swagger UI.
Generated specification
Section titled “Generated specification”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
Example
Section titled “Example”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" } } } } } } } } } } } } }}Using with swagger UI
Section titled “Using with swagger UI”Docker
Section titled “Docker”Run Swagger UI pointing to your Hyperterse server:
docker run -p 8081:8080 \ -e SWAGGER_JSON_URL=http://host.docker.internal:8080/docs \ swaggerapi/swagger-uiOpen http://localhost:8081 to browse your API.
Embedded
Section titled “Embedded”You can also embed the OpenAPI spec in your own Swagger UI deployment.
Type mappings
Section titled “Type mappings”Hyperterse types map to OpenAPI types:
| Hyperterse | OpenAPI |
|---|---|
string | string |
int | integer (format: int64) |
float | number (format: double) |
boolean | boolean |
uuid | string (format: uuid) |
datetime | string (format: date-time) |
API client generation
Section titled “API client generation”Use the OpenAPI spec to generate typed API clients:
JavaScript/TypeScript
Section titled “JavaScript/TypeScript”npx openapi-typescript http://localhost:8080/docs --output api.tsPython
Section titled “Python”# Using openapi-python-clientopenapi-python-client generate --url http://localhost:8080/docs# Using oapi-codegenoapi-codegen -package api http://localhost:8080/docs > api.goResponse format
Section titled “Response format”All query endpoints return a consistent format:
{ "success": true, "error": "", "results": [...]}This is documented in the OpenAPI spec for all endpoints.
Error responses
Section titled “Error responses”Error responses follow the same structure:
{ "success": false, "error": "validation error for field 'userId': required input is missing", "results": []}