( t *testing.T, build func(*expr.RootExpr) ([]*codegen.File, error), root *expr.RootExpr, )
| 104 | } |
| 105 | |
| 106 | func renderOpenAPIJSON( |
| 107 | t *testing.T, |
| 108 | build func(*expr.RootExpr) ([]*codegen.File, error), |
| 109 | root *expr.RootExpr, |
| 110 | ) []byte { |
| 111 | t.Helper() |
| 112 | |
| 113 | files, err := build(root) |
| 114 | require.NoError(t, err) |
| 115 | for _, f := range files { |
| 116 | if filepath.Ext(f.Path) != ".json" { |
| 117 | continue |
| 118 | } |
| 119 | require.Len(t, f.SectionTemplates, 1) |
| 120 | section := f.SectionTemplates[0] |
| 121 | require.NotEmpty(t, section.Source) |
| 122 | require.NotNil(t, section.Data) |
| 123 | |
| 124 | var buf bytes.Buffer |
| 125 | tmpl := template.Must(template.New("openapi").Funcs(section.FuncMap).Parse(section.Source)) |
| 126 | require.NoError(t, tmpl.Execute(&buf, section.Data)) |
| 127 | return buf.Bytes() |
| 128 | } |
| 129 | |
| 130 | t.Fatalf("no JSON OpenAPI file generated") |
| 131 | return nil |
| 132 | } |
| 133 | |
| 134 | var cookieAPIKeySecurityDSL = func() { |
| 135 | var browserSessionCookie = dsl.APIKeySecurity("browser_session_cookie", func() { |
no test coverage detected