8000 chore!: Generalize the `getResponseContentType` adapter method to `ge… · aklinker1/zeta@246519b · GitHub
[go: up one dir, main page]

Skip to content

Commit 246519b

Browse files
committed
chore!: Generalize the getResponseContentType adapter method to getMeta
1 parent b63e137 commit 246519b

3 files changed

Lines changed: 6 additions & 7 deletions

File tree

‎src/adapters/zod-schema-adapter.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export const zodSchemaAdapter: SchemaAdapter = {
4040
}),
4141
);
4242
},
43-
getResponseContentType: (schema: any) => {
43+
getMeta: (schema: any) => {
4444
const meta = z.globalRegistry.get(schema);
4545
return meta?.contentType ?? meta?.["content-type"];
4646
},

‎src/open-api.ts‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,9 @@ export function buildOpenApiDocs(
6262
requestBody: body
6363
? {
6464
content: {
65-
[adapter.getResponseContentType(body) ?? "application/json"]:
66-
{
67-
schema: adapter.toJsonSchema(body),
68-
},
65+
[adapter.getMeta(body)?.contentType ?? "application/json"]: {
66+
schema: adapter.toJsonSchema(body),
67+
},
6968
},
7069
}
7170
: undefined,
@@ -79,7 +78,7 @@ export function buildOpenApiDocs(
7978
200: {
8079
description: "OK",
8180
content: {
82-
[adapter.getResponseContentType(response) ??
81+
[adapter.getMeta(response)?.contentType ??
8382
"application/json"]: {
8483
schema: adapter.toJsonSchema(response),
8584
},

‎src/types.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,7 @@ export interface SchemaAdapter {
956956
schema: StandardSchemaV1;
957957
description?: string;
958958
}>;
959-
getResponseContentType: (schema: StandardSchemaV1) => string | undefined;
959+
getMeta: (schema: StandardSchemaV1) => Record<string, any> | undefined;
960960
}
961961

962962
//

0 commit comments

Comments
 (0)
0