@@ -4,6 +4,7 @@ import type { CreateAppOptions } from "./app";
44import type { StandardSchemaV1 } from "@standard-schema/spec" ;
55import { getHttpStatusName } from "./status" ;
66import { ErrorResponseJsonSchema , type ZetaSchema } from "./custom-responses" ;
7+ import { getMeta } from "./meta" ;
78
89export function buildOpenApiDocs (
910 options : CreateAppOptions < any > | undefined ,
@@ -45,7 +46,7 @@ export function buildOpenApiDocs(
4546 requestBody : body
4647 ? {
4748 content : {
48- [ adapter . getMeta ( body ) ?. contentType ?? "application/json" ] : {
49+ [ getMeta ( adapter , body ) ?. contentType ?? "application/json" ] : {
4950 schema : adapter . toJsonSchema ( body ) ,
5051 } ,
5152 } ,
@@ -151,16 +152,18 @@ function buildResponse(
151152 schema : StandardSchemaV1 | ZetaSchema ,
152153 adapter : SchemaAdapter ,
153154) : NonNullable < OpenAPI . Operation [ "responses" ] > [ string ] {
155+ const meta = getMeta ( adapter , schema ) ;
156+
154157 if ( "~zeta" in schema ) {
155158 const description =
156- schema [ "~zeta" ] . meta ?. responseDescription ??
157- getHttpStatusName ( status ) ??
158- "" ;
159+ meta ?. responseDescription ?? getHttpStatusName ( status ) ?? "" ;
160+
159161 if ( schema [ "~zeta" ] . type === "NoResponse" ) {
160162 return {
161163 description,
162164 } ;
163165 }
166+
164167 if ( schema [ "~zeta" ] . type === "ErrorResponse" ) {
165168 return {
166169 description,
@@ -175,7 +178,6 @@ function buildResponse(
175178 }
176179 }
177180
178- const meta = adapter . getMeta ( schema ) ;
179181 return {
180182 description : meta ?. responseDescription ?? getHttpStatusName ( status ) ,
181183 content : {
0 commit comments