diff --git a/tools/importer-rest-api-specs/internal/components/apidefinitions/parse_api_resource.go b/tools/importer-rest-api-specs/internal/components/apidefinitions/parse_api_resource.go index 568cf4e78f2..470f5c92cf3 100644 --- a/tools/importer-rest-api-specs/internal/components/apidefinitions/parse_api_resource.go +++ b/tools/importer-rest-api-specs/internal/components/apidefinitions/parse_api_resource.go @@ -77,7 +77,7 @@ func parseAPIResourcesFromFile(filePath, serviceName string, resourceProvider *s } } - // 3. Discriminator implementations that are defined in separate files with no link to a swagger tag + // 4. Discriminator implementations that are defined in separate files with no link to a swagger tag // are not parsed. So far there are two known instances of this (Data Factory, Chaos Studio) where // the files are defined in a nested directory e.g. d.Name = /Types/Capabilities if len(parsedAPIResources) == 0 { @@ -95,7 +95,6 @@ func parseAPIResourcesFromFile(filePath, serviceName string, resourceProvider *s Constants: result.Constants, Models: result.Models, } - resource = cleanup.NormalizeAPIResource(resource) discoveredResources := map[string]sdkModels.APIResource{ inferredTag: resource, diff --git a/tools/importer-rest-api-specs/internal/components/apidefinitions/parse_api_version.go b/tools/importer-rest-api-specs/internal/components/apidefinitions/parse_api_version.go index ca3d779a161..7c00de49bbf 100644 --- a/tools/importer-rest-api-specs/internal/components/apidefinitions/parse_api_version.go +++ b/tools/importer-rest-api-specs/internal/components/apidefinitions/parse_api_version.go @@ -52,6 +52,14 @@ func parseAPIVersion(serviceName string, input discoveryModels.AvailableDataSetF logging.Tracef("Processing API Definitions from file %q - Completed.", filePath) } + // Normalize names of all operations, resource IDs, constants, models, and field names, ensuring they are + // appropriately Pascal cased. We are doing this after building out all the resources, since some references + // can get updated out-of-band and would subsequently be missed if we normalized immediately after parsing + // each resource. + for resourceName, resource := range apiResources { + apiResources[resourceName] = cleanup.NormalizeAPIResource(resource) + } + // Now that we have a canonical list of resources - can we simplify the Operation names at all? for resourceName, resource := range apiResources { logging.Tracef("Simplifying operation names for resource %q", resourceName) diff --git a/tools/importer-rest-api-specs/internal/components/apidefinitions/parser/parse_swagger_tag.go b/tools/importer-rest-api-specs/internal/components/apidefinitions/parser/parse_swagger_tag.go index 876bad6b377..84c7f4810a5 100644 --- a/tools/importer-rest-api-specs/internal/components/apidefinitions/parser/parse_swagger_tag.go +++ b/tools/importer-rest-api-specs/internal/components/apidefinitions/parser/parse_swagger_tag.go @@ -4,7 +4,6 @@ import ( "fmt" sdkModels "github.com/hashicorp/pandora/tools/data-api-sdk/v1/models" - "github.com/hashicorp/pandora/tools/importer-rest-api-specs/internal/components/apidefinitions/parser/cleanup" "github.com/hashicorp/pandora/tools/importer-rest-api-specs/internal/components/apidefinitions/parser/commonschema" parserModels "github.com/hashicorp/pandora/tools/importer-rest-api-specs/internal/components/apidefinitions/parser/models" "github.com/hashicorp/pandora/tools/importer-rest-api-specs/internal/components/apidefinitions/parser/operation" @@ -61,8 +60,5 @@ func (p *apiDefinitionsParser) ParseAPIResourceWithinSwaggerTag(tag, resourcePro // then switch out any Common Schema Types (e.g. Identity) resource = commonschema.ReplaceSDKObjectDefinitionsAsNeeded(resource) - // Normalize the names, ensuring they are appropriately Pascal cased - resource = cleanup.NormalizeAPIResource(resource) - return &resource, nil } diff --git a/tools/importer-rest-api-specs/internal/pipeline/import.go b/tools/importer-rest-api-specs/internal/pipeline/import.go index 2958433e75e..552cbc49fd6 100644 --- a/tools/importer-rest-api-specs/internal/pipeline/import.go +++ b/tools/importer-rest-api-specs/internal/pipeline/import.go @@ -46,7 +46,7 @@ func RunImporter(opts Options) error { } logging.Debugf("Completed - Clearing any existing API Definitions.") - logging.Infof("Processing the %d Services..", len(p.servicesFromConfigurationFiles)) + logging.Infof("Processing %d Services..", len(p.servicesFromConfigurationFiles)) for _, service := range p.servicesFromConfigurationFiles { if len(opts.ServiceNamesToLimitTo) > 0 { processThisService := false