Skip to content
This repository was archived by the owner on Oct 11, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 2 additions & 20 deletions .gulp/regeneration.iced
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,6 @@ rubyAzureMappings = {
'parameter_grouping':['azure-parameter-grouping.json', 'ParameterGroupingModule']
}

rubyAzureAdditionalMappings = {
'azure_resource_inheritance': ['resource_inheritance.json', 'AzureResourceInheritanceModule']
}

swaggerDir = "node_modules/@microsoft.azure/autorest.testserver/swagger"

task 'regenerate-rubyazure', '', (done) ->
Expand All @@ -112,20 +108,6 @@ task 'regenerate-rubyazure', '', (done) ->
},done
return null

testSwaggerDir = "test/swagger"

task 'regenerate-rubyazure-additional', '', (done) ->
regenExpected {
'outputBaseDir': 'test/azure',
'inputBaseDir': testSwaggerDir,
'mappings': rubyAzureAdditionalMappings,
'outputDir': 'RspecTests/Generated',
'language': 'ruby',
'azureArm': true,
'nsPrefix': 'MyNamespace'
},done
return null

task 'regenerate-ruby', '', (done) ->
regenExpected {
'outputBaseDir': 'test/vanilla',
Expand All @@ -137,5 +119,5 @@ task 'regenerate-ruby', '', (done) ->
},done
return null

task 'regenerate', "regenerate expected code for tests", ['regenerate-ruby', 'regenerate-rubyazure', 'regenerate-rubyazure-additional'], (done) ->
done();
task 'regenerate', "regenerate expected code for tests", ['regenerate-ruby', 'regenerate-rubyazure'], (done) ->
done();
19 changes: 10 additions & 9 deletions src/azure/Model/CompositeTypeRba.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public override string GetBaseTypeName()
if (this.BaseModelType.Extensions.ContainsKey(AzureExtensions.ExternalExtension) ||
this.BaseModelType.Extensions.ContainsKey(AzureExtensions.AzureResourceExtension))
{
if (resourceOrSubResourceRegEx.IsMatch(typeName) || IsResourceModelMatchingStandardDefinition(this))
if (!resourceOrSubResourceRegEx.IsMatch(typeName) || !IsResourceModelMatchingStandardDefinition(this))
{
typeName = "MsRestAzure::" + typeName;
}
Expand All @@ -68,21 +68,22 @@ public override string GetBaseTypeName()
}

/// <summary>
/// Checks if the provided definition of model matches the standard definition of 'Resource'/'SubResource',
/// as defined in MsRestAzure.
/// Checks if the provided definition of models 'Resource'/'SubResource' matches the standard definition,
/// as defined in MsRestAzure. For other models, it returns false.
/// </summary>
/// <param name="model">CompositeType model to be validated.</param>
/// <returns><c>true</c> if model matches standard name and definition of Resource or SubResource, <c>false</c> otherwise.</returns>
/// <param name="model">to be validated</param>
/// <returns></returns>
public static bool IsResourceModelMatchingStandardDefinition(CompositeType model)
{
string modelName = model.Name.ToString();
if (!resourceOrSubResourceRegEx.IsMatch(modelName))
if (modelName.EqualsIgnoreCase("SubResource") &&
model.Properties.All(property => subResourceRegEx.IsMatch(property.Name.ToString())))
{
return false;
return true;
}

if (model.Properties.All(property => subResourceRegEx.IsMatch(property.Name.ToString())) ||
model.Properties.All(property => resourceRegEx.IsMatch(property.Name.ToString())))
if(modelName.EqualsIgnoreCase("Resource") &&
model.Properties.All(property => resourceRegEx.IsMatch(property.Name.ToString())))
{
return true;
}
Expand Down
57 changes: 0 additions & 57 deletions test/azure/RspecTests/resource_inheritance.rb

This file was deleted.

Loading