Skip to content

Commit

Permalink
fix(request-body): return undefined when not giving schema
Browse files Browse the repository at this point in the history
  • Loading branch information
moontai0724 committed May 22, 2024
1 parent ec26f34 commit 3a0f5c6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
5 changes: 1 addition & 4 deletions src/transformers/request-body/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ export function transformRequestBody(
schema?: SchemaObject,
options: TransformRequestBodyOptions = {},
) {
if (!schema)
return {
content: {},
};
if (!schema) return undefined;

const { description, ...remains } = schema;
const {
Expand Down
9 changes: 2 additions & 7 deletions src/transformers/request-body/none.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import type { RequestBodyObject } from "@moontai0724/openapi-types";
import { expect, it } from "vitest";

import { transformRequestBody } from ".";

const expected: RequestBodyObject = {
content: {},
};

it("should be able to transform without a schema", () => {
expect(transformRequestBody(undefined)).toEqual(expected);
it("should return undefined when transform without a schema", () => {
expect(transformRequestBody(undefined)).toEqual(undefined);
});

0 comments on commit 3a0f5c6

Please sign in to comment.