-
Notifications
You must be signed in to change notification settings - Fork 741
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
Code changes to generate resources/subresources #1769
Changes from all commits
48f1173
4b7d7d7
9e3e93b
0858bed
0cc3bea
3f857a1
9f5c1f6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
@using System | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The entire file seems like exact copy of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looked into other options. For now, since we are using cshtml files, we do not have anyother option. No changes here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. okay then |
||
@using System.Linq | ||
@using AutoRest.Core.Utilities | ||
@using AutoRest.Ruby | ||
@using AutoRest.Ruby.Model | ||
@using AutoRest.Ruby.Azure.Model | ||
@inherits AutoRest.Core.Template<AutoRest.Ruby.Model.CompositeTypeRb> | ||
# encoding: utf-8 | ||
@Header("# ") | ||
@EmptyLine | ||
module @(Settings.Namespace) | ||
module Models | ||
# | ||
@WrapComment("# ", Model.BuildSummaryAndDescriptionString()) | ||
# | ||
class @Model.Name@(Model.GetBaseTypeName()) | ||
@if (Model.Includes.Any()) | ||
{ | ||
@EmptyLine | ||
foreach (var include in Model.Includes) | ||
{ | ||
@:include @include | ||
} | ||
@EmptyLine | ||
} | ||
|
||
@if (Model.BaseIsPolymorphic && Model.BaseModelType == null) | ||
{ | ||
@:@@@@discriminatorMap = Hash.new | ||
foreach (var derivedType in Model.DerivedTypes) | ||
{ | ||
@:@@@@discriminatorMap["@derivedType.SerializedName"] = "@derivedType.Name" | ||
} | ||
} | ||
|
||
@if (Model.BaseIsPolymorphic) | ||
{ | ||
@EmptyLine | ||
@:def initialize | ||
@: @@@Model.PolymorphicDiscriminatorProperty.Name = "@Model.SerializedName" | ||
@:end | ||
@EmptyLine | ||
@:attr_accessor :@Model.PolymorphicDiscriminatorProperty.Name | ||
@EmptyLine | ||
} | ||
|
||
@foreach (var property in Model.PropertyTemplateModels.Where(each => !each.IsPolymorphicDiscriminator)) | ||
{ | ||
@if (CompositeTypeRba.NeedsAccessor(Model, property.Name)) | ||
{ | ||
@:@WrapComment("# ", string.Format("@return {0}{1}", property.ModelType.GetYardDocumentation(), CompositeTypeRb.GetPropertyDocumentationString(property))) | ||
@:attr_accessor :@property.Name | ||
@EmptyLine | ||
@: | ||
} | ||
} | ||
|
||
@EmptyLine | ||
# | ||
@WrapComment("# ", string.Format("Mapper for {0} class as Ruby Hash.", Model.Name)) | ||
# This will be used for serialization/deserialization. | ||
# | ||
def self.mapper() | ||
@(Model.ConstructModelMapper()) | ||
end | ||
end | ||
end | ||
end |
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.
Looking into AzureModelTemplate the only difference I saw with Model template is an if statement asking if an accessor should be generated and avoid generating it if the model is Resource or Subsresource, is this correct? If so, could we be making the distinction here and producing the template with the accessor (AzureModelTemplate) if the model matches a resource or subsresource, and produce a Model template in the rest of the cases?
or is there another way where we could avoid repeating the code between ModelTemplate and AzureModelTemplate and add a condition to ModelTemplate that can produce the difference?
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.
As discussed offline, since we have to create AzureModelTemplate anyway, it is good to keep the Azure specific model generation in one place than two. I am not convinced that we need to continue to use 2 file. No changes here
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.
I liked the idea that @veronicagg has but looks like you guys already discussed and reached to mutual conclusion