File: Model\RegistrationPage.cs
Web Access
Project: src\nuget-client\src\NuGet.Core\NuGet.Protocol\NuGet.Protocol.csproj (NuGet.Protocol)
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.Collections.Generic;
using System.Text.Json.Serialization;
using Newtonsoft.Json;
namespace NuGet.Protocol.Model
{
    /// <summary>
    /// This model is used for both the registration page item (found in a registration index) and for a registration
    /// page fetched on its own.
    /// Source: https://docs.microsoft.com/en-us/nuget/api/registration-base-url-resource#registration-page
    /// Source: https://docs.microsoft.com/en-us/nuget/api/registration-base-url-resource#registration-page-object
    /// </summary>
    internal class RegistrationPage
    {
        // NULL_INC: Annotated as non-null per protocol spec (link above). JSON deserialization may leave these
        // as null if the server sends malformed data, but existing code assumes non-null without checks.
        [JsonProperty("@id")]
        [JsonPropertyName("@id")]
        public string Url { get; set; } = null!;

        /// <summary>
        /// This property can be null when this model is used as an item in <see cref="RegistrationIndex.Items"/> when
        /// the server decided not to inline the leaf items. In this case, the <see cref="Url"/> property can be used 
        /// fetch another <see cref="RegistrationPage"/> instance with the <see cref="Items"/> property filled in.
        /// </summary>
        [JsonProperty("items")]
        [JsonPropertyName("items")]
        public List<RegistrationLeafItem>? Items { get; set; }

        // NULL_INC: Annotated as non-null per protocol spec (link above). JSON deserialization may leave these
        // as null if the server sends malformed data, but existing code assumes non-null without checks.
        [JsonProperty("lower")]
        [JsonPropertyName("lower")]
        public string Lower { get; set; } = null!;

        // NULL_INC: Annotated as non-null per protocol spec (link above). JSON deserialization may leave these
        // as null if the server sends malformed data, but existing code assumes non-null without checks.
        [JsonProperty("upper")]
        [JsonPropertyName("upper")]
        public string Upper { get; set; } = null!;
    }
}