MCPcopy Index your code
hub / github.com/getkin/kin-openapi / LoadFromData

Method LoadFromData

openapi3/loader.go:169–179  ·  view source on GitHub ↗

LoadFromData loads a spec from a byte array

(data []byte)

Source from the content-addressed store, hash-verified

167
168// LoadFromData loads a spec from a byte array
169func (loader *Loader) LoadFromData(data []byte) (*T, error) {
170 loader.resetVisitedPathItemRefs()
171 doc := &T{}
172 if err := unmarshal(data, doc, loader.IncludeOrigin, nil); err != nil {
173 return nil, err
174 }
175 if err := loader.ResolveRefsIn(doc, nil); err != nil {
176 return nil, err
177 }
178 return doc, nil
179}
180
181// LoadFromDataWithPath takes the OpenAPI document data in bytes and a path where the resolver can find referred
182// elements and returns a *T with all resolved data or an error if unable to load data or resolve refs.

Calls 3

ResolveRefsInMethod · 0.95
unmarshalFunction · 0.70