Skip to content
This repository was archived by the owner on Oct 11, 2023. It is now read-only.

Fixing the inheritance logic#13

Merged
sarangan12 merged 4 commits intoAzure:masterfrom
sarangan12:FixInheritanceLogic
Oct 2, 2017
Merged

Fixing the inheritance logic#13
sarangan12 merged 4 commits intoAzure:masterfrom
sarangan12:FixInheritanceLogic

Conversation

@sarangan12
Copy link
Copy Markdown
Contributor

A swagger file can have 'Resource'/'SubResource' models defined in them.

In the current design, these two models have defined structure in ms_rest_azure. When the provided structure matches with the one defined then the defined ones are used. Else, a new class is defined per gem and this new class derives from the standard ones in MsRestAzure.

But, the above approach does have a problem. When the 'Resource' in swagger has properties such as 'name', 'p1', 'p2', 'p3', the above approach fails.

In order to handle this condition, a new design is provided - 'Generate Resource/SubResource per gem'.

What are the changes included in this PR?

  1. Any new code that was added originally to fix the inheritance logic has been removed.
  2. There is no more logic around x-ms-azure-resource & x-ms-azure-external extensions. I have discussed with Amar too and confirmed that this does not have any impact.
  3. AzureModelTemplate.cshtml was introduced originally to handle this issue. Since the logic has been changed, there is no reason to keep it. So, I removed.

How did I test?

  1. I opened all the models in all the services and checked manually.
  2. I have written a script to load all the models in all the services and confirmed there are no issues

@vishrutshah @veronicagg @salameer Please review and approve,

Copy link
Copy Markdown
Contributor

@vishrutshah vishrutshah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes looks great!

@sarangan12 💯 Thanks for taking care for this issue 💯

As you have exhaustive understanding of the cases, Would you mind please adding unit tests as that'd greatly help us as well and make sure that no one else is breaking it as well in future :)

Copy link
Copy Markdown
Contributor

@veronicagg veronicagg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor comment, rest looks good, thanks!
Agree with Vishrut, adding a test would be helpful.
Should we remove the "Resource" and "Subresource" definitions from MsRestAzure?

@@ -48,68 +48,12 @@ public override string GetBaseTypeName()
{
string typeName = this.BaseModelType.Name;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we not declare this variable now, and just return " < " + this.BaseModelType.Name; ? else return string.Empty?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@veronicagg Yes. the 'typeName' is no longer required. I have removed with the latest commit.

@veronicagg
Copy link
Copy Markdown
Contributor

and thanks for the extensive testing on this!

@sarangan12 sarangan12 changed the title Initial commit for fixing the inheritance logic Fixing the inheritance logic Sep 29, 2017
@sarangan12
Copy link
Copy Markdown
Contributor Author

@vishrutshah @veronicagg I have added the testcases around the inheritance logic.

@sarangan12
Copy link
Copy Markdown
Contributor Author

@veronicagg Just to be on the safe side, I have created issue Azure/azure-sdk-for-ruby#1010 and assigned it to next-arm and myself. I will just wait for one more release before taking that step :-)

Copy link
Copy Markdown
Contributor

@veronicagg veronicagg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couple of minor comments, thanks!

it 'should generate models with expected inheritance' do
modules = Module.const_get('AzureResourceInheritanceModule::Models')

# Should generate InheritMsRestAzureResource with super class as MsRestAzure::Resource
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this comment is out of date

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. My bad... Fixed it


include AzureResourceInheritanceModule

describe 'ResourceInheritance' do
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be renamed, as it's not testing inheritance for resource anymore? but validating that all models are generated for any inheritance relationship?

@vishrutshah
Copy link
Copy Markdown
Contributor

Just adding Issue link here..

Fixing Azure/azure-sdk-for-ruby#957

Copy link
Copy Markdown
Contributor

@vishrutshah vishrutshah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Copy Markdown
Contributor

@veronicagg veronicagg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@sarangan12 sarangan12 merged commit 5faa5b6 into Azure:master Oct 2, 2017
@olydis
Copy link
Copy Markdown
Contributor

olydis commented Oct 2, 2017

publish job

success (version: 2.0.17)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants