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

Function Files

http/codegen/openapi/v3/files.go:15–40  ·  view source on GitHub ↗

Files returns the OpenAPI v3 specification files in JSON and YAML formats.

(root *expr.RootExpr)

Source from the content-addressed store, hash-verified

13
14// Files returns the OpenAPI v3 specification files in JSON and YAML formats.
15func Files(root *expr.RootExpr) ([]*codegen.File, error) {
16 spec := New(root)
17 jsonSection := &codegen.SectionTemplate{
18 Name: "openapi_v3",
19 FuncMap: template.FuncMap{"toJSON": toJSON(root.API.Meta)},
20 Source: "{{ toJSON .}}",
21 Data: spec,
22 }
23 yamlSection := &codegen.SectionTemplate{
24 Name: "openapi_v3",
25 FuncMap: template.FuncMap{"toYAML": toYAML},
26 Source: "{{ toYAML .}}",
27 Data: spec,
28 }
29
30 return []*codegen.File{
31 {
32 Path: filepath.Join(codegen.Gendir, "http", "openapi3.json"),
33 SectionTemplates: []*codegen.SectionTemplate{jsonSection},
34 },
35 {
36 Path: filepath.Join(codegen.Gendir, "http", "openapi3.yaml"),
37 SectionTemplates: []*codegen.SectionTemplate{yamlSection},
38 },
39 }, nil
40}
41
42func toJSON(meta expr.MetaExpr) func(any) string {
43 prefix, p := meta.Last("openapi:json:prefix")

Callers

nothing calls this directly

Calls 2

NewFunction · 0.70
toJSONFunction · 0.70

Tested by

no test coverage detected