Skip to content

Commit df75b15

Browse files
committed
Merge branch 'master' into make-v24
2 parents daa87c2 + 6746a94 commit df75b15

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

express-zod-api/src/documentation-helpers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import {
4141
import { InputSource } from "./config-type";
4242
import { ezDateInBrand } from "./date-in-schema";
4343
import { ezDateOutBrand } from "./date-out-schema";
44-
import { hasRaw } from "./deep-checks";
44+
import { contentTypes } from "./content-type";
4545
import { DocumentationError } from "./errors";
4646
import { ezFileBrand } from "./file-schema";
4747
import { extractObjectSchema, IOSchema } from "./io-schema";
@@ -729,7 +729,7 @@ export const depictBody = ({
729729
description,
730730
content: { [mimeType]: media },
731731
};
732-
if (hasRequired || hasRaw(schema)) body.required = true;
732+
if (hasRequired || mimeType === contentTypes.raw) body.required = true;
733733
return body;
734734
};
735735

express-zod-api/tests/documentation-helpers.spec.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { JSONSchema } from "@zod/core";
22
import { SchemaObject } from "openapi3-ts/oas31";
33
import * as R from "ramda";
44
import { z } from "zod";
5+
import { ez } from "../src";
56
import {
67
OpenAPIContext,
78
depictExamples,
@@ -27,6 +28,7 @@ import {
2728
depictPipeline,
2829
depictDateIn,
2930
depictDateOut,
31+
depictBody,
3032
} from "../src/documentation-helpers";
3133

3234
describe("Documentation helpers", () => {
@@ -502,6 +504,19 @@ describe("Documentation helpers", () => {
502504
});
503505
});
504506

507+
describe("depictBody", () => {
508+
test("should mark ez.raw() body as required", () => {
509+
const body = depictBody({
510+
...requestCtx,
511+
schema: ez.raw(),
512+
composition: "inline",
513+
mimeType: "application/octet-stream", // raw content type
514+
paramNames: [],
515+
});
516+
expect(body.required).toBe(true);
517+
});
518+
});
519+
505520
describe("depictDateIn", () => {
506521
test("should set type:string, pattern and format", () => {
507522
expect(

0 commit comments

Comments
 (0)