MCPcopy Create free account
hub / github.com/goadesign/goa / toSchemaHrefs

Function toSchemaHrefs

http/codegen/openapi/json_schema.go:568–581  ·  view source on GitHub ↗

toSchemaHrefs produces hrefs that replace the path wildcards with JSON schema references when appropriate.

(r *expr.RouteExpr)

Source from the content-addressed store, hash-verified

566// toSchemaHrefs produces hrefs that replace the path wildcards with JSON
567// schema references when appropriate.
568func 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.

Callers 1

Calls 2

ExtractHTTPWildcardsFunction · 0.92
FullPathsMethod · 0.45

Tested by

no test coverage detected