MCPcopy Index your code
hub / github.com/oapi-codegen/oapi-codegen / walkSchemaRef

Function walkSchemaRef

pkg/codegen/prune.go:105–144  ·  view source on GitHub ↗
(ref *openapi3.SchemaRef, doFn func(RefWrapper) (bool, error))

Source from the content-addressed store, hash-verified

103}
104
105func walkSchemaRef(ref *openapi3.SchemaRef, doFn func(RefWrapper) (bool, error)) error {
106 // Not a valid ref, ignore it and continue
107 if ref == nil {
108 return nil
109 }
110 refWrapper := RefWrapper{Ref: ref.Ref, HasValue: ref.Value != nil, SourceRef: ref}
111 shouldContinue, err := doFn(refWrapper)
112 if err != nil {
113 return err
114 }
115 if !shouldContinue {
116 return nil
117 }
118 if ref.Value == nil {
119 return nil
120 }
121
122 for _, ref := range ref.Value.OneOf {
123 _ = walkSchemaRef(ref, doFn)
124 }
125
126 for _, ref := range ref.Value.AnyOf {
127 _ = walkSchemaRef(ref, doFn)
128 }
129
130 for _, ref := range ref.Value.AllOf {
131 _ = walkSchemaRef(ref, doFn)
132 }
133
134 _ = walkSchemaRef(ref.Value.Not, doFn)
135 _ = walkSchemaRef(ref.Value.Items, doFn)
136
137 for _, ref := range ref.Value.Properties {
138 _ = walkSchemaRef(ref, doFn)
139 }
140
141 _ = walkSchemaRef(ref.Value.AdditionalProperties.Schema, doFn)
142
143 return nil
144}
145
146func walkParameterRef(ref *openapi3.ParameterRef, doFn func(RefWrapper) (bool, error)) error {
147 // Not a valid ref, ignore it and continue

Callers 5

walkComponentsFunction · 0.85
walkParameterRefFunction · 0.85
walkRequestBodyRefFunction · 0.85
walkResponseRefFunction · 0.85
walkHeaderRefFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected