Skip to content

Commit

Permalink
Compose mappers (Azure#153)
Browse files Browse the repository at this point in the history
* Use object spread to add parent properties to mapper

* Regenerate
  • Loading branch information
RikkiGibson authored Jun 7, 2018
1 parent 1bdd229 commit b27b925
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 933 deletions.
13 changes: 12 additions & 1 deletion src/DSL/TSObject.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
//
//

using System;

Expand Down Expand Up @@ -105,6 +105,17 @@ public void Property(string propertyName, Action<TSValue> propertyValueAction)
builder.Value(propertyValueAction);
}

/// <summary>
/// Spreads the properties of the given object expression into this TSObject.
/// </summary>
/// <param name="objectExpression">The object expression to spread in this object.</param>
public void Spread(string objectExpression)
{
SetCurrentState(State.Property);
builder.Text("...");
builder.Text(objectExpression);
}

/// <summary>
/// Add a property to this TSObject with the provided name and null value.
/// </summary>
Expand Down
7 changes: 6 additions & 1 deletion src/vanilla/ClientModelExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,12 @@ public static void ConstructMapper(TSValue value, IModelType type, string serial
{
mapper.ObjectProperty("modelProperties", modelProperties =>
{
foreach (Property prop in composite.ComposedProperties)

if (composite.BaseModelType != null && composite.BaseModelType.ComposedProperties.Any())
{
modelProperties.Spread(composite.BaseModelType.Name + ".type.modelProperties");
}
foreach (Property prop in composite.Properties)
{
var serializedPropertyName = prop.SerializedName;
if (isPageable)
Expand Down
Loading

0 comments on commit b27b925

Please sign in to comment.