<commit_before>﻿// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this 
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

namespace ServiceStack.Documentation.Models
{
    using System;
    using System.Linq;

    // TODO Rename this api spec?
    /// <summary>
    /// General top level model with API (Service) wide vars
    /// </summary>
    public class ApiDocumentation
    {
        public string Title { get; set; }
        public string ApiVersion { get; set; }
        public string ApiBaseUrl { get; set; }

        public string Description { get; set; }
        /*public string Category { get; set; }
        public string[] Tags { get; set; }*/
        public string TermsOfService { get; set; }
        public string Licence { get; set; }
        public string LicenceUrl { get; set; }
        public ApiContact Contact { get; set; }

        public ApiResourceDocumentation[] Resources { get; set; }

        // Security

        public ApiDocumentation CreateCopy(Func<ApiResourceDocumentation, bool> resourcesFilter)
        {
            var apiDocumentation = MemberwiseClone() as ApiDocumentation;
            apiDocumentation.Resources = Resources.Where(resourcesFilter).ToArray();
            return apiDocumentation;
        }
    }

    /// <summary>
    /// Contact details for this api
    /// </summary>
    public class ApiContact
    {
        public string Name { get; set; }
        public string Url { get; set; }
        public string Email { get; set; }
    }

    /// <summary>
    /// A single API resource (DTO)
    /// </summary>
    //[DebuggerDisplay("{Title}")]
    public class ApiResourceDocumentation : IApiResourceType, IApiResponseStatus
    {
        // Set when instantiating
        public string TypeName { get; set; }

        // From IApiResourceType
        private string title;
        public string Title
        {
            get { return title ?? TypeName; }
            set
            {
                if (!string.IsNullOrEmpty(value))
                    title = value;
            }
        }

        public string Description { get; set; }
        public string Notes { get; set; }
        public ApiPropertyDocumention[] Properties { get; set; }

        // From IApiResponseStatus
        public string[] Verbs { get; set; }
        public StatusCode[] StatusCodes { get; set; }
        public string[] ContentTypes { get; set; }
        public string RelativePath { get; set; } // Depends on [Route]. .ToRelativeUri().
        public ApiResourceType ReturnType { get; set; } // ReturnType w/params

        // From ICategorised
        public string Category { get; set; }
        public string[] Tags { get; set; }

        // IDictionary<string, string> of extra 'stuff' that doesn't fit in any specific place
    }

    public class ApiResourceType : IApiResourceType
    {
        // These will need key'd by something (Type?) for finding + enriching
        private string title;
        public string Title
        {
            get { return title ?? TypeName; }
            set
            {
                if (!string.IsNullOrEmpty(value))
                    title = value;
            }
        }
        public string Description { get; set; }
        public string Notes { get; set; }
        public string TypeName { get; set; }
        public ApiPropertyDocumention[] Properties { get; set; }
    }

    /// <summary>
    /// Each request property within a DTO
    /// </summary>
    public class ApiPropertyDocumention : IApiSpec
    {
        // Set when instantiated
        public string Id { get; set; }
        public Type ClrType { get; set; }

        // From IApiSpec
        private string title;
        public string Title
        {
            get { return title ?? Id; }
            set
            {
                if (!string.IsNullOrEmpty(value))
                    title = value; 
            }
        }
        public string Description { get; set; }
        public string Notes { get; set; }
    
        public string ParamType { get; set; } // used to denote if the param is request querystring or body restricted
        public bool? IsRequired { get; set; }
        public string[] ExternalLinks { get; set; }
        public bool? AllowMultiple { get; set; }

        public IApiResourceType EmbeddedResource { get; set; }

        public PropertyConstraint Contraints { get; set; }

        // IDictionary<string,string> for extra stuff?
        // ExcludeInSchema??
    }

    // Should this be split further down? IHasTitle, IHasDescription etc?
    public interface IApiResourceType : IApiSpec
    {
        string TypeName { get; set; }
        ApiPropertyDocumention[] Properties { get; set; }
    }

    // NOTE Better name required
    public interface IApiResponseStatus : IApiMetadata
    {
        string[] Verbs { get; set; }
        StatusCode[] StatusCodes { get; set; }
        string[] ContentTypes { get; set; } // NOTE Does this need split by Accepts: and Content-Type:
        string RelativePath { get; set; }

        ApiResourceType ReturnType { get; set; } // Could this be IApiResourceType
    }

    public interface IApiSpec
    {
        string Title { get; set; }
        string Description { get; set; }
        string Notes { get; set; }
    }

    public interface IApiMetadata
    {
        string Category { get; set; }
        string[] Tags { get; set; }
    }
}<commit_msg>Removed unnecessary comments<commit_after>﻿// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this 
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

namespace ServiceStack.Documentation.Models
{
    using System;
    using System.Linq;

    /// <summary>
    /// General top level model with API (Service) wide vars
    /// </summary>
    public class ApiDocumentation
    {
        public string Title { get; set; }
        public string ApiVersion { get; set; }
        public string ApiBaseUrl { get; set; }

        public string Description { get; set; }
        public string TermsOfService { get; set; }
        public string Licence { get; set; }
        public string LicenceUrl { get; set; }
        public ApiContact Contact { get; set; }

        public ApiResourceDocumentation[] Resources { get; set; }

        // Security

        public ApiDocumentation CreateCopy(Func<ApiResourceDocumentation, bool> resourcesFilter)
        {
            var apiDocumentation = MemberwiseClone() as ApiDocumentation;
            apiDocumentation.Resources = Resources.Where(resourcesFilter).ToArray();
            return apiDocumentation;
        }
    }

    /// <summary>
    /// Contact details for this api
    /// </summary>
    public class ApiContact
    {
        public string Name { get; set; }
        public string Url { get; set; }
        public string Email { get; set; }
    }

    /// <summary>
    /// A single API resource (DTO)
    /// </summary>
    //[DebuggerDisplay("{Title}")]
    public class ApiResourceDocumentation : IApiResourceType, IApiResponseStatus
    {
        // Set when instantiating
        public string TypeName { get; set; }

        // From IApiResourceType
        private string title;
        public string Title
        {
            get { return title ?? TypeName; }
            set
            {
                if (!string.IsNullOrEmpty(value))
                    title = value;
            }
        }

        public string Description { get; set; }
        public string Notes { get; set; }
        public ApiPropertyDocumention[] Properties { get; set; }

        // From IApiResponseStatus
        public string[] Verbs { get; set; }
        public StatusCode[] StatusCodes { get; set; }
        public string[] ContentTypes { get; set; }
        public string RelativePath { get; set; }
        public ApiResourceType ReturnType { get; set; } // ReturnType w/params

        // From ICategorised
        public string Category { get; set; }
        public string[] Tags { get; set; }
    }

    public class ApiResourceType : IApiResourceType
    {
        // These will need key'd by something (Type?) for finding + enriching
        private string title;
        public string Title
        {
            get { return title ?? TypeName; }
            set
            {
                if (!string.IsNullOrEmpty(value))
                    title = value;
            }
        }
        public string Description { get; set; }
        public string Notes { get; set; }
        public string TypeName { get; set; }
        public ApiPropertyDocumention[] Properties { get; set; }
    }

    /// <summary>
    /// Each request property within a DTO
    /// </summary>
    public class ApiPropertyDocumention : IApiSpec
    {
        // Set when instantiated
        public string Id { get; set; }
        public Type ClrType { get; set; }

        // From IApiSpec
        private string title;
        public string Title
        {
            get { return title ?? Id; }
            set
            {
                if (!string.IsNullOrEmpty(value))
                    title = value; 
            }
        }
        public string Description { get; set; }
        public string Notes { get; set; }
    
        public string ParamType { get; set; } // used to denote if the param is request querystring or body restricted
        public bool? IsRequired { get; set; }
        public string[] ExternalLinks { get; set; }
        public bool? AllowMultiple { get; set; }

        public IApiResourceType EmbeddedResource { get; set; }

        public PropertyConstraint Contraints { get; set; }
    }

    public interface IApiResourceType : IApiSpec
    {
        string TypeName { get; set; }
        ApiPropertyDocumention[] Properties { get; set; }
    }

    public interface IApiResponseStatus : IApiMetadata
    {
        string[] Verbs { get; set; }
        StatusCode[] StatusCodes { get; set; }
        string[] ContentTypes { get; set; }
        string RelativePath { get; set; }

        ApiResourceType ReturnType { get; set; } // Could this be IApiResourceType
    }

    public interface IApiSpec
    {
        string Title { get; set; }
        string Description { get; set; }
        string Notes { get; set; }
    }

    public interface IApiMetadata
    {
        string Category { get; set; }
        string[] Tags { get; set; }
    }
}
{'fraction_non_alphanumeric': 0.09112482202183199, 'fraction_numerical': 0.0007593735168485999, 'mean_word_length': 1.854510972636142, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1922830', 'n_tokens_mistral': 2760, 'n_tokens_neox': 2730, 'n_words': 946}