Generate format byte as string instead of Blob
Fixes #1841
Problem
Since 13.5.0 (1ed598b), type: string, format: byte is generated as Blob.
In OpenAPI, byte means base64-encoded characters, and raw bytes are format: binary (OpenAPI 3.0 Data Types).
In a JSON body these values are plain strings. For example, ASP.NET serialises byte[] properties such as concurrency tokens (rowVersion) as base64 strings. With Blob, the generated type no longer matches the runtime value, so a value read from one response can't be sent back in the next request without a cast.
Solution
src/configuration.ts:bytemaps tostringagain, as in 13.4.x and earlier.src/schema-routes/schema-routes.ts: the binary-produces response alias (c4b02db) got its
Blobtype from a synthetic{ type: "string", format: "byte" }schema, so changing the
mapping alone would have turned those aliases intostring. It now usesformat: "binary"
and sets the alias content toBlobdirectly. Binary downloads are still typed asBlob.
Only their JSDoc changes, from@format byteto@format binary, which describes them
more accurately.
Verification
- New regression test
tests/spec/issue-1841: a JSON body withrowVersion: format byte
generatesrowVersion: string, andformat: binarystill generatesFile. It fails
without this change. - Updated snapshots in
binary-produces,binary-produces-base-pathand
binary-produces-base-path-with-extracts.format: byteproperties change fromBlobto
string,GetXxxExportDataaliases stayBlob, and route return types are unchanged. - Changeset added (patch).
Summary by cubic
Fixes #1841. Since 13.5.0, format: byte was generated as Blob, but per the OpenAPI spec it is base64-encoded text carried as a JSON string; raw bytes are format: binary. Properties like ASP.NET byte[] concurrency tokens are now generated as string again, matching the runtime value so they can be sent back in a request without a cast.
- Binary download response aliases (e.g.,
GetXxxExportData) stay typed asBlob, now built from aformat: binaryschema with the alias content set directly; their JSDoc changes from@format byteto@format binary. - Adds a regression test covering
format: byte→stringandformat: binary→File, and updates affected snapshots.