toSchemaHrefs produces hrefs that replace the path wildcards with JSON schema references when appropriate.
(r *expr.RouteExpr)
| 566 | // toSchemaHrefs produces hrefs that replace the path wildcards with JSON |
| 567 | // schema references when appropriate. |
| 568 | func toSchemaHrefs(r *expr.RouteExpr) []string { |
| 569 | paths := r.FullPaths() |
| 570 | res := make([]string, len(paths)) |
| 571 | for i, path := range paths { |
| 572 | params := expr.ExtractHTTPWildcards(path) |
| 573 | args := make([]any, len(params)) |
| 574 | for j, p := range params { |
| 575 | args[j] = fmt.Sprintf("/{%s}", p) |
| 576 | } |
| 577 | tmpl := expr.HTTPWildcardRegex.ReplaceAllLiteralString(path, "%s") |
| 578 | res[i] = fmt.Sprintf(tmpl, args...) |
| 579 | } |
| 580 | return res |
| 581 | } |
| 582 | |
| 583 | // propertiesFromDefs creates a Properties map referencing the given definitions |
| 584 | // under the given path. |
no test coverage detected