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

Function toJSON

http/codegen/openapi/v3/files.go:42–58  ·  view source on GitHub ↗
(meta expr.MetaExpr)

Source from the content-addressed store, hash-verified

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