MCPcopy Create free account
hub / github.com/Effect-TS/effect / addContent

Function addContent

packages/effect/src/unstable/httpapi/OpenApi.ts:782–819  ·  view source on GitHub ↗
(
    schema: Schema.Constraint,
    status: number,
    encoding: HttpApiSchema.Encoding,
    description: string | undefined
  )

Source from the content-addressed store, hash-verified

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,

Callers 1

processFunction · 0.85

Calls 3

getMethod · 0.65
setMethod · 0.65
addMethod · 0.65

Tested by

no test coverage detected