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

Hide paging classes #1066

Merged
merged 2 commits into from
Mar 2, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace AppConfiguration.Models
{
public partial class KeyListResult
internal partial class KeyListResult
{
internal static KeyListResult DeserializeKeyListResult(JsonElement element)
{
Expand Down
2 changes: 1 addition & 1 deletion samples/AppConfiguration/Generated/Models/KeyListResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace AppConfiguration.Models
{
/// <summary> The result of a list request. </summary>
public partial class KeyListResult
internal partial class KeyListResult
{
/// <summary> Initializes a new instance of KeyListResult. </summary>
internal KeyListResult()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace AppConfiguration.Models
{
public partial class KeyValueListResult
internal partial class KeyValueListResult
{
internal static KeyValueListResult DeserializeKeyValueListResult(JsonElement element)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace AppConfiguration.Models
{
/// <summary> The result of a list request. </summary>
public partial class KeyValueListResult
internal partial class KeyValueListResult
{
/// <summary> Initializes a new instance of KeyValueListResult. </summary>
internal KeyValueListResult()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace AppConfiguration.Models
{
public partial class LabelListResult
internal partial class LabelListResult
{
internal static LabelListResult DeserializeLabelListResult(JsonElement element)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace AppConfiguration.Models
{
/// <summary> The result of a list request. </summary>
public partial class LabelListResult
internal partial class LabelListResult
{
/// <summary> Initializes a new instance of LabelListResult. </summary>
internal LabelListResult()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Azure.Management.Storage.Models
{
public partial class BlobServiceItems
internal partial class BlobServiceItems
{
internal static BlobServiceItems DeserializeBlobServiceItems(JsonElement element)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace Azure.Management.Storage.Models
{
/// <summary> The BlobServiceItems. </summary>
public partial class BlobServiceItems
internal partial class BlobServiceItems
{
/// <summary> Initializes a new instance of BlobServiceItems. </summary>
internal BlobServiceItems()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Azure.Management.Storage.Models
{
public partial class EncryptionScopeListResult
internal partial class EncryptionScopeListResult
{
internal static EncryptionScopeListResult DeserializeEncryptionScopeListResult(JsonElement element)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace Azure.Management.Storage.Models
{
/// <summary> List of encryption scopes requested, and if paging is required, a URL to the next page of encryption scopes. </summary>
public partial class EncryptionScopeListResult
internal partial class EncryptionScopeListResult
{
/// <summary> Initializes a new instance of EncryptionScopeListResult. </summary>
internal EncryptionScopeListResult()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Azure.Management.Storage.Models
{
public partial class FileShareItems
internal partial class FileShareItems
{
internal static FileShareItems DeserializeFileShareItems(JsonElement element)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace Azure.Management.Storage.Models
{
/// <summary> Response schema. Contains list of shares returned, and if paging is requested or required, a URL to next page of shares. </summary>
public partial class FileShareItems
internal partial class FileShareItems
{
/// <summary> Initializes a new instance of FileShareItems. </summary>
internal FileShareItems()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Azure.Management.Storage.Models
{
public partial class ListContainerItems
internal partial class ListContainerItems
{
internal static ListContainerItems DeserializeListContainerItems(JsonElement element)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace Azure.Management.Storage.Models
{
/// <summary> Response schema. Contains list of blobs returned, and if paging is requested or required, a URL to next page of containers. </summary>
public partial class ListContainerItems
internal partial class ListContainerItems
{
/// <summary> Initializes a new instance of ListContainerItems. </summary>
internal ListContainerItems()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Azure.Management.Storage.Models
{
public partial class ObjectReplicationPolicies
internal partial class ObjectReplicationPolicies
{
internal static ObjectReplicationPolicies DeserializeObjectReplicationPolicies(JsonElement element)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace Azure.Management.Storage.Models
{
/// <summary> List storage account object replication policies. </summary>
public partial class ObjectReplicationPolicies
internal partial class ObjectReplicationPolicies
{
/// <summary> Initializes a new instance of ObjectReplicationPolicies. </summary>
internal ObjectReplicationPolicies()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Azure.Management.Storage.Models
{
public partial class OperationListResult
internal partial class OperationListResult
{
internal static OperationListResult DeserializeOperationListResult(JsonElement element)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace Azure.Management.Storage.Models
{
/// <summary> Result of the request to list Storage operations. It contains a list of operations and a URL link to get the next set of results. </summary>
public partial class OperationListResult
internal partial class OperationListResult
{
/// <summary> Initializes a new instance of OperationListResult. </summary>
internal OperationListResult()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Azure.Management.Storage.Models
{
public partial class StorageAccountListResult
internal partial class StorageAccountListResult
{
internal static StorageAccountListResult DeserializeStorageAccountListResult(JsonElement element)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace Azure.Management.Storage.Models
{
/// <summary> The response from the List Storage Accounts operation. </summary>
public partial class StorageAccountListResult
internal partial class StorageAccountListResult
{
/// <summary> Initializes a new instance of StorageAccountListResult. </summary>
internal StorageAccountListResult()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Azure.Management.Storage.Models
{
public partial class StorageSkuListResult
internal partial class StorageSkuListResult
{
internal static StorageSkuListResult DeserializeStorageSkuListResult(JsonElement element)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace Azure.Management.Storage.Models
{
/// <summary> The response from the List Storage SKUs operation. </summary>
public partial class StorageSkuListResult
internal partial class StorageSkuListResult
{
/// <summary> Initializes a new instance of StorageSkuListResult. </summary>
internal StorageSkuListResult()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Azure.Management.Storage.Models
{
public partial class UsageListResult
internal partial class UsageListResult
{
internal static UsageListResult DeserializeUsageListResult(JsonElement element)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace Azure.Management.Storage.Models
{
/// <summary> The response from the List Usages operation. </summary>
public partial class UsageListResult
internal partial class UsageListResult
{
/// <summary> Initializes a new instance of UsageListResult. </summary>
internal UsageListResult()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Azure.Network.Management.Interface.Models
{
public partial class NetworkInterfaceIPConfigurationListResult
internal partial class NetworkInterfaceIPConfigurationListResult
{
internal static NetworkInterfaceIPConfigurationListResult DeserializeNetworkInterfaceIPConfigurationListResult(JsonElement element)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace Azure.Network.Management.Interface.Models
{
/// <summary> Response for list ip configurations API service call. </summary>
public partial class NetworkInterfaceIPConfigurationListResult
internal partial class NetworkInterfaceIPConfigurationListResult
{
/// <summary> Initializes a new instance of NetworkInterfaceIPConfigurationListResult. </summary>
internal NetworkInterfaceIPConfigurationListResult()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Azure.Network.Management.Interface.Models
{
public partial class NetworkInterfaceListResult
internal partial class NetworkInterfaceListResult
{
internal static NetworkInterfaceListResult DeserializeNetworkInterfaceListResult(JsonElement element)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace Azure.Network.Management.Interface.Models
{
/// <summary> Response for the ListNetworkInterface API service call. </summary>
public partial class NetworkInterfaceListResult
internal partial class NetworkInterfaceListResult
{
/// <summary> Initializes a new instance of NetworkInterfaceListResult. </summary>
internal NetworkInterfaceListResult()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Azure.Network.Management.Interface.Models
{
public partial class NetworkInterfaceLoadBalancerListResult
internal partial class NetworkInterfaceLoadBalancerListResult
{
internal static NetworkInterfaceLoadBalancerListResult DeserializeNetworkInterfaceLoadBalancerListResult(JsonElement element)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace Azure.Network.Management.Interface.Models
{
/// <summary> Response for list ip configurations API service call. </summary>
public partial class NetworkInterfaceLoadBalancerListResult
internal partial class NetworkInterfaceLoadBalancerListResult
{
/// <summary> Initializes a new instance of NetworkInterfaceLoadBalancerListResult. </summary>
internal NetworkInterfaceLoadBalancerListResult()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Azure.Network.Management.Interface.Models
{
public partial class NetworkInterfaceTapConfigurationListResult
internal partial class NetworkInterfaceTapConfigurationListResult
{
internal static NetworkInterfaceTapConfigurationListResult DeserializeNetworkInterfaceTapConfigurationListResult(JsonElement element)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace Azure.Network.Management.Interface.Models
{
/// <summary> Response for list tap configurations API service call. </summary>
public partial class NetworkInterfaceTapConfigurationListResult
internal partial class NetworkInterfaceTapConfigurationListResult
{
/// <summary> Initializes a new instance of NetworkInterfaceTapConfigurationListResult. </summary>
internal NetworkInterfaceTapConfigurationListResult()
Expand Down
18 changes: 17 additions & 1 deletion src/AutoRest.CSharp/Input/SchemaUsageProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,23 @@ public SchemaUsageProvider(CodeModel codeModel)
{
foreach (var operationResponse in operation.Responses)
{
Apply(operationResponse.ResponseSchema, SchemaTypeUsage.Model | SchemaTypeUsage.Output);
var paging = operation.Language.Default.Paging;
if (paging != null && operationResponse.ResponseSchema is ObjectSchema objectSchema)
{
Apply(operationResponse.ResponseSchema, SchemaTypeUsage.Output);
foreach (var property in objectSchema.Properties)
{
var itemName = paging.ItemName ?? "value";
if (property.SerializedName == itemName)
{
Apply(property.Schema, SchemaTypeUsage.Model | SchemaTypeUsage.Output);
}
}
}
else
{
Apply(operationResponse.ResponseSchema, SchemaTypeUsage.Model | SchemaTypeUsage.Output);
}
}

foreach (var operationResponse in operation.Exceptions)
Expand Down
6 changes: 6 additions & 0 deletions test/AutoRest.TestServer.Tests/paging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -857,5 +857,11 @@ public Task PagingFirstResponseEmpty() => Test(async (host, pipeline) =>
}
Assert.AreEqual(1, count);
});

[Test]
public void PagingModelsAreHidden()
{
Assert.IsFalse(typeof(ProductResult).IsPublic);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace custom_baseUrl_paging.Models
{
public partial class ProductResult
internal partial class ProductResult
{
internal static ProductResult DeserializeProductResult(JsonElement element)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace custom_baseUrl_paging.Models
{
/// <summary> The ProductResult. </summary>
public partial class ProductResult
internal partial class ProductResult
{
/// <summary> Initializes a new instance of ProductResult. </summary>
internal ProductResult()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace paging.Models
{
public partial class OdataProductResult
internal partial class OdataProductResult
{
internal static OdataProductResult DeserializeOdataProductResult(JsonElement element)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace paging.Models
{
/// <summary> The OdataProductResult. </summary>
public partial class OdataProductResult
internal partial class OdataProductResult
{
/// <summary> Initializes a new instance of OdataProductResult. </summary>
internal OdataProductResult()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace paging.Models
{
public partial class ProductResult
internal partial class ProductResult
{
internal static ProductResult DeserializeProductResult(JsonElement element)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace paging.Models
{
/// <summary> The ProductResult. </summary>
public partial class ProductResult
internal partial class ProductResult
{
/// <summary> Initializes a new instance of ProductResult. </summary>
internal ProductResult()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace paging.Models
{
public partial class ProductResultValue
internal partial class ProductResultValue
{
internal static ProductResultValue DeserializeProductResultValue(JsonElement element)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace paging.Models
{
/// <summary> The ProductResultValue. </summary>
public partial class ProductResultValue
internal partial class ProductResultValue
{
/// <summary> Initializes a new instance of ProductResultValue. </summary>
internal ProductResultValue()
Expand Down
Loading