(allOf []*openapi3.SchemaRef, seenSchemaRef map[string]bool)
| 224 | } |
| 225 | |
| 226 | func mergeAllOf(allOf []*openapi3.SchemaRef, seenSchemaRef map[string]bool) (openapi3.Schema, error) { |
| 227 | var schema openapi3.Schema |
| 228 | for _, schemaRef := range allOf { |
| 229 | var err error |
| 230 | if schemaRef.Ref != "" && seenSchemaRef[schemaRef.Ref] { |
| 231 | continue |
| 232 | } |
| 233 | if schemaRef.Ref != "" { |
| 234 | seenSchemaRef[schemaRef.Ref] = true |
| 235 | } |
| 236 | // Use valueWithPropagatedRef so sibling extensions on a $ref |
| 237 | // member of a transitively-flattened allOf reach the merged |
| 238 | // schema, matching mergeSchemas' top-level handling. |
| 239 | member, err := valueWithPropagatedRef(schemaRef) |
| 240 | if err != nil { |
| 241 | return openapi3.Schema{}, err |
| 242 | } |
| 243 | schema, err = mergeOpenapiSchemas(schema, member, true, seenSchemaRef) |
| 244 | if err != nil { |
| 245 | return openapi3.Schema{}, fmt.Errorf("error merging schemas for AllOf: %w", err) |
| 246 | } |
| 247 | } |
| 248 | return schema, nil |
| 249 | } |
| 250 | |
| 251 | // mergeOpenapiSchemas merges two openAPI schemas and returns the schema |
| 252 | // all of whose fields are composed. |
no test coverage detected