Releases: BitGo/api-ts
@api-ts/[email protected]
@api-ts/typed-express-router 1.1.14 (2025-07-18)
Dependencies
- @api-ts/superagent-wrapper: upgraded to 1.3.4
@api-ts/[email protected]
@api-ts/[email protected]
@api-ts/express-wrapper 1.0.34 (2025-07-18)
Dependencies
- @api-ts/typed-express-router: upgraded to 1.1.14
- @api-ts/superagent-wrapper: upgraded to 1.3.4
@api-ts/[email protected]
@api-ts/typed-express-router 2.0.0-beta.1 (2025-07-18)
Features
- opentelemetry: create otel instrumentation for typed-express-router (296a92e)
BREAKING CHANGES
- opentelemetry: To enforce stricter checks for http response sending types, there is now a check that the response is in a JSON format. This will make it more difficult to send a response or accidentally send a malformed response.
wrapRouter
modified to create decode and encode spans if@opentelemetry/api
is installed- if
@opentelemetry/api
is not installed, spans are not created
- if
onDecodeError
option removed. Please usedecodeErrorFormatter
andgetDecodeErrorStatusCode
decodeErrorFormatter
takes in an array ofValidationError
s and aWrappedRequest
, returning aJson
object.getDecodeErrorStatusCode
takes in an array ofValidationError
s and aWrappedRequest
, returning a number.
onEncodeError
option removed. Please useencodeErrorFormatter
andgetEncodeErrorStatusCode
encodeErrorFormatter
takes in an error and aWrappedRequest
, returning aJson
object.getEncodeErrorStatusCode
takes in an error and aWrappedRequest
, returning a number.
typed-express-router
now handles the sending of the http response when there is a decode or encode error
Consequently, to use createRouter
or wrapRouter
, instead of using onDecodeError
and onEncodeError
:
const router = createRouter(spec, {
onDecodeError: (errs, req, res) => {
const validationErrorMessage = /* use errs to craft an error message */;
res.status(400).json({ error: validationErrorMessage }).end();
},
onEncodeError: (err, req, res) => {
const encodeErrorMessage = /* use err to craft an error message */;
res.status(500).json({ error: encodeErrorMessage }).end();
},
});
We now use decodeErrorFormatter
, getDecodeErrorStatusCode
, encodeErrorFormatter
, and getEncodeErrorStatusCode
:
const router = createRouter(spec, {
decodeErrorFormatter: (errs, req) => {
const validationErrorMessage = /* use errs to craft an error message */;
return ({error: validationErrorMessage});
},
getDecodeErrorStatusCode: (errs, req) => {
return 400;
},
encodeErrorFormatter: (err, req) => {
const encodeErrorMessage = /* use err to craft an error message */;
return ({error: encodeErrorMessage});
},
getEncodeErrorStatusCode: (err, req) => {
return 500;
},
});
@api-ts/[email protected]
@api-ts/express-wrapper 2.0.0-beta.1 (2025-07-18)
Features
- opentelemetry: create otel instrumentation for typed-express-router (296a92e)
BREAKING CHANGES
- opentelemetry:
onDecodeError
andonEncodeError
have been removed. Please usedecodeErrorFormatter
,getDecodeErrorStatusCode
,encodeErrorFormatter
, andgetEncodeErrorStatusCode
Dependencies
- @api-ts/typed-express-router: upgraded to 2.0.0-beta.1
@api-ts/[email protected]
@api-ts/openapi-generator 5.7.0 (2025-03-05)
Features
-
Output boolean query parameters as booleans instead of string enums (#1017)
This feature update changes how boolean parameters are represented in the OpenAPI specification generated by api-ts. Previously, boolean values in query parameters were represented as string enums with values "true" and "false". With this change, they are now represented as native OpenAPI boolean types.
Concretely, this httpRoute:
import * as t from 'io-ts'; import * as h from '@api-ts/io-ts-http'; import { BooleanFromString } from 'io-ts-types'; export const route = h.httpRoute({ path: '/resources', method: 'GET', request: h.httpRequest({ query: { // Boolean parameters isActive: BooleanFromString, includeDeleted: BooleanFromString, // Mixed boolean/number union filterOption: t.union([BooleanFromString, t.number]) } }), response: { 200: t.type({ results: t.array(t.string), pagination: t.type({ hasMore: t.boolean }) }) } });
now generates the following OpenAPI specification:
{ "openapi": "3.0.3", "paths": { "/resources": { "get": { "parameters": [ { "name": "isActive", "in": "query", "required": true, "schema": { - "type": "string", - "enum": ["true", "false"] + "type": "boolean" } }, { "name": "includeDeleted", "in": "query", "required": true, "schema": { - "type": "string", - "enum": ["true", "false"] + "type": "boolean" } }, { "name": "filterOption", "in": "query", "required": true, "schema": { "oneOf": [ - { "type": "string", "enum": ["true", "false"] }, + { "type": "boolean" }, { "type": "number" } ] } } ], "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "type": "object", "properties": { "results": { "type": "array", "items": { "type": "string" } }, "pagination": { "type": "object", "properties": { "hasMore": { "type": "boolean" } }, "required": ["hasMore"] } }, "required": ["results", "pagination"] } } } } } } } } }
This update aligns with OpenAPI best practices by using native types rather than string-based enumerations for boolean query parameters in API specifications.