(from: any, jsonSchema: any, ast: AST.AST)
| 550 | } |
| 551 | |
| 552 | const mergeRefinements = (from: any, jsonSchema: any, ast: AST.AST): any => { |
| 553 | const out: any = { ...from, ...getJsonSchemaAnnotations(ast), ...jsonSchema } |
| 554 | out.allOf ??= [] |
| 555 | |
| 556 | const handle = (name: string, filter: (i: any) => boolean) => { |
| 557 | if (name in jsonSchema && name in from) { |
| 558 | out.allOf.unshift({ [name]: from[name] }) |
| 559 | out.allOf = out.allOf.filter(filter) |
| 560 | } |
| 561 | } |
| 562 | |
| 563 | handle("minLength", (i) => i.minLength > jsonSchema.minLength) |
| 564 | handle("maxLength", (i) => i.maxLength < jsonSchema.maxLength) |
| 565 | handle("pattern", (i) => i.pattern !== jsonSchema.pattern) |
| 566 | handle("minItems", (i) => i.minItems > jsonSchema.minItems) |
| 567 | handle("maxItems", (i) => i.maxItems < jsonSchema.maxItems) |
| 568 | handle("minimum", (i) => i.minimum > jsonSchema.minimum) |
| 569 | handle("maximum", (i) => i.maximum < jsonSchema.maximum) |
| 570 | handle("exclusiveMinimum", (i) => i.exclusiveMinimum > jsonSchema.exclusiveMinimum) |
| 571 | handle("exclusiveMaximum", (i) => i.exclusiveMaximum < jsonSchema.exclusiveMaximum) |
| 572 | handle("multipleOf", (i) => i.multipleOf !== jsonSchema.multipleOf) |
| 573 | |
| 574 | if (out.allOf.length === 0) { |
| 575 | delete out.allOf |
| 576 | } |
| 577 | return out |
| 578 | } |
| 579 | |
| 580 | type GoOptions = { |
| 581 | readonly getRef: (id: string) => string |
no test coverage detected