Skip to content
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

config - add network 2024-01-01-preview #4374

Closed
wants to merge 3 commits into from

Conversation

teowa
Copy link
Contributor

@teowa teowa commented Aug 22, 2024

@teowa
Copy link
Contributor Author

teowa commented Aug 22, 2024

Building fails with below error while running importer-rest-api-specs

2024-08-22T02:39:47.780Z [INFO]  Importer for Service "Network"
2024-08-22T02:41:50.202Z [INFO]  ❌ Service "Network" - Api Version "2024-01-01-preview"
Error: -22T02:41:50.202Z [ERROR]      💥 Error: parsing Swagger files: parsing files in "../../submodules/rest-api-specs/specification/network/resource-manager/Microsoft.Network/preview/2024-01-01-preview": parsing definition: finding resources for tag "AdminRules": finding nested items yet to be parsed: appending model: appending constants: conflicting constant "ProvisioningState" with different values. First: map[Canceled:Canceled Creating:Creating Deleting:Deleting Failed:Failed Succeeded:Succeeded Updating:Updating]. Second: map[Deleting:Deleting Failed:Failed Succeeded:Succeeded Updating:Updating]

because there is more than one ProvisioningState in two swagger json files under network@2024-01-01-preview https://github.com/Azure/azure-rest-api-specs/blob/ba268c5654f002bc17914e0bc157f19529f1fec1/specification/network/resource-manager/Microsoft.Network/preview/2024-01-01-preview/network.json#L464

https://github.com/Azure/azure-rest-api-specs/blob/b72e0199fa3242d64b0b49f38e71586066a8c048/specification/network/resource-manager/Microsoft.Network/preview/2024-01-01-preview/networkManagerSecurityAdminConfiguration.json#L1007-L1023

Is there any way we can resolve this?

@teowa
Copy link
Contributor Author

teowa commented Aug 30, 2024

After some debug, this is because after analysis.Flatten

flattenedWithReferencesOpts := &analysis.FlattenOpts{
Minimal: true,
Verbose: true,
Expand: false,
RemoveUnused: false,
//ContinueOnError: true,
BasePath: swaggerDocWithReferences.SpecFilePath(),
Spec: analysis.New(swaggerDocWithReferences.Spec()),
}
if err := analysis.Flatten(*flattenedWithReferencesOpts); err != nil {
return nil, fmt.Errorf("flattening swagger file with references %q: %+v", filePath, err)
}
in below code block, there will be one provisioningState and one ProvisioningState in d.swaggerSpecRaw.Definitions

ProvisioningState [Failed Succeeded Canceled Creating Updating Deleting]
provisioningState [Succeeded Updating Deleting Failed]

ProvisioningState with 6 values is used in networkManagerSecurityAdminConfiguration.json but provisioningState with 4 values is never used in the file.
Below shows model name and its Enum values before and after analysis.Flatten

parsing ../../submodules/rest-api-specs/specification/network/resource-manager/Microsoft.Network/preview/2024-01-01-preview /networkManagerSecurityAdminConfiguration.json

--- before flatten /networkManagerSecurityAdminConfiguration.json ---
Access [Allow Deny]
AddressPrefixItem []
AddressSpaceAggregationOption [None Manual]
AdminPropertiesFormat []
AdminRule []
AdminRuleCollection []
AdminRuleCollectionListResult []
AdminRuleCollectionPropertiesFormat []
AdminRuleListResult []
AuthenticationMethod [EAPTLS EAPMSCHAPv2]
AzureAsyncOperationResult []
BaseAdminRule []
ChildResource []
CloudError []
CloudErrorBody []
CommonErrorAdditionalInfo []
CommonErrorDetail []
CommonErrorResponse []
CommonProxyResource []
CommonResource []
CommonTrackedResource []
ConfigurationType [SecurityAdmin Connectivity]
CrossTenantScopes []
DefaultAdminPropertiesFormat []
DefaultAdminRule []
Error []
ErrorDetails []
ExtendedLocation []
ExtendedLocationType [EdgeZone]
IPAllocationMethod [Static Dynamic]
IPVersion [IPv4 IPv6]
ManagedServiceIdentity []
NetworkIntentPolicyBasedService [None All AllowRulesOnly]
NetworkManager []
NetworkManagerCommit []
NetworkManagerDeploymentStatus []
NetworkManagerDeploymentStatusListResult []
NetworkManagerDeploymentStatusParameter []
NetworkManagerListResult []
NetworkManagerProperties []
NetworkManagerSecurityGroupItem []
PatchObject []
ProvisioningState [Failed Succeeded Canceled Creating Updating Deleting]
Resource []
RuleProtocol [Tcp Udp Icmp Esp Any Ah]
SecurityAdminConfiguration []
SecurityAdminConfigurationListResult []
SecurityAdminConfigurationPropertiesFormat []
SecurityConfigurationRuleAccess [Allow Deny AlwaysAllow]
SecurityConfigurationRuleDirection [Inbound Outbound]
SubResource []
SystemData []
TagsObject []



--- after flatten /networkManagerSecurityAdminConfiguration.json ---
Access [Allow Deny]
AddressPrefixItem []
AddressSpaceAggregationOption [None Manual]
AdminPropertiesFormat []
AdminRule []
AdminRuleCollection []
AdminRuleCollectionListResult []
AdminRuleCollectionPropertiesFormat []
AdminRuleListResult []
AuthenticationMethod [EAPTLS EAPMSCHAPv2]
AzureAsyncOperationResult []
BaseAdminRule []
ChildResource []
CloudError []
CloudErrorBody []
CommonErrorAdditionalInfo []
CommonErrorDetail []
CommonErrorResponse []
CommonProxyResource []
CommonResource []
CommonTrackedResource []
ConfigurationType [SecurityAdmin Connectivity]
CrossTenantScopes []
DefaultAdminPropertiesFormat []
DefaultAdminRule []
Error []
ErrorDetails []
ExtendedLocation []
ExtendedLocationType [EdgeZone]
IPAllocationMethod [Static Dynamic]
IPVersion [IPv4 IPv6]
ManagedServiceIdentity []
NetworkIntentPolicyBasedService [None All AllowRulesOnly]
NetworkManager []
NetworkManagerCommit []
NetworkManagerDeploymentStatus []
NetworkManagerDeploymentStatusListResult []
NetworkManagerDeploymentStatusParameter []
NetworkManagerListResult []
NetworkManagerProperties []
NetworkManagerSecurityGroupItem []
PatchObject []
ProvisioningState [Failed Succeeded Canceled Creating Updating Deleting]
Resource []
RuleProtocol [Tcp Udp Icmp Esp Any Ah]
SecurityAdminConfiguration []
SecurityAdminConfigurationListResult []
SecurityAdminConfigurationPropertiesFormat []
SecurityConfigurationRuleAccess [Allow Deny AlwaysAllow]
SecurityConfigurationRuleDirection [Inbound Outbound]
SubResource []
SystemData []
TagsObject []
+cloudError []
+cloudErrorBody []
+commonErrorAdditionalInfo []
+commonErrorDetail []
+commonErrorResponse []
+commonProxyResource []
+commonResource []
+provisioningState [Succeeded Updating Deleting Failed]
+resource []
+systemData []

NOTE the green part is generated by analysis.Flatten
Not sure if there is bug in upstream package https://github.com/go-openapi/analysis
Then in

func (d *SwaggerDefinition) findTopLevelObject(name string) (*spec.Schema, error) {
for modelName, model := range d.swaggerSpecRaw.Definitions {
if strings.EqualFold(modelName, name) {
return &model, nil
}
}
, strings.EqualFold(modelName, name) is used, thus may lead to two conflict enum.

@teowa
Copy link
Contributor Author

teowa commented Oct 11, 2024

Hi team, this should be good to merge after the importer is refactored in PR #4307.

@teowa
Copy link
Contributor Author

teowa commented Oct 16, 2024

close as 2024-05-01 stable version covering the new feature is coming soon.

@teowa teowa closed this Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant