(t *testing.T)
| 19 | ) |
| 20 | |
| 21 | func TestFiles(t *testing.T) { |
| 22 | var ( |
| 23 | goldenPath = filepath.Join("testdata", "golden") |
| 24 | ) |
| 25 | cases := []struct { |
| 26 | Name string |
| 27 | DSL func() |
| 28 | }{ |
| 29 | // TestSections |
| 30 | {"file-service", testdata.FileServiceDSL}, |
| 31 | {"file-service-swagger", testdata.FileServiceSwaggerDSL}, |
| 32 | {"file-service-wildcard", testdata.FileServiceWildcardDSL}, |
| 33 | {"valid", testdata.SimpleDSL}, |
| 34 | {"multiple-services", testdata.MultipleServicesDSL}, |
| 35 | {"multiple-views", testdata.MultipleViewsDSL}, |
| 36 | {"explicit-view", testdata.ExplicitViewDSL}, |
| 37 | {"security", testdata.SecurityDSL}, |
| 38 | {"bearer-security", testdata.BearerSecurityDSL}, |
| 39 | {"server-host-with-variables", testdata.ServerHostWithVariablesDSL}, |
| 40 | {"with-spaces", testdata.WithSpacesDSL}, |
| 41 | {"with-map", testdata.WithMapDSL}, |
| 42 | {"with-any", testdata.WithAnyDSL}, |
| 43 | {"path-with-wildcards", testdata.PathWithWildcardDSL}, |
| 44 | {"path-with-multiple-wildcards", testdata.PathWithMultipleWildcardDSL}, |
| 45 | {"path-with-multiple-explicit-wildcards", testdata.PathWithMultipleExplicitWildcardDSL}, |
| 46 | {"headers", testdata.HeadersDSL}, |
| 47 | {"with-tags", testdata.WithTagsDSL}, |
| 48 | {"with-tags-swagger", testdata.WithTagsSwaggerDSL}, |
| 49 | {"typename", testdata.TypenameDSL}, |
| 50 | {"not-generate-server", testdata.NotGenerateServerDSL}, |
| 51 | {"not-generate-host", testdata.NotGenerateHostDSL}, |
| 52 | {"not-generate-attribute", testdata.NotGenerateAttributeDSL}, |
| 53 | {"json-prefix", testdata.JSONPrefixDSL}, |
| 54 | {"json-indent", testdata.JSONIndentDSL}, |
| 55 | {"json-prefix-indent", testdata.JSONPrefixIndentDSL}, |
| 56 | // TestEndpoints |
| 57 | {"endpoint", testdata.ExtensionDSL}, |
| 58 | {"endpoint-swagger", testdata.ExtensionSwaggerDSL}, |
| 59 | {"skip-response-body-encode-decode", testdata.SkipResponseBodyEncodeDecodeDSL}, |
| 60 | // TestValidations |
| 61 | {"string", testdata.StringValidationDSL}, |
| 62 | {"integer", testdata.IntValidationDSL}, |
| 63 | {"array", testdata.ArrayValidationDSL}, |
| 64 | // Error examples |
| 65 | {"error-examples", testdata.ErrorExamplesDSL}, |
| 66 | } |
| 67 | for _, c := range cases { |
| 68 | t.Run(c.Name, func(t *testing.T) { |
| 69 | // Reset global variables |
| 70 | openapi.Definitions = make(map[string]*openapi.Schema) |
| 71 | root := httpgen.RunHTTPDSL(t, c.DSL) |
| 72 | oFiles, err := openapiv3.Files(root) |
| 73 | if err != nil { |
| 74 | t.Fatalf("OpenAPI failed with %s", err) |
| 75 | } |
| 76 | for i, o := range oFiles { |
| 77 | tname := fmt.Sprintf("file%d", i) |
| 78 | s := o.SectionTemplates |
nothing calls this directly
no test coverage detected