valueWithPropagatedRef returns a copy of ref's schema with its Properties refs rewritten when ref itself is external, and with extensions placed next to the $ref folded in (ref-side wins over value-side). This is what allows allOf members to carry per-use sibling directives without mutating the refe
(ref *openapi3.SchemaRef)
| 155 | // allows allOf members to carry per-use sibling directives without |
| 156 | // mutating the referenced schema. |
| 157 | func valueWithPropagatedRef(ref *openapi3.SchemaRef) (openapi3.Schema, error) { |
| 158 | schema := *ref.Value |
| 159 | schema.Extensions = combinedSchemaExtensions(ref) |
| 160 | |
| 161 | if len(ref.Ref) == 0 || ref.Ref[0] == '#' { |
| 162 | return schema, nil |
| 163 | } |
| 164 | |
| 165 | pathParts := strings.Split(ref.Ref, "#") |
| 166 | if len(pathParts) < 1 || len(pathParts) > 2 { |
| 167 | return openapi3.Schema{}, fmt.Errorf("unsupported reference: %s", ref.Ref) |
| 168 | } |
| 169 | remoteComponent := pathParts[0] |
| 170 | |
| 171 | propagateRemoteRefs(remoteComponent, &schema) |
| 172 | |
| 173 | return schema, nil |
| 174 | } |
| 175 | |
| 176 | // propagateRemoteRefs rewrites local "#/..." refs within a schema to be |
| 177 | // qualified with the remote component path. This is needed so that when an |
no test coverage detected