Skip to content

Commit

Permalink
fix swagger transformer
Browse files Browse the repository at this point in the history
  • Loading branch information
bcmdarroch authored Feb 8, 2023
1 parent 1ef9137 commit 2919540
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cmd/transform-swagger/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"log"
"os"
"path/filepath"
"regexp"
"strings"

"github.com/go-openapi/loads"
Expand Down Expand Up @@ -137,7 +138,10 @@ func loadSharedDefinitions(sharedPath, svcPath string) (map[string]bool, error)

for _, def := range doc.Analyzer.AllDefinitions() {
if def.TopLevel {
if !strings.HasPrefix(def.Name, "hashicorp.cloud") {
// depending on which plugin used for swagger, some package info may not be available
// any types missing package information are skipped
fqnSwaggerFormat, _ := regexp.MatchString("\\w+\\.\\w+\\.", def.Name)
if fqnSwaggerFormat && !strings.HasPrefix(def.Name, "hashicorp.cloud") {
sharedDefs[def.Name] = true
}
}
Expand Down

0 comments on commit 2919540

Please sign in to comment.