Skip to content

Latest commit

 

History

History
159 lines (116 loc) · 6.61 KB

File metadata and controls

159 lines (116 loc) · 6.61 KB
outline
2
3
title Annotations Reference
titleTemplate NpgsqlRest
description Complete reference for all NpgsqlRest comment annotations. HTTP methods, authorization, caching, rate limiting, and more for PostgreSQL REST APIs.
head
meta
name content
keywords
npgsqlrest annotations, postgresql comment annotations, rest api annotations, http endpoint configuration, sql api annotations
meta
property content
og:title
NpgsqlRest Annotations Reference
meta
property content
og:description
Complete reference for all NpgsqlRest comment annotations for PostgreSQL REST APIs.
meta
property content
og:type
article

Annotations Reference

Complete reference for all NpgsqlRest comment annotations. For an introduction to how annotations work, see the Comment Annotations Guide.

::: info All annotations work in both PostgreSQL function/procedure comments (COMMENT ON FUNCTION ...) and SQL file endpoints (-- and /* */ comments in .sql files). The "SQL File Annotations" section below lists annotations that are specific to SQL files. :::

How to Use This Reference

Each annotation has its own page with:

  • Recognized keywords
  • Syntax explanation
  • Working examples from the test suite
  • Related annotations

Annotation Categories

HTTP & Routing

  • HTTP - Expose function as HTTP endpoint
  • PATH - Set custom endpoint path
  • PROXY - Mark endpoint as reverse proxy
  • PROXY_OUT - Execute function first, then forward result to upstream
  • ENABLED - Enable endpoint for specific tags
  • DISABLED - Disable endpoint for specific tags
  • TAGS - Filter annotations by tags
  • OPENAPI - Hide from the OpenAPI document or override the section tag
  • MCP - Expose a routine as a Model Context Protocol (MCP) tool for AI agents
  • HTTP CUSTOM TYPES - Define HTTP request on composite type for external API calls
  • INTERNAL - Mark endpoint as internal-only (accessible via proxy/HTTP client types, not public HTTP)

Authorization

Basic Authentication

Request Configuration

Response Configuration

  • Response Headers - Set custom response headers
  • RESPONSE_NULL_HANDLING - NULL handling in responses
  • NESTED - Serialize composite type columns as nested JSON objects
  • SINGLE - Return a single record as a JSON object instead of an array
  • VOID - Force endpoint to return 204 No Content

Table Format Output

  • Custom Parameters - table_format, excel_file_name, excel_sheet for HTML table and Excel rendering

Raw Output Mode

  • RAW - Return raw text instead of JSON
  • SEPARATOR - Column separator for raw output
  • NEW_LINE - Row separator for raw output
  • COLUMN_NAMES - Include column headers

Caching

  • CACHED - Enable response caching
  • CACHE_EXPIRES_IN - Set cache expiration
  • CACHE_PROFILE - Select a named cache profile (multiple backends, dynamic TTL, skip-on-condition rules)

Performance

Format References

Server-Sent Events

Upload

  • UPLOAD - File upload handling

Policies

Context & Security

Parameter Annotations

  • PARAM - Rename, retype, set defaults, and configure parameters
  • PARAMETER_HASH - Hash one parameter using another
  • ENCRYPT - Encrypt parameter values before sending to PostgreSQL
  • DECRYPT - Decrypt result column values before returning to client

SQL File Annotations

  • DEFINE_PARAM - Define virtual HTTP parameters not bound to SQL
  • RESULT_NAME - Rename result keys in multi-command SQL file endpoints
  • SKIP - Exclude commands from multi-command results
  • RETURNS - Skip Describe step and resolve return columns from a composite type (for runtime-created temp tables)

Test File Annotations

These apply only to test files run by the SQL test runner (npgsqlrest --test) — not to endpoint SQL files or routine comments:

  • TEST @setup - Run named steps before an individual test file
  • TEST @teardown - Run named steps after an individual test file, always
  • TEST @connection - Run a test file on a different named connection
  • TEST @tag - Tag a test file for Tag/ExcludeTag filtering
  • TEST @claim - Set the acting principal for an in-process endpoint call (HTTP block directive)
  • TEST @response - Name the captured response temp table (HTTP block directive)

Custom