Normalise paths when checking overrides
@@ -60,6 +60,10 @@ func AddStatusFromSwagger(idFactory astmodel.IdentifierFactory, config *config.C
klog.V(1).Infof("Loaded Swagger data (%d resources, %d other types)", len(swaggerTypes.ResourceTypes), len(swaggerTypes.OtherTypes))
+ if len(swaggerTypes.ResourceTypes) == 0 || len(swaggerTypes.OtherTypes) == 0 {
+ return nil, errors.Errorf("Failed to load swagger information")
+ }
+
statusTypes, err := generateStatusTypes(swaggerTypes)
if err != nil {
return nil, err
@@ -576,11 +580,12 @@ func loadAllSchemas(
}
func groupFromPath(filePath string, rootPath string, overrides []config.SchemaOverride) string {
+ filePath = filepath.ToSlash(filePath)
group := jsonast.SwaggerGroupRegex.FindString(filePath)
// see if there is a config override for this file
for _, schemaOverride := range overrides {
- configSchemaPath := path.Join(rootPath, schemaOverride.BasePath)
+ configSchemaPath := filepath.ToSlash(path.Join(rootPath, schemaOverride.BasePath))
if strings.HasPrefix(filePath, configSchemaPath) {
// a forced namespace: use it
if schemaOverride.Namespace != "" {
@@ -609,5 +614,6 @@ func versionFromPath(filePath string, rootPath string) string {
// (and indeed this is the case with the /v2/ package)
filePath = strings.TrimPrefix(filePath, rootPath)
// must trim leading & trailing '/' as golang does not support lookaround
- return strings.Trim(swaggerVersionRegex.FindString(filePath), "/")
+ fp := filepath.ToSlash(filePath)
+ return strings.Trim(swaggerVersionRegex.FindString(fp), "/")
}
