← 输入框|npgsqlrest.github.io|刷新
Skip to content

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.

Looking for a specific keyword?

Annotations often have aliases (@timeout → COMMAND_TIMEOUT, @retry → RETRY_STRATEGY, @anon → ALLOW_ANONYMOUS). See the A–Z Index for every name and alias.

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 - Re-enable an endpoint after @disabled, optionally only for specific tags
  • DISABLED - Disable endpoint, optionally only 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 ​

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

Client Code Generation ​

  • TSCLIENT - Control TypeScript client generation per endpoint (disable, module names, URL exports, TanStack Query hooks opt-out)
  • DARTCLIENT - Control Dart (Flutter) client generation per endpoint (disable, module names, URL exports, response options)

Raw Output Mode ​

Caching ​

Performance ​

Format References ​

Server-Sent Events ​

Upload ​

Policies ​

Context & Security ​

Parameter Annotations ​

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 ​

A–Z Index (Names and Aliases) ​

Most annotations accept one or more aliases, so the keyword you remember may not be the page name (for example, @timeout is documented under COMMAND_TIMEOUT). All keywords work with or without the @ prefix. Use your browser's find (Ctrl+F / ⌘F) on this table to look up any keyword.

AnnotationAlso acceptedWhat it does
ALLOW_ANONYMOUSanonymous, allow_anon, anonAllow unauthenticated access
AUTHORIZEauthorized, requires_authorizationRequire authentication
BASIC_AUTHbasic_authenticationEnable HTTP Basic Authentication
BASIC_AUTH_COMMANDbasic_authentication_command, challenge_commandSet validation function
BASIC_AUTH_REALMbasic_authentication_realm, realmSet authentication realm
BODY_PARAMETER_NAMEbody_param_nameBody parameter name
BUFFER_ROWSbufferRow buffering count
CACHE_EXPIRES_INcache_expiresSet cache expiration
CACHE_PROFILE—Select a named cache profile (multiple backends, dynamic TTL, skip-on-condition rules)
CACHED—Enable response caching
COLUMN_NAMEScolumns, namesInclude column headers
COMMAND_TIMEOUTtimeoutQuery timeout
CONNECTIONconnection_nameNamed database connection
Custom Parameters—Custom key-value settings
DARTCLIENT—Control Dart (Flutter) client generation per endpoint (disable, module names, URL exports, response options)
DECRYPTdecrypted, unprotect, unprotectedDecrypt result column values before returning to client
DEFINE_PARAM—Define virtual HTTP parameters not bound to SQL
DISABLED—Disable endpoint, optionally only for specific tags
ENABLED—Re-enable an endpoint after @disabled, optionally only for specific tags
ENCRYPTencrypted, protect, protectedEncrypt parameter values before sending to PostgreSQL
ERROR_CODE_POLICYerror_code_policy_name, error_codeError handling policy
HTTP—Expose function as HTTP endpoint
HTTP CUSTOM TYPES—Define HTTP request on composite type for external API calls
INTERNALinternal_onlyMark endpoint as internal-only (accessible via proxy/HTTP client types, not public HTTP)
Interval Format—Time/duration format for timeouts and cache expiration
LOGINsigninMark as sign-in endpoint
LOGOUTsignoutMark as sign-out endpoint
MCP—Expose a routine as a Model Context Protocol (MCP) tool for AI agents
NESTEDnested_json, nested_compositeSerialize composite type columns as nested JSON objects
NEW_LINEraw_new_lineRow separator for raw output
OPENAPI—Hide from the OpenAPI document or override the section tag
PARAMparameterRename, retype, set defaults, and configure parameters
Parameter Value Substitution—{name} placeholders in annotation values
PARAMETER_HASHparam … is hash of … form of PARAMHash one parameter using another
PATH—Set custom endpoint path
PROXYreverse_proxyMark endpoint as reverse proxy
PROXY_OUTforward_proxyExecute function first, then forward result to upstream
QUERY_STRING_NULL_HANDLINGquery_null_handling, query_string_null, query_nullNULL handling in query strings
RATE_LIMITER_POLICYrate_limiter_policy_name, rate_limiterRate limiting policy
RAWraw_mode, raw_resultsReturn raw text instead of JSON
REQUEST_HEADERS_MODErequest_headersControl header passing
REQUEST_HEADERS_PARAMETER_NAMErequest_headers_param_name, request-headers-param-nameHeader parameter name
REQUEST_PARAM_TYPEparam_typeQuery string vs body parameters
Resolved Parameters—Compute a parameter value server-side from a SQL expression
Response Headers—Set custom response headers
RESPONSE_NULL_HANDLINGresponse_nullNULL handling in responses
RESULT_NAMEresultRename result keys in multi-command SQL file endpoints
RETRY_STRATEGYretry_strategy_name, retryRetry behavior
RETURNS—Skip Describe step and resolve return columns from a composite type (for runtime-created temp tables)
SECURITY_SENSITIVEsensitive, securityObfuscate logs
SEPARATORraw_separatorColumn separator for raw output
SINGLEsingle_record, single_resultReturn a single record as a JSON object instead of an array
SKIPskip_result, no_resultExclude commands from multi-command results
SSEsse_events_path, sse_pathEnable Server-Sent Events
SSE_EVENTS_LEVELsse_levelNotice level for SSE
SSE_EVENTS_SCOPEsse_scopeSSE distribution scope
TABLE_FORMAT—table_format, excel_file_name, excel_sheet for HTML table and Excel rendering
TAGSfor, tagFilter annotations by tags
TEST @claim—Set the acting principal for an in-process endpoint call (HTTP block directive)
TEST @connection—Run a test file on a different named connection
TEST @response—Name the captured response temp table (HTTP block directive)
TEST @setup—Run named steps before an individual test file
TEST @tag—Tag a test file for Tag/ExcludeTag filtering
TEST @teardown—Run named steps after an individual test file, always
TSCLIENT—Control TypeScript client generation per endpoint (disable, module names, URL exports, TanStack Query hooks opt-out)
UPLOAD—File upload handling
USER_CONTEXT—Enable user context
USER_PARAMETERSuser_paramsAdd user parameters
VALIDATE—Parameter validation before database execution
VOIDvoid_resultForce endpoint to return 204 No Content

Comments