MCPcopy Index your code
hub / github.com/APIParkLab/APIPark / recurseSchemaRef

Function recurseSchemaRef

mcp-server/openapi.go:119–152  ·  view source on GitHub ↗
(ref *openapi3.SchemaRef)

Source from the content-addressed store, hash-verified

117}
118
119func recurseSchemaRef(ref *openapi3.SchemaRef) (map[string]interface{}, error) {
120 if ref == nil || ref.Value == nil {
121 return nil, nil
122 }
123 data, err := json.Marshal(ref.Value)
124 if err != nil {
125 return nil, err
126 }
127 m := make(map[string]interface{})
128 err = json.Unmarshal(data, &m)
129 if err != nil {
130 return nil, err
131 }
132
133 if ref.Value.Properties != nil {
134 m["properties"] = make(map[string]interface{})
135 for k, v := range ref.Value.Properties {
136 v, err := recurseSchemaRef(v)
137 if err != nil {
138 return nil, err
139 }
140 m["properties"].(map[string]interface{})[k] = v
141 }
142 }
143 if ref.Value.Items != nil {
144 v, err := recurseSchemaRef(ref.Value.Items)
145 if err != nil {
146 return nil, err
147 }
148 m["items"] = v
149 }
150
151 return m, nil
152}

Callers 1

genAPIFunction · 0.85

Calls 1

MarshalMethod · 0.80

Tested by

no test coverage detected