Generate format byte as string instead of Blob

Closed
DM
12d ago
+182-30

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: byte maps to string again, as in 13.4.x and earlier.
  • src/schema-routes/schema-routes.ts: the binary-produces response alias (c4b02db) got its
    Blob type from a synthetic { type: "string", format: "byte" } schema, so changing the
    mapping alone would have turned those aliases into string. It now uses format: "binary"
    and sets the alias content to Blob directly. Binary downloads are still typed as Blob.
    Only their JSDoc changes, from @format byte to @format binary, which describes them
    more accurately.

Verification

  • New regression test tests/spec/issue-1841: a JSON body with rowVersion: format byte
    generates rowVersion: string, and format: binary still generates File. It fails
    without this change.
  • Updated snapshots in binary-produces, binary-produces-base-path and
    binary-produces-base-path-with-extracts. format: byte properties change from Blob to
    string, GetXxxExportData aliases stay Blob, 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 as Blob, now built from a format: binary schema with the alias content set directly; their JSDoc changes from @format byte to @format binary.
  • Adds a regression test covering format: byte → string and format: binary → File, and updates affected snapshots.