Skip to content

Changelog v4.1.1 ​

Version 4.1.1 (2026-12-02) ​

Full Changelog

Patch release. What the generators say an endpoint answers with now matches what the endpoint answers with: the OpenAPI document, the generated TypeScript and Dart clients, and the MCP tool schemas. Reported in #36 for one case (@single in the OpenAPI document). The other cases were found by calling every endpoint of the test suite and comparing each answer with the document. Two responses were wrong themselves and are fixed: a money value made the response invalid JSON, and a raw response was labelled as JSON. No configuration key was added or changed.

Who should upgrade: everyone who generates clients from openapi.json, and everyone who uses raw, table_format, money or bytea results, uploads, the void annotation or cache invalidation endpoints with the generated TypeScript or Dart clients or with MCP tools.

After upgrading: regenerate the OpenAPI document and the clients. Read Changes in responses first: two responses change. What still cannot be described exactly is listed in Known limits.

Summary ​

WhatAffects
Changedmoney values are JSON strings ("$1,234.50"); they were written without quotes, which is not valid JSONresponses, all generators
Changedraw responses without a content type are text/plain; they were application/jsonresponses, OpenAPI
Fixedthe described response follows the endpoint's annotations and return type (single, void, single values, bytea, raw, table_format, json, composite types, SQL files with several statements, cache invalidation, proxy, login)OpenAPI
Fixedupload endpoints have a multipart/form-data request bodyOpenAPI
Fixeda 204 response is documented for endpoints that answer NULL or no row with itOpenAPI
Fixedthe cache invalidation endpoint of a hidden endpoint is hidden, and has the tags of its endpointOpenAPI, MCP
Fixedfunctions for raw, table_format, bytea, cache invalidation and upload endpoints read and type the response the endpoint givesTypeScript and Dart clients
FixedoutputSchema and structuredContent agree for a set with one named column, single and the void annotationMCP
Documentedwhat cannot be described exactlyKnown limits

Contents ​

Changes in responses ​

money values are JSON strings ​

A money value in a row was written without quotes:

json
json
[{"id":1,"price":$1,234.50}]

This is not valid JSON, so no client could read a response that had a money column, an array of money, or a composite type with a money field. It is now a string, as PostgreSQL writes it:

json
json
[{"id":1,"price":"$1,234.50"}]
  • The text is in the format of the database's lc_monetary setting ($1,234.50, 1.234,50 €), which is why it cannot be a JSON number. To get a number, return price::numeric from the routine.
  • A routine that returns one money value answers with it as text/plain, as before.
  • A money parameter is unchanged: it is a decimal number, sent as a number (12.5) or as a string ("12.5").
  • The generators follow: money is string in the TypeScript client, String in the Dart client (it was double), and a string in the OpenAPI document and in MCP schemas. This applies to parameters as well.

raw responses are text/plain ​

A raw endpoint that does not set a content type answered with the content type application/json, although its body is text that is not JSON. It now answers with text/plain. The same goes for a raw routine that returns a single array value.

If you rely on the old header: set it on the endpoint.

sql
sql
comment on function export_users() is '
HTTP GET
raw
Content-Type: application/json';

Endpoints that already set a content type (Content-Type: text/csv) are not affected.

Fixes ​

OpenAPI: the described response did not match the response ​

The document decided the response from the routine alone and did not look at the endpoint's annotations. Before the fix, 482 of the 1,271 answers of the test suite's endpoints that could be compared were not what the document said.

EndpointThe document saidThe endpoint answers with, and the document now says
single on a set of rows (#36)an array of objectsone object
single on a set of values (returns setof text)an array of objectsone value
a set of values (returns setof text)an array of objectsan array of values
void annotation, or a routine that returns nothing200204, no body
a single value that is not json or an array (returns text, int, boolean...)application/jsontext/plain; a boolean is t or f
byteaapplication/json, a stringapplication/octet-stream
rawan array of objectsa string, text/plain
table_format (HTML, Excel)application/json, an array of objectsthe content type of the format
json and jsonb values and columnsan objectany JSON value
moneya numbera string
a column that is an array of a composite typean array of stringsan array of objects with the type's fields
nested composite columnsthe fields of the type as columns of the rowone object under the column name
returns recordan objectan array of strings
SQL files with several statementsthe columns of the first statementan object with a property for each statement: its rows (one object with single), or the number of rows it affected
cache invalidation endpoint (InvalidateCacheSuffix)the response of the cached endpoint{"invalidated": true} or {"invalidated": false}
proxy with a routine that returns nothing, and proxy_outno bodythe response of the upstream service (*/*)
loginthe routine's columnsa body that depends on the authentication scheme (*/*)
a content type taken from a parameter (Content-Type: {_type})the content type {_type}*/*

For the function in the report

sql
sql
create function api.register_thing()
returns table (thing_id uuid, name text)
language sql
begin atomic
    select gen_random_uuid(), 'a';
end;
comment on function api.register_thing() is '
@http POST /api/things
@single
Registers a thing.';

the response in openapi.json was

json
json
"200": { "description": "Successful response", "content": { "application/json": { "schema": {
  "type": "array", "items": { "type": "object", "properties": { "thingId": { "type": "string", "format": "uuid" }, "name": { "type": "string" } } }
} } } }

and is now

json
json
"200": { "description": "Successful response", "content": { "application/json": { "schema": {
  "type": "object", "properties": { "thingId": { "type": "string", "format": "uuid" }, "name": { "type": "string" } }
} } } }

OpenAPI: three more things the document did not say ​

  • Uploads. An upload endpoint had no request body in the document. It now has a multipart/form-data body with the files.
  • 204 for no value. An endpoint that answers a NULL value, or single with no row, with 204 (response_null_handling no_content) now has a 204 response next to its 200.
  • Hidden endpoints. The cache invalidation endpoint of an endpoint with openapi hide was still in the document, so the path that was meant to be hidden was visible. It is hidden now, and an invalidation endpoint also gets the openapi tags of its endpoint.

TypeScript and Dart clients: functions that read the wrong kind of response ​

  • raw. The function read the response as JSON (response.json(), jsonDecode) and failed, because a raw endpoint answers with text. It now returns the text (string, String).
  • table_format and bytea. The function read an HTML table or an Excel file as JSON, and bytes as text. It now returns the response itself (Response, http.Response), as functions of proxy endpoints do, so the caller reads it as text or as bytes.
  • Cache invalidation endpoints. The function was typed as the cached endpoint's response. It now returns { invalidated: boolean } (Map<String, dynamic> in Dart). It is also written to the same module as the function of the cached endpoint, and the other tsclient_... and dartclient_... annotations of that endpoint apply to it. Before, they did not, and the function went to the default module.
  • Uploads. The function of every upload endpoint was typed as a list of file descriptions (the upload metadata). That is right only when the routine returns the metadata, which is a routine that returns one json value. For any other routine the response is now any (dynamic in Dart).
  • Dart, void annotation. The function read a body from an endpoint that answers 204 without one. The TypeScript client was already correct.

MCP: outputSchema and structuredContent for four return shapes ​

  • A set with one named column (returns table (val text)): the schema said items are values, and they are objects ({"val": ...}).
  • single on a set with one named column: the row was wrapped as text ({"value": "{\"val\":\"a\"}"}). It is now the object itself ({"val": "a"}).
  • single on a set of values: a text value kept its JSON quotes ({"value": "\"a\""}). It is now the value ({"value": "a"}).
  • void annotation: the tool declared an outputSchema and returned no structuredContent. It now declares none.

Known limits ​

What a generator cannot know when the endpoints are built. None of these is new in this version.

  • Arrays of more than one dimension. The number of dimensions is not part of a PostgreSQL array type: int[] and int[][] are the same type. An array is described as one of a single dimension (number[], List<int>, {"type":"array","items":{"type":"integer"}}), also when its values are arrays themselves ([[1,2],[3,4]]). An array of a composite type with more than one dimension holds its values as text ("(1,a)"), not as objects.
  • json and jsonb. The value can be any JSON value, so it is described as any value (any, dynamic, {}), not as its actual shape.
  • NULL and missing rows. A single value that is NULL, and single with no row, are answered with an empty body, with null or with 204, depending on response_null_handling. The document describes the response with a value (and the 204, when it is configured). It does not mark values as nullable: the OpenAPI document has no nullability at all yet, for parameters or for responses.
  • Responses decided at request time. A content type or a table format taken from a parameter (Content-Type: {_type}, table_format = {_format}), the response of a proxied upstream service, and the body of a login (it depends on the authentication scheme) are described as any content (*/*), and the generated client functions for proxies and table formats return the response itself.
  • A text value declared as JSON. A routine that returns text on an endpoint with Content-Type: application/json is described as any JSON value. Whether the text is valid JSON is up to the routine.
  • Uploads in the generated clients. The upload function reads the response as JSON. A routine of an upload endpoint that returns plain text (returns text) is answered as text/plain, and the function fails to read it. Return json from such a routine.
  • Columns with the same name. A result with two columns of the same name is written as a JSON object with that key twice ({"value":1,"value":2}). The descriptions hold one property of that name. Give the columns different names.
  • money text depends on the database. See above: the same value is $1,234.50 in one database and 1.234,50 € in another.
  • Responses written by custom code. A response written by a CommandCallbackAsync or another extension point of the library is not known to the generators. They describe what the endpoint would answer with on its own.

For plugin authors ​

RoutineEndpoint.GetResponseKind(NpgsqlRestOptions?) returns what kind of response an endpoint gives (EndpointResponseKind: Routine, NoContent, RawText, Binary, TableFormat, Upstream, CacheInvalidation). The four generators above now use it instead of each deciding on its own, which is how they came to disagree. A custom IEndpointCreateHandler that describes responses should use it as well.

The cache invalidation endpoint of a cached endpoint now carries that endpoint's CustomParameters and Items, so a handler sees for it what it saw for the cached endpoint. A handler that registers something for each endpoint with its metadata (as the MCP plugin registers tools) should skip endpoints with InvalidateCache set.

Dependencies ​

Packages of the npgsqlrest client (the executable and its Docker images) were upgraded to their latest versions. The NpgsqlRest library and the plugins have no dependency changes.

PackageVersion
Serilog.Sinks.OpenTelemetry4.2.0 → 4.3.0
Microsoft.Extensions.Caching.Hybrid11.0.0 → 11.0.1

For builds of the client on .NET 10: Microsoft.Extensions.Caching.Hybrid 10.7.0 → 10.11.1, Microsoft.AspNetCore.Authentication.JwtBearer and Microsoft.Extensions.Caching.StackExchangeRedis 10.0.9 → 10.0.15.

In the test project: WireMock.Net 2.31.0 → 2.35.0, and Microsoft.AspNetCore.Mvc.Testing 10.0.9 → 10.0.15 for .NET 10. The whole test suite passes on .NET 11 and on .NET 10.

NuGet Package Upgrades ​

PackageVersion
NpgsqlRest4.1.0 → 4.1.1
NpgsqlRest.OpenApi1.4.0 → 1.4.1
NpgsqlRest.TsClient1.39.0 → 1.39.1
NpgsqlRest.DartClient1.2.0 → 1.2.1
NpgsqlRest.Mcp1.2.1 → 1.2.2

The other plugins are unchanged.

Comments