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

Function toJSON

http/codegen/openapi/v2/files.go:44–60  ·  view source on GitHub ↗
(meta expr.MetaExpr)

Source from the content-addressed store, hash-verified

42}
43
44func toJSON(meta expr.MetaExpr) func(any) string {
45 prefix, p := meta.Last("openapi:json:prefix")
46 indent, i := meta.Last("openapi:json:indent")
47 marshal := json.Marshal
48 if p || i {
49 marshal = func(v any) ([]byte, error) {
50 return json.MarshalIndent(v, prefix, indent)
51 }
52 }
53 return func(d any) string {
54 b, err := marshal(d)
55 if err != nil {
56 panic("openapi: " + err.Error()) // bug
57 }
58 return string(b)
59 }
60}
61
62func toYAML(d any) string {
63 b, err := yaml.Marshal(d)

Callers 1

FilesFunction · 0.70

Calls 3

marshalFunction · 0.85
LastMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected