| 780 | } |
| 781 | |
| 782 | function addContent( |
| 783 | schema: Schema.Constraint, |
| 784 | status: number, |
| 785 | encoding: HttpApiSchema.Encoding, |
| 786 | description: string | undefined |
| 787 | ) { |
| 788 | const statusMap = map.get(status) |
| 789 | const { _tag, contentType } = encoding |
| 790 | if (statusMap === undefined) { |
| 791 | map.set(status, { |
| 792 | descriptions: new Set(description !== undefined ? [description] : []), |
| 793 | content: new Map([[_tag, new Map([[contentType, new Set([schema])]])]]), |
| 794 | headers: [], |
| 795 | streamContent: undefined |
| 796 | }) |
| 797 | } else { |
| 798 | // concat descriptions |
| 799 | if (description !== undefined) { |
| 800 | statusMap.descriptions.add(description) |
| 801 | } |
| 802 | |
| 803 | if (statusMap.content === undefined) { |
| 804 | statusMap.content = new Map([[_tag, new Map([[contentType, new Set([schema])]])]]) |
| 805 | } else { |
| 806 | const schemasByContentType = statusMap.content.get(_tag) |
| 807 | if (schemasByContentType === undefined) { |
| 808 | statusMap.content.set(_tag, new Map([[contentType, new Set([schema])]])) |
| 809 | } else { |
| 810 | const set = schemasByContentType.get(contentType) |
| 811 | if (set === undefined) { |
| 812 | schemasByContentType.set(contentType, new Set([schema])) |
| 813 | } else { |
| 814 | set.add(schema) |
| 815 | } |
| 816 | } |
| 817 | } |
| 818 | } |
| 819 | } |
| 820 | |
| 821 | function addStreamContent( |
| 822 | stream: HttpApiSchema.StreamSchema, |