File tree Expand file tree Collapse file tree 3 files changed +39
-1
lines changed Expand file tree Collapse file tree 3 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -292,7 +292,6 @@ Service:
292292 - ServiceTaskCreate
293293 - ServiceTaskGet
294294 - ServiceUpdate
295- - ServiceUpdate
296295ServiceUser :
297296 - ServiceUserCreate
298297 - ServiceUserCredentialsModify
Original file line number Diff line number Diff line change 1+ package main
2+
3+ import (
4+ "fmt"
5+ )
6+
7+ func checkDuplicateEndpoints (config map [string ][]string ) error {
8+ endpoints := make (map [string ]struct {})
9+ duplicates := make (map [string ]struct {})
10+
11+ for _ , methods := range config {
12+ for _ , method := range methods {
13+ if _ , exists := endpoints [method ]; exists {
14+ duplicates [method ] = struct {}{}
15+ } else {
16+ endpoints [method ] = struct {}{}
17+ }
18+ }
19+ }
20+
21+ if len (duplicates ) > 0 {
22+ return fmt .Errorf ("Duplicate endpoints found in config: %v" , keys (duplicates ))
23+ }
24+ return nil
25+ }
26+
27+ func keys (m map [string ]struct {}) []string {
28+ keys := make ([]string , 0 , len (m ))
29+ for k := range m {
30+ keys = append (keys , k )
31+ }
32+ return keys
33+ }
Original file line number Diff line number Diff line change @@ -82,6 +82,12 @@ func exec() error {
8282 return err
8383 }
8484
85+ // Check for duplicate endpoints
86+ err = checkDuplicateEndpoints (config )
87+ if err != nil {
88+ return err
89+ }
90+
8591 // Reads OpenAPI file and applies a patch
8692 docBytes , err := readOpenAPIPatched (cfg .OpenAPIFile , cfg .OpenAPIPatchFile )
8793 if err != nil {
You can’t perform that action at this time.
0 commit comments