()
| 63 | } |
| 64 | |
| 65 | func specTemplate() (*template.Template, errors.Error) { |
| 66 | path := config.GetConfig().GetString("SWAGGER_DOCS_DIR") |
| 67 | if path == "" { |
| 68 | return nil, errors.Default.New("path for Swagger docs resources is not set") |
| 69 | } |
| 70 | file, err := os.Open(filepath.Join(path, "open_api_spec.json.tmpl")) |
| 71 | if err != nil { |
| 72 | return nil, errors.Default.Wrap(err, "could not open swagger doc template") |
| 73 | } |
| 74 | contents, err := io.ReadAll(file) |
| 75 | if err != nil { |
| 76 | return nil, errors.Default.Wrap(err, "could not read swagger doc template") |
| 77 | } |
| 78 | specTemplate, err := template.New("doc").Parse(string(contents)) |
| 79 | if err != nil { |
| 80 | return nil, errors.Default.Wrap(err, "could not parse swagger doc template") |
| 81 | } |
| 82 | return specTemplate, nil |
| 83 | } |
no test coverage detected