| 393 | } |
| 394 | |
| 395 | const extractPayloads = (topAst: AST.AST): ReadonlyMap<string, { |
| 396 | readonly encoding: HttpApiSchema.Encoding |
| 397 | readonly ast: AST.AST |
| 398 | }> => { |
| 399 | const members = new Map<string, { |
| 400 | encoding: HttpApiSchema.Encoding |
| 401 | ast: AST.AST |
| 402 | }>() |
| 403 | function process(ast: AST.AST) { |
| 404 | if (ast._tag === "NeverKeyword") { |
| 405 | return |
| 406 | } |
| 407 | ast = AST.annotations(ast, { |
| 408 | ...HttpApiSchema.extractAnnotations(topAst.annotations), |
| 409 | ...ast.annotations |
| 410 | }) |
| 411 | const encoding = HttpApiSchema.getEncoding(ast) |
| 412 | const contentType = HttpApiSchema.getMultipart(ast) || HttpApiSchema.getMultipartStream(ast) |
| 413 | ? "multipart/form-data" |
| 414 | : encoding.contentType |
| 415 | const current = members.get(contentType) |
| 416 | if (current === undefined) { |
| 417 | members.set(contentType, { |
| 418 | encoding, |
| 419 | ast |
| 420 | }) |
| 421 | } else { |
| 422 | current.ast = AST.Union.make([current.ast, ast]) |
| 423 | } |
| 424 | } |
| 425 | if (topAst._tag === "Union") { |
| 426 | for (const type of topAst.types) { |
| 427 | process(type) |
| 428 | } |
| 429 | } else { |
| 430 | process(topAst) |
| 431 | } |
| 432 | return members |
| 433 | } |
| 434 | |
| 435 | const getDescriptionOrIdentifier = (ast: AST.PropertySignature | AST.AST): Option.Option<string> => { |
| 436 | const annotations = "to" in ast ? |