-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
importer-rest-api-specs
- parse orphaned discriminated models in nested files
#3727
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hey @stephybun
Thanks for this PR - I've taken a look through and left a few minor comments inline, but on the whole this is looking pretty good, if we can fix those up then this should otherwise be good to merge 👍
Thanks!
tools/importer-rest-api-specs/components/parser/swagger_resources.go
Outdated
Show resolved
Hide resolved
resource := models.AzureApiResource{ | ||
Constants: result.Constants, | ||
Models: result.Models, | ||
} | ||
resource = normalizeAzureApiResource(resource) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that the structure of Azure/azure-rest-api-specs
has changed multiple times in the past - I suspect we probably shouldn't assume that only Constants and Models are present within the nested directories (even if that's the case today).
Whilst we're merging the result of this function in combineResourcesWith
- rather than assuming the Swagger Tag is unique within this function (as we're doing here by writing to resourcesOut
without checking for an existing value) - I suspect it'd be worth supporting merging into resourcesOut
, as we do above (similar to lines 52-57 above) so that we don't unintentionally overwrite any Operations/Resource IDs which may be defined for an existing Tag, should Operations be added into a nested directory?
Alternatively we could look to surface an error here if the Swagger Tag already exists within resourcesOut
- but since we'd end up needing to implement the merge to fix that error, I suspect it'd be worth supporting merge from the start for consistency with the rest of the function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although I'm not in agreement that it's necessary I've added the logic to merge the resource information for a tag if it already exists since there isn't any harm in adding it.
Because this function is called on a per file basis, if any tags or operations were defined in the file it would be pulled out either here
resource, err := d.parseResourcesWithinSwaggerTag(&tag, resourceProvider, resourceIds) |
or here
pandora/tools/importer-rest-api-specs/components/parser/parser.go
Lines 37 to 39 in 793c3e5
// however some things don't, so we then need to iterate over any without them | |
if _, shouldIgnore := tagsToIgnore[strings.ToLower(serviceName)]; !shouldIgnore { | |
resource, err := d.parseResourcesWithinSwaggerTag(nil, resourceProvider, resourceIds) |
resulting in a populated
resources
variable which means we would never enter this part of the function and no prior tags could exist if we ended up here.
This PR closes #3693 and is related to #2551 but doesn't close it since we skip over this new functionality for DataFactory due to #3725.
Although we iterate over files in a nested directory structure, if the files have no paths defined then we don't parse any of the models defined in them.
This change adds the following functionality:
Note:
DataMigration
andSecurityInsights
are also affected by this change.DataMigration
results in the addition of a lot of new "resources" due to the naming of the files, we may want to consider skipping this functionality forDataMigration
as well.