Skip to content

Commit 020480e

Browse files
committed
refactor(generator): remove getBodyType from public exports
1 parent 75462a7 commit 020480e

File tree

3 files changed

+3
-95
lines changed

3 files changed

+3
-95
lines changed

packages/generator/src/__tests__/create-url-map.test.ts

Lines changed: 2 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { describe, expect, test } from 'bun:test'
33
import type { UrlMapValue } from '@devup-api/core'
44
import type { OpenAPIV3_1 } from 'openapi-types'
5-
import { createUrlMap, getBodyType } from '../create-url-map'
5+
import { createUrlMap } from '../create-url-map'
66

77
test.each([
88
[
@@ -605,95 +605,4 @@ describe('bodyType emission', () => {
605605
})
606606
})
607607

608-
describe('getBodyType', () => {
609-
const emptyDoc: OpenAPIV3_1.Document = {
610-
openapi: '3.1.0',
611-
info: { title: 'Test', version: '1.0.0' },
612-
paths: {},
613-
}
614-
615-
test('returns undefined when no requestBody', () => {
616-
expect(getBodyType({ responses: {} }, emptyDoc)).toBeUndefined()
617-
})
618-
619-
test('returns undefined for JSON content', () => {
620-
expect(
621-
getBodyType(
622-
{
623-
requestBody: {
624-
content: {
625-
'application/json': { schema: { type: 'object' } },
626-
},
627-
},
628-
responses: {},
629-
},
630-
emptyDoc,
631-
),
632-
).toBeUndefined()
633-
})
634-
635-
test('returns form for urlencoded content', () => {
636-
expect(
637-
getBodyType(
638-
{
639-
requestBody: {
640-
content: {
641-
'application/x-www-form-urlencoded': {
642-
schema: { type: 'object' },
643-
},
644-
},
645-
},
646-
responses: {},
647-
},
648-
emptyDoc,
649-
),
650-
).toBe('form')
651-
})
652-
653-
test('returns multipart for multipart/form-data content', () => {
654-
expect(
655-
getBodyType(
656-
{
657-
requestBody: {
658-
content: {
659-
'multipart/form-data': { schema: { type: 'object' } },
660-
},
661-
},
662-
responses: {},
663-
},
664-
emptyDoc,
665-
),
666-
).toBe('multipart')
667-
})
668-
669-
test('returns undefined when requestBody has no content', () => {
670-
expect(
671-
getBodyType(
672-
{
673-
requestBody: { content: {} },
674-
responses: {},
675-
},
676-
emptyDoc,
677-
),
678-
).toBeUndefined()
679-
})
680-
681-
test('prefers urlencoded over multipart when both present', () => {
682-
expect(
683-
getBodyType(
684-
{
685-
requestBody: {
686-
content: {
687-
'application/x-www-form-urlencoded': {
688-
schema: { type: 'object' },
689-
},
690-
'multipart/form-data': { schema: { type: 'object' } },
691-
},
692-
},
693-
responses: {},
694-
},
695-
emptyDoc,
696-
),
697-
).toBe('form')
698-
})
699-
})
608+
// getBodyType is now internal (not exported) — tested indirectly through createUrlMap tests above

packages/generator/src/__tests__/index.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ test('index.ts exports', () => {
55
expect({ ...indexModule }).toEqual({
66
// URL map
77
createUrlMap: expect.any(Function),
8-
getBodyType: expect.any(Function),
98
// Interface generation
109
generateInterface: expect.any(Function),
1110
// Zod generation

packages/generator/src/create-url-map.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { OpenAPIV3_1 } from 'openapi-types'
33
import { convertCase } from './convert-case'
44
import { resolveRef } from './openapi-utils'
55

6-
export function getBodyType(
6+
function getBodyType(
77
operation: OpenAPIV3_1.OperationObject,
88
document: OpenAPIV3_1.Document,
99
): 'form' | 'multipart' | undefined {

0 commit comments

Comments
 (0)