Open tombuildsstuff opened 1 year ago
May we update Pandora's constant logic just like Azure Track 2 SDK to workaround this? We can detect if there are constants with the name exitsts, and rename the constant with a prefix by the model name if so. I'd like to submit such PR to Pandora if this looks good to you.
@wuxu92 unfortunately not - those scenarios are always data issues that need to be resolved there - if we did so we'd be opening ourselves up to both more regular breaking changes (which becomes an issue with generated items) - and unnecessarily duplicated constants - both of which are problematic in their own way.
When I last looked into this one, the issue was that the Discriminated Types that exist in the API aren't actually implemented correctly in the Swagger, with a Constant being used for the type
field with one possible value, rather than this being defined as a Discriminated Type - as such I believe this is going to need to be fixed by implementing the Discriminated Types correctly, rather than adding 30+ unique aliases for the constants (which shouldn't exist/don't need to be set in any other API, because the other APIs are using Discriminated Types).
Unfortunately either approach is going to be a breaking change to the Swagger - however there's not a lot we can do about that, since the Swagger is fundamentally wrong at present - and the "workaround" used in Track2 unfortunately further exacerbates the issue.
Looks like the same data issue exists in API Version 2024-02-01
?
$ go build . && ./importer-rest-api-specs import -services=CDN
2024-05-07T10:57:45.775+0200 [INFO] Finding only the Services "CDN"
2024-05-07T10:57:47.923+0200 [INFO] Importer for Service "CDN".Importer for API Version "2024-02-01": ❌ Service "CDN" - Api Version "2024-02-01"
2024-05-07T10:57:47.923+0200 [ERROR] Importer for Service "CDN".Importer for API Version "2024-02-01": 💥 Error: parsing Swagger files: parsing files in "../../submodules/rest-api-specs/specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01": parsing definition: finding resources for tag "Rules": finding nested items yet to be parsed: appending model: appending constants: conflicting constant "typeName" with different values. First: map[DeliveryRuleRequestMethodConditionParameters:DeliveryRuleRequestMethodConditionParameters]. Second: map[DeliveryRuleRouteConfigurationOverrideActionParameters:DeliveryRuleRouteConfigurationOverrideActionParameters]
2024/05/07 10:57:47 Error: parsing data for Service "CDN": parsing data for Service "CDN" / Version "2024-02-01": parsing Swagger files: parsing files in "../../submodules/rest-api-specs/specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01": parsing definition: finding resources for tag "Rules": finding nested items yet to be parsed: appending model: appending constants: conflicting constant "typeName" with different values. First: map[DeliveryRuleRequestMethodConditionParameters:DeliveryRuleRequestMethodConditionParameters]. Second: map[DeliveryRuleRouteConfigurationOverrideActionParameters:DeliveryRuleRouteConfigurationOverrideActionParameters]
should be fixed in the latest API Version by https://github.com/Azure/azure-rest-api-specs/pull/29629
Swagger issue: the same Constant is defined with differing values
Requires a Swagger PR to fix this