< Summary - Kestrun — Combined Coverage

Information
Class: Kestrun.OpenApi.OpenApiComponentClone
Assembly: Kestrun
File(s): /home/runner/work/Kestrun/Kestrun/src/CSharp/Kestrun/OpenApi/OpenApiComponentClone.cs
Tag: Kestrun/Kestrun@ca54e35c77799b76774b3805b6f075cdbc0c5fbe
Line coverage
70%
Covered lines: 211
Uncovered lines: 88
Coverable lines: 299
Total lines: 709
Line coverage: 70.5%
Branch coverage
46%
Covered branches: 68
Total branches: 146
Branch coverage: 46.5%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 12/12/2025 - 17:27:19 Line coverage: 27.1% (77/284) Branch coverage: 21.7% (30/138) Total lines: 645 Tag: Kestrun/Kestrun@826bf9dcf9db118c5de4c78a3259bce9549f0dcd12/21/2025 - 06:07:10 Line coverage: 27% (77/285) Branch coverage: 22% (30/136) Total lines: 666 Tag: Kestrun/Kestrun@8cf7f77e55fd1fd046ea4e5413eb9ef96e49fe6a12/27/2025 - 20:05:22 Line coverage: 25.7% (77/299) Branch coverage: 20.5% (30/146) Total lines: 709 Tag: Kestrun/Kestrun@dec745d62965b14e1ed62c0f3ec815e60e53366f01/08/2026 - 08:19:25 Line coverage: 34.7% (104/299) Branch coverage: 26% (38/146) Total lines: 709 Tag: Kestrun/Kestrun@6ab94ca7560634c2ac58b36c2b98e2a9b1bf305d01/09/2026 - 06:56:42 Line coverage: 68.2% (204/299) Branch coverage: 46.5% (68/146) Total lines: 709 Tag: Kestrun/Kestrun@94f8107dc592fa7eaec45c0dd5f9fffbd41bc14501/21/2026 - 17:07:46 Line coverage: 70.5% (211/299) Branch coverage: 46.5% (68/146) Total lines: 709 Tag: Kestrun/Kestrun@3f6f61710c7ef7d5953cab578fe699c1e5e01a36 12/12/2025 - 17:27:19 Line coverage: 27.1% (77/284) Branch coverage: 21.7% (30/138) Total lines: 645 Tag: Kestrun/Kestrun@826bf9dcf9db118c5de4c78a3259bce9549f0dcd12/21/2025 - 06:07:10 Line coverage: 27% (77/285) Branch coverage: 22% (30/136) Total lines: 666 Tag: Kestrun/Kestrun@8cf7f77e55fd1fd046ea4e5413eb9ef96e49fe6a12/27/2025 - 20:05:22 Line coverage: 25.7% (77/299) Branch coverage: 20.5% (30/146) Total lines: 709 Tag: Kestrun/Kestrun@dec745d62965b14e1ed62c0f3ec815e60e53366f01/08/2026 - 08:19:25 Line coverage: 34.7% (104/299) Branch coverage: 26% (38/146) Total lines: 709 Tag: Kestrun/Kestrun@6ab94ca7560634c2ac58b36c2b98e2a9b1bf305d01/09/2026 - 06:56:42 Line coverage: 68.2% (204/299) Branch coverage: 46.5% (68/146) Total lines: 709 Tag: Kestrun/Kestrun@94f8107dc592fa7eaec45c0dd5f9fffbd41bc14501/21/2026 - 17:07:46 Line coverage: 70.5% (211/299) Branch coverage: 46.5% (68/146) Total lines: 709 Tag: Kestrun/Kestrun@3f6f61710c7ef7d5953cab578fe699c1e5e01a36

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Clone(...)100%210%
Clone(...)50%66100%
Clone(...)50%5466.66%
Clone(...)100%210%
Clone(...)100%11100%
ConvertToSchema(...)50%66100%
Clone(...)0%2040%
Clone(...)25%9433.33%
Clone(...)100%11100%
Clone(...)75%4483.33%
Clone(...)25%5466.66%
Clone(...)50%66100%
Clone(...)100%210%
Clone(...)50%22100%
Clone(...)100%210%
Clone(...)0%2040%
Clone(...)75%4483.33%
Clone(...)25%5466.66%
Clone(...)100%210%
Clone(...)100%11100%
Clone(...)50%9872.72%
Clone(...)100%210%
Clone(...)100%22100%
Clone(...)50%5466.66%
Clone(...)50%4242100%
Clone(...)100%11100%
Clone(...)0%2040%
Clone(...)100%44100%
Clone(...)0%2040%
Clone(...)50%66100%
Clone(...)100%210%
Clone(...)75%4483.33%
Clone(...)25%5466.66%
Clone(...)100%210%
Clone(...)50%22100%
Clone(...)0%620%
Clone(...)50%22100%
Clone(...)75%4483.33%
JsonNodeClone(...)100%22100%

File(s)

/home/runner/work/Kestrun/Kestrun/src/CSharp/Kestrun/OpenApi/OpenApiComponentClone.cs

#LineLine coverage
 1using Microsoft.OpenApi;
 2using System.Text.Json.Nodes;
 3
 4namespace Kestrun.OpenApi;
 5
 6/// <summary>
 7/// Helper methods for cloning OpenAPI components.
 8/// </summary>
 9public static class OpenApiComponentClone
 10{
 11    #region Parameter
 12    /// <summary>
 13    /// Clones an OpenApiParameterReference instance.
 14    /// </summary>
 15    /// <param name="parameter">The OpenApiParameterReference to clone.</param>
 16    /// <returns>A new OpenApiParameterReference instance with the same properties as the input parameter.</returns>
 17    public static OpenApiParameterReference Clone(this OpenApiParameterReference parameter)
 18    {
 019        var clone = new OpenApiParameterReference(parameter.Reference.Id!)
 020        {
 021            Description = parameter.Description,
 022        };
 023        return clone;
 24    }
 25
 26    /// <summary>
 27    /// Clones an OpenApiParameter instance.
 28    /// </summary>
 29    /// <param name="parameter">The OpenApiParameter to clone.</param>
 30    /// <returns>A new OpenApiParameter instance with the same properties as the input parameter.</returns>
 31    public static OpenApiParameter Clone(this OpenApiParameter parameter)
 32    {
 133        var clone = new OpenApiParameter
 134        {
 135            Name = parameter.Name,
 136            In = parameter.In,
 137            Description = parameter.Description,
 138            Required = parameter.Required,
 139            Style = parameter.Style,
 140            Explode = parameter.Explode,
 141            AllowReserved = parameter.AllowReserved,
 142            Schema = parameter.Schema?.Clone(),
 143            Examples = parameter.Examples?.Clone(),
 144            Example = JsonNodeClone(parameter.Example),
 145            Content = parameter.Content?.Clone(),
 146            Extensions = parameter.Extensions.Clone(),
 147            AllowEmptyValue = parameter.AllowEmptyValue,
 148            Deprecated = parameter.Deprecated
 149        };
 150        return clone;
 51    }
 52
 53    /// <summary>
 54    /// Clones an IOpenApiParameter instance.
 55    /// </summary>
 56    /// <param name="parameter">The IOpenApiParameter instance to clone.</param>
 57    /// <returns>A cloned instance of IOpenApiParameter.</returns>
 58    /// <exception cref="InvalidOperationException">Thrown when the IOpenApiParameter implementation is unsupported.</ex
 59    public static IOpenApiParameter Clone(this IOpenApiParameter parameter)
 60    {
 61        // Determine the actual type of IOpenApiParameter and clone accordingly
 162        return parameter switch
 163        {
 064            OpenApiParameter param => param.Clone(),
 065            OpenApiParameterReference paramRef => paramRef.Clone(),
 166            _ => throw new InvalidOperationException("Unsupported IOpenApiParameter implementation."),
 167        };
 68    }
 69    #endregion
 70    #region RequestBody
 71    /// <summary>
 72    /// Clones an OpenApiRequestBodyReference instance.
 73    /// </summary>
 74    /// <param name="requestBody">The OpenApiRequestBodyReference to clone.</param>
 75    /// <returns>A new OpenApiRequestBodyReference instance with the same properties as the input requestBody.</returns>
 76    public static OpenApiRequestBodyReference Clone(this OpenApiRequestBodyReference requestBody)
 77    {
 078        var clone = new OpenApiRequestBodyReference(requestBody.Reference.Id!)
 079        {
 080            Description = requestBody.Description,
 081        };
 082        return clone;
 83    }
 84    /// <summary>
 85    /// Clones an OpenApiRequestBody instance.
 86    /// </summary>
 87    /// <param name="requestBody">The OpenApiRequestBody to clone.</param>
 88    /// <returns>A new OpenApiRequestBody instance with the same properties as the input requestBody.</returns>
 89    public static OpenApiRequestBody Clone(this OpenApiRequestBody requestBody)
 90    {
 191        var clone = new OpenApiRequestBody
 192        {
 193            Description = requestBody.Description,
 194            Required = requestBody.Required,
 195            Content = requestBody.Content.Clone(),
 196            Extensions = requestBody.Extensions.Clone()
 197        };
 198        return clone;
 99    }
 100
 101    /// <summary>
 102    /// Converts an OpenApiRequestBody to an OpenApiSchema.
 103    /// </summary>
 104    /// <param name="requestBody">The OpenApiRequestBody to convert.</param>
 105    /// <returns>An OpenApiSchema representing the request body.</returns>
 106    public static OpenApiSchema ConvertToSchema(this OpenApiRequestBody requestBody)
 107    {
 1108        var clone = new OpenApiSchema
 1109        {
 1110            Description = requestBody.Description,
 1111            Properties = requestBody.Content?.Values.FirstOrDefault()?.Schema?.Properties.Clone(),
 1112            Extensions = requestBody.Extensions.Clone()
 1113        };
 1114        return clone;
 115    }
 116    /// <summary>
 117    /// Clones an IOpenApiRequestBody instance.
 118    /// </summary>
 119    /// <param name="parameter">The IOpenApiRequestBody instance to clone.</param>
 120    /// <returns>A cloned instance of IOpenApiRequestBody.</returns>
 121    /// <exception cref="InvalidOperationException">Thrown when the IOpenApiRequestBody implementation is unsupported.</
 122    public static IOpenApiRequestBody Clone(this IOpenApiRequestBody parameter)
 123    {
 124        // Determine the actual type of IOpenApiParameter and clone accordingly
 0125        return parameter switch
 0126        {
 0127            OpenApiRequestBody param => param.Clone(),
 0128            OpenApiRequestBodyReference paramRef => paramRef.Clone(),
 0129            _ => throw new InvalidOperationException("Unsupported IOpenApiRequestBody implementation."),
 0130        };
 131    }
 132    #endregion
 133    #region Extensions
 134    /// <summary>
 135    /// Clones a dictionary of OpenApiExtension instances.
 136    /// </summary>
 137    /// <param name="extensions">The dictionary to clone.</param>
 138    /// <returns>A new dictionary with cloned OpenApiExtension instances.</returns>
 139    public static IDictionary<string, IOpenApiExtension>? Clone(this IDictionary<string, IOpenApiExtension>? extensions)
 140    {
 21141        if (extensions == null)
 142        {
 21143            return null;
 144        }
 145
 0146        var clone = new Dictionary<string, IOpenApiExtension>();
 0147        foreach (var kvp in extensions)
 148        {
 0149            clone[kvp.Key] = kvp.Value.Clone();
 150        }
 0151        return clone;
 152    }
 153
 154    /// <summary>
 155    /// Clones an OpenApiExtension instance.
 156    /// </summary>
 157    /// <param name="extension">The OpenApiExtension to clone.</param>
 158    /// <returns>A new OpenApiExtension instance with the same properties as the input extension.</returns>
 159    /// <exception cref="InvalidOperationException">Thrown when the extension is of an unsupported type.</exception>
 1160    public static IOpenApiExtension Clone(this IOpenApiExtension extension) => throw new InvalidOperationException("Unsu
 161
 162    #endregion
 163
 164    #region Header
 165    /// <summary>
 166    /// Clones a dictionary of IOpenApiHeader instances.
 167    /// </summary>
 168    /// <param name="headers">The dictionary of headers to clone.</param>
 169    /// <returns>A new dictionary with cloned IOpenApiHeader instances.</returns>
 170    public static IDictionary<string, IOpenApiHeader>? Clone(this IDictionary<string, IOpenApiHeader>? headers)
 171    {
 1172        if (headers == null)
 173        {
 0174            return null;
 175        }
 176
 1177        var clone = new Dictionary<string, IOpenApiHeader>();
 4178        foreach (var kvp in headers)
 179        {
 1180            clone[kvp.Key] = kvp.Value.Clone();
 181        }
 1182        return clone;
 183    }
 184
 185    /// <summary>
 186    /// Clones an IOpenApiHeader instance.
 187    /// </summary>
 188    /// <param name="header">The IOpenApiHeader to clone.</param>
 189    /// <returns>A new IOpenApiHeader instance with the same properties as the input header.</returns>
 190    /// <exception cref="InvalidOperationException">Thrown when the header is of an unsupported type.</exception>
 191    public static IOpenApiHeader Clone(this IOpenApiHeader header) =>
 1192    header switch
 1193    {
 1194        OpenApiHeader headerObj => headerObj.Clone(),
 0195        OpenApiHeaderReference headerRef => headerRef.Clone(),
 0196        _ => throw new InvalidOperationException("Unsupported IOpenApiHeader implementation.")
 1197    };
 198
 199    /// <summary>
 200    /// Clones an OpenApiHeader instance.
 201    /// </summary>
 202    /// <param name="header">The OpenApiHeader to clone.</param>
 203    /// <returns>A new OpenApiHeader instance with the same properties as the input header.</returns>
 204    public static OpenApiHeader Clone(this OpenApiHeader header)
 205    {
 2206        var clone = new OpenApiHeader
 2207        {
 2208            Description = header.Description,
 2209            Required = header.Required,
 2210            Deprecated = header.Deprecated,
 2211            Style = header.Style,
 2212            Explode = header.Explode,
 2213            AllowEmptyValue = header.AllowEmptyValue,
 2214            Schema = header.Schema?.Clone(),
 2215            Examples = header.Examples?.Clone(),
 2216            Example = JsonNodeClone(header.Example),
 2217            Content = header.Content?.Clone(),
 2218            Extensions = header.Extensions.Clone(),
 2219            AllowReserved = header.AllowReserved
 2220        };
 2221        return clone;
 222    }
 223    /// <summary>
 224    /// Clones an OpenApiHeaderReference instance.
 225    /// </summary>
 226    /// <param name="header">The OpenApiHeaderReference to clone.</param>
 227    /// <returns>A new OpenApiHeaderReference instance with the same properties as the input header.</returns>
 228    public static OpenApiHeaderReference Clone(this OpenApiHeaderReference header)
 229    {
 0230        var clone = new OpenApiHeaderReference(header.Reference.Id!)
 0231        {
 0232            Description = header.Description,
 0233        };
 0234        return clone;
 235    }
 236    #endregion
 237    #region Response
 238
 239    /// <summary>
 240    /// Clones an OpenApiResponse instance.
 241    /// </summary>
 242    /// <param name="response">The OpenApiResponse to clone.</param>
 243    /// <returns>A new OpenApiResponse instance with the same properties as the input response.</returns>
 244    public static OpenApiResponse Clone(this OpenApiResponse response)
 245    {
 1246        var clone = new OpenApiResponse
 1247        {
 1248            Description = response.Description,
 1249            Headers = response.Headers?.Clone(),
 1250            Content = Clone(response.Content),
 1251            Links = response.Links.Clone(),
 1252            Extensions = response.Extensions.Clone()
 1253        };
 1254        return clone;
 255    }
 256    /// <summary>
 257    /// Clones an OpenApiResponseReference instance.
 258    /// </summary>
 259    /// <param name="response">The OpenApiResponseReference to clone.</param>
 260    /// <returns>A new OpenApiResponseReference instance with the same properties as the input response.</returns>
 261    public static OpenApiResponseReference Clone(this OpenApiResponseReference response)
 262    {
 0263        var clone = new OpenApiResponseReference(response.Reference.Id!)
 0264        {
 0265            Description = response.Description,
 0266        };
 0267        return clone;
 268    }
 269
 270    /// <summary>
 271    /// Clones an IOpenApiResponse instance.
 272    /// </summary>
 273    /// <param name="response"> The IOpenApiResponse instance to clone.</param>
 274    /// <returns>A cloned IOpenApiResponse instance.</returns>
 275    /// <exception cref="InvalidOperationException">Thrown when the IOpenApiResponse implementation is unsupported.</exc
 276    public static IOpenApiResponse Clone(this IOpenApiResponse response)
 277    {
 278        // Determine the actual type of IOpenApiResponse and clone accordingly
 0279        return response switch
 0280        {
 0281            OpenApiResponse resp => resp.Clone(),
 0282            OpenApiResponseReference respRef => respRef.Clone(),
 0283            _ => throw new InvalidOperationException("Unsupported IOpenApiResponse implementation."),
 0284        };
 285    }
 286
 287    #endregion
 288    #region MediaType
 289    /// <summary>
 290    /// Clones a dictionary of OpenApiMediaType instances.
 291    /// </summary>
 292    /// <param name="content">The dictionary to clone.</param>
 293    /// <returns>A new dictionary with cloned OpenApiMediaType instances.</returns>
 294    public static IDictionary<string, IOpenApiMediaType>? Clone(this IDictionary<string, IOpenApiMediaType>? content)
 295    {
 3296        if (content == null)
 297        {
 0298            return null;
 299        }
 300
 3301        var clone = new Dictionary<string, IOpenApiMediaType>();
 12302        foreach (var kvp in content)
 303        {
 3304            clone[kvp.Key] = kvp.Value.Clone();
 305        }
 3306        return clone;
 307    }
 308
 309    /// <summary>
 310    /// Clones an IOpenApiMediaType instance.
 311    /// </summary>
 312    /// <param name="mediaType"> The IOpenApiMediaType instance to clone.</param>
 313    /// <returns>A cloned IOpenApiMediaType instance.</returns>
 314    /// <exception cref="InvalidOperationException">Thrown when the IOpenApiMediaType implementation is unsupported.</ex
 315    public static IOpenApiMediaType Clone(this IOpenApiMediaType mediaType)
 316    {
 317        // Determine the actual type of IOpenApiParameter and clone accordingly
 4318        return mediaType switch
 4319        {
 4320            OpenApiMediaType media => media.Clone(),
 0321            OpenApiMediaTypeReference mediaRef => mediaRef.Clone(),
 0322            _ => throw new InvalidOperationException("Unsupported IOpenApiMediaType implementation."),
 4323        };
 324    }
 325    /// <summary>
 326    /// Clones an OpenApiMediaTypeReference instance.
 327    /// </summary>
 328    /// <param name="mediaType"> The OpenApiMediaTypeReference instance to clone.</param>
 329    /// <returns>A cloned OpenApiMediaTypeReference instance.</returns>
 330    public static OpenApiMediaTypeReference Clone(this OpenApiMediaTypeReference mediaType)
 331    {
 0332        var clone = new OpenApiMediaTypeReference(mediaType.Reference.Id!);
 0333        return clone;
 334    }
 335
 336    /// <summary>
 337    /// Clones an OpenApiMediaType instance.
 338    /// </summary>
 339    /// <param name="mediaType">The OpenApiMediaType instance to clone.</param>
 340    /// <returns>A cloned OpenApiMediaType instance.</returns>
 341    public static OpenApiMediaType Clone(this OpenApiMediaType mediaType)
 342    {
 5343        var clone = new OpenApiMediaType(mediaType);
 5344        return clone;
 345    }
 346
 347    #endregion
 348    #region Example
 349    /// <summary>
 350    /// Clones a dictionary of OpenApiExample instances.
 351    /// </summary>
 352    /// <param name="examples">The dictionary to clone.</param>
 353    /// <returns>A new dictionary with cloned OpenApiExample instances.</returns>
 354    public static IDictionary<string, IOpenApiExample>? Clone(this IDictionary<string, IOpenApiExample>? examples)
 355    {
 1356        if (examples == null)
 357        {
 0358            return null;
 359        }
 360
 1361        var clone = new Dictionary<string, IOpenApiExample>();
 4362        foreach (var kvp in examples)
 363        {
 1364            clone[kvp.Key] = kvp.Value switch
 1365            {
 1366                OpenApiExample exampleObj => exampleObj.Clone(),
 0367                OpenApiExampleReference exampleRef => exampleRef.Clone(),
 0368                _ => throw new InvalidOperationException("Unsupported IOpenApiExample implementation."),
 1369            };
 370        }
 1371        return clone;
 372    }
 373
 374    /// <summary>
 375    /// Clones an OpenApiExampleReference instance.
 376    /// </summary>
 377    /// <param name="example">The OpenApiExampleReference to clone.</param>
 378    /// <returns>A new OpenApiExampleReference instance with the same properties as the input instance.</returns>
 379    public static OpenApiExampleReference Clone(this OpenApiExampleReference example)
 380    {
 0381        var clone = new OpenApiExampleReference(example.Reference.Id!)
 0382        {
 0383            Description = example.Description,
 0384            Summary = example.Summary
 0385        };
 0386        return clone;
 387    }
 388
 389    /// <summary>
 390    /// Clones an OpenApiExample instance.
 391    /// </summary>
 392    /// <param name="example">The OpenApiExample to clone.</param>
 393    /// <returns>A new OpenApiExample instance with the same properties as the input example.</returns>
 394    public static OpenApiExample Clone(this OpenApiExample example)
 395    {
 4396        var clone = new OpenApiExample
 4397        {
 4398            Summary = example.Summary,
 4399            Description = example.Description,
 4400            Value = example.Value != null ? JsonNodeClone(example.Value) : null,
 4401            ExternalValue = example.ExternalValue,
 4402            Extensions = example.Extensions.Clone()
 4403        };
 4404        return clone;
 405    }
 406    #endregion
 407    #region Schema
 408    /// <summary>
 409    /// Clones an IOpenApiSchema instance.
 410    /// </summary>
 411    /// <param name="schema">The IOpenApiSchema to clone.</param>
 412    /// <returns>A new IOpenApiSchema instance with the same properties as the input schema.</returns>
 413    public static IOpenApiSchema Clone(this IOpenApiSchema schema) =>
 6414    schema switch
 6415    {
 0416        OpenApiSchemaReference schemaRef => schemaRef.Clone(),
 6417        OpenApiSchema schemaObj => schemaObj.Clone(),
 0418        _ => throw new InvalidOperationException("Unsupported IOpenApiSchema implementation.")
 6419    };
 420
 421    /// <summary>
 422    /// Clones an OpenApiSchema instance.
 423    /// </summary>
 424    /// <param name="schema">The OpenApiSchema to clone.</param>
 425    /// <returns>A new OpenApiSchema instance with the same properties as the input schema.</returns>
 426    public static OpenApiSchema Clone(this OpenApiSchema schema)
 427    {
 7428        var clone = new OpenApiSchema()
 7429        {
 7430            Title = schema.Title,
 7431            Id = schema.Id,
 7432            Const = schema.Const,
 7433            Schema = schema.Schema,
 7434            Comment = schema.Comment,
 7435            Vocabulary = schema.Vocabulary != null ? new Dictionary<string, bool>(schema.Vocabulary) : null,
 7436            DynamicAnchor = schema.DynamicAnchor,
 7437            DynamicRef = schema.DynamicRef,
 7438            Definitions = schema.Definitions.Clone(),
 7439            UnevaluatedProperties = schema.UnevaluatedProperties,
 7440            ExclusiveMaximum = schema.ExclusiveMaximum,
 7441            ExclusiveMinimum = schema.ExclusiveMinimum,
 7442
 7443            Type = schema.Type,
 7444            Format = schema.Format,
 7445            Description = schema.Description,
 7446            Maximum = schema.Maximum,
 7447            Minimum = schema.Minimum,
 7448            MaxLength = schema.MaxLength,
 7449            MinLength = schema.MinLength,
 7450            Pattern = schema.Pattern,
 7451            MultipleOf = schema.MultipleOf,
 7452            Default = JsonNodeClone(schema.Default),
 7453            ReadOnly = schema.ReadOnly,
 7454            WriteOnly = schema.WriteOnly,
 7455            AllOf = schema.AllOf?.Clone(),
 7456            OneOf = schema.OneOf?.Clone(),
 7457            AnyOf = schema.AnyOf?.Clone(),
 7458            Not = schema.Not?.Clone(),
 7459            Required = schema.Required != null ? new HashSet<string>(schema.Required) : null,
 7460            Items = schema.Items?.Clone(),
 7461            MaxItems = schema.MaxItems,
 7462            MinItems = schema.MinItems,
 7463            UniqueItems = schema.UniqueItems,
 7464            Properties = schema.Properties.Clone(),
 7465            PatternProperties = schema.PatternProperties?.Clone(),
 7466            MaxProperties = schema.MaxProperties,
 7467            MinProperties = schema.MinProperties,
 7468            AdditionalPropertiesAllowed = schema.AdditionalPropertiesAllowed,
 7469            AdditionalProperties = schema.AdditionalProperties?.Clone(),
 7470            Discriminator = schema.Discriminator != null ? new(schema.Discriminator) : null,
 7471            Example = schema.Example != null ? JsonNodeClone(schema.Example) : null,
 7472            Examples = schema.Examples != null ? [.. schema.Examples] : null,
 7473            Enum = schema.Enum != null ? [.. schema.Enum] : null,
 7474            ExternalDocs = schema.ExternalDocs != null ? new(schema.ExternalDocs) : null,
 7475            Deprecated = schema.Deprecated,
 7476            Xml = schema.Xml != null ? new(schema.Xml) : null,
 7477            Extensions = schema.Extensions.Clone(),
 7478            Metadata = schema is IMetadataContainer { Metadata: not null } mContainer ? new Dictionary<string, object>(m
 7479            UnrecognizedKeywords = schema.UnrecognizedKeywords != null ? new Dictionary<string, JsonNode>(schema.Unrecog
 7480            DependentRequired = schema.DependentRequired != null ? new Dictionary<string, HashSet<string>>(schema.Depend
 7481        };
 7482        return clone;
 483    }
 484    /// <summary>
 485    /// Clones an OpenApiSchemaReference instance.
 486    /// </summary>
 487    /// <param name="schemaRef">The OpenApiSchemaReference to clone</param>
 488    /// <returns>A new OpenApiSchemaReference instance with the same properties as the input instance.</returns>
 489    public static OpenApiSchemaReference Clone(this OpenApiSchemaReference schemaRef)
 490    {
 1491        var cloneRef = new OpenApiSchemaReference(referenceId: schemaRef.Reference.Id!)
 1492        {
 1493            Reference = schemaRef.Reference,
 1494            Title = schemaRef.Title,
 1495            Description = schemaRef.Description
 1496        };
 1497        return cloneRef;
 498    }
 499    /// <summary>
 500    /// Clones a list of OpenApiSchema instances.
 501    /// </summary>
 502    /// <param name="schemas">The list to clone.</param>
 503    /// <returns>A new list containing cloned OpenApiSchema instances.</returns>
 504    public static IList<IOpenApiSchema>? Clone(this IList<IOpenApiSchema>? schemas)
 505    {
 0506        if (schemas == null)
 507        {
 0508            return null;
 509        }
 0510        var cloneList = new List<IOpenApiSchema>();
 0511        foreach (var schema in schemas)
 512        {
 0513            cloneList.Add(schema.Clone());
 514        }
 0515        return cloneList;
 516    }
 517    /// <summary>
 518    /// Clones a dictionary of OpenApiSchema instances.
 519    /// </summary>
 520    /// <param name="schemas">The dictionary to clone.</param>
 521    /// <returns>A new dictionary containing cloned OpenApiSchema instances.</returns>
 522    public static Dictionary<string, IOpenApiSchema>? Clone(this IDictionary<string, IOpenApiSchema>? schemas)
 523    {
 15524        if (schemas == null)
 525        {
 12526            return null;
 527        }
 3528        var clone = new Dictionary<string, IOpenApiSchema>();
 12529        foreach (var kvp in schemas)
 530        {
 3531            clone[kvp.Key] = kvp.Value.Clone();
 532        }
 3533        return clone;
 534    }
 535    #endregion
 536
 537    #region Callback
 538    /// <summary>
 539    /// Clones an IOpenApiCallback instance.
 540    /// </summary>
 541    /// <param name="callback">The IOpenApiCallback to clone.</param>
 542    /// <returns>A new IOpenApiCallback instance with the same properties as the input callback.</returns>
 543    /// <exception cref="InvalidOperationException">Thrown when the callback is of an unsupported type.</exception>
 544    public static IOpenApiCallback Clone(this IOpenApiCallback callback) =>
 0545    callback switch
 0546    {
 0547        OpenApiCallback callbackObj => callbackObj.Clone(),
 0548        OpenApiCallbackReference callbackRef => callbackRef.Clone(),
 0549        _ => throw new InvalidOperationException("Unsupported IOpenApiCallback implementation.")
 0550    };
 551
 552    /// <summary>
 553    /// Clones an OpenApiCallback instance.
 554    /// </summary>
 555    /// <param name="callback">The OpenApiCallback to clone.</param>
 556    /// <returns>A new OpenApiCallback instance with the same properties as the input callback.</returns>
 557    public static OpenApiCallback Clone(this OpenApiCallback callback)
 558    {
 1559        var clone = new OpenApiCallback
 1560        {
 1561            PathItems = callback?.PathItems != null ? new(callback.PathItems) : null,
 1562            Extensions = callback?.Extensions.Clone()
 1563        };
 1564        return clone;
 565    }
 566
 567    /// <summary>
 568    /// Clones an OpenApiCallbackReference instance.
 569    /// </summary>
 570    /// <param name="callback">The OpenApiCallbackReference to clone.</param>
 571    /// <returns>A new OpenApiCallbackReference instance with the same properties as the input callback.</returns>
 572    public static OpenApiCallbackReference Clone(this OpenApiCallbackReference callback)
 573    {
 0574        var clone = new OpenApiCallbackReference(callback.Reference.Id!);
 0575        return clone;
 576    }
 577
 578    #endregion
 579    #region Link
 580    /// <summary>
 581    /// Clones a dictionary of IOpenApiLink instances.
 582    /// </summary>
 583    /// <param name="links">The dictionary of IOpenApiLink instances to clone.</param>
 584    /// <returns>A new dictionary containing cloned IOpenApiLink instances.</returns>
 585    public static IDictionary<string, IOpenApiLink>? Clone(this IDictionary<string, IOpenApiLink>? links)
 586    {
 1587        if (links == null)
 588        {
 0589            return null;
 590        }
 591
 1592        var clone = new Dictionary<string, IOpenApiLink>();
 4593        foreach (var kvp in links)
 594        {
 1595            clone[kvp.Key] = kvp.Value.Clone();
 596        }
 1597        return clone;
 598    }
 599
 600    /// <summary>
 601    /// Clones an IOpenApiLink instance.
 602    /// </summary>
 603    /// <param name="link">The IOpenApiLink to clone.</param>
 604    /// <returns>A new IOpenApiLink instance with the same properties as the input link.</returns>
 605    public static IOpenApiLink Clone(this IOpenApiLink link) =>
 1606    link switch
 1607    {
 1608        OpenApiLink linkObj => linkObj.Clone(),
 0609        OpenApiLinkReference linkRef => linkRef.Clone(),
 0610        _ => throw new InvalidOperationException("Unsupported IOpenApiLink implementation.")
 1611    };
 612
 613    /// <summary>
 614    /// Clones an OpenApiLinkReference instance.
 615    /// </summary>
 616    /// <param name="link">The OpenApiLinkReference instance to clone.</param>
 617    /// <returns>A new OpenApiLinkReference instance with the same properties as the input instance.</returns>
 618    public static OpenApiLinkReference Clone(this OpenApiLinkReference link)
 619    {
 0620        var clone = new OpenApiLinkReference(link.Reference.Id!)
 0621        {
 0622            Reference = link.Reference
 0623        };
 0624        return clone;
 625    }
 626
 627    /// <summary>
 628    /// Clones an OpenApiLink instance.
 629    /// </summary>
 630    /// <param name="link">The OpenApiLink instance to clone.</param>
 631    /// <returns>A new OpenApiLink instance with the same properties as the input instance.</returns>
 632    public static OpenApiLink Clone(this OpenApiLink link)
 633    {
 3634        var clone = new OpenApiLink
 3635        {
 3636            OperationRef = link.OperationRef,
 3637            OperationId = link.OperationId,
 3638            Parameters = link.Parameters.Clone(),
 3639            RequestBody = link.RequestBody!.Clone(),
 3640            Description = link.Description,
 3641            Server = link.Server?.Clone(),
 3642            Extensions = link.Extensions.Clone()
 3643        };
 3644        return clone;
 645    }
 646    #endregion
 647
 648    /// <summary>
 649    /// Clones an OpenApiServer instance.
 650    /// </summary>
 651    /// <param name="server">The OpenApiServer instance to clone.</param>
 652    /// <returns>A new OpenApiServer instance with the same properties as the input instance.</returns>
 653    public static OpenApiServer Clone(this OpenApiServer server)
 654    {
 0655        var clone = new OpenApiServer
 0656        {
 0657            Url = server.Url,
 0658            Description = server.Description,
 0659            Variables = server.Variables != null ? new Dictionary<string, OpenApiServerVariable>(server.Variables) : nul
 0660            Extensions = server.Extensions.Clone()
 0661        };
 0662        return clone;
 663    }
 664
 665    #region RuntimeExpression
 666    /// <summary>
 667    /// Clones a RuntimeExpressionAnyWrapper instance.
 668    /// </summary>
 669    /// <param name="expressionWrapper">The RuntimeExpressionAnyWrapper instance to clone.</param>
 670    /// <returns>A new RuntimeExpressionAnyWrapper instance with the same properties as the input instance.</returns>
 671    public static RuntimeExpressionAnyWrapper Clone(this RuntimeExpressionAnyWrapper expressionWrapper)
 672    {
 6673        return new RuntimeExpressionAnyWrapper
 6674        {
 6675            Expression = expressionWrapper.Expression,
 6676            Any = expressionWrapper.Any != null ? JsonNodeClone(expressionWrapper.Any) : null
 6677        };
 678    }
 679
 680    /// <summary>
 681    /// Clones a dictionary of RuntimeExpressionAnyWrapper instances.
 682    /// </summary>
 683    /// <param name="parameters">The dictionary of RuntimeExpressionAnyWrapper instances to clone.</param>
 684    /// <returns>A new dictionary that is a deep clone of the input dictionary.</returns>
 685    public static IDictionary<string, RuntimeExpressionAnyWrapper>? Clone(this IDictionary<string, RuntimeExpressionAnyW
 686    {
 3687        if (parameters == null)
 688        {
 0689            return null;
 690        }
 691
 3692        var clone = new Dictionary<string, RuntimeExpressionAnyWrapper>();
 12693        foreach (var kvp in parameters)
 694        {
 3695            clone[kvp.Key] = kvp.Value.Clone();
 696        }
 3697        return clone;
 698    }
 699
 700    #endregion
 701    #region JsonNode
 702    /// <summary>
 703    /// Clones a JsonNode instance.
 704    /// </summary>
 705    /// <param name="value">The JsonNode to clone.</param>
 706    /// <returns>A new JsonNode instance that is a deep clone of the input value.</returns>
 18707    public static JsonNode? JsonNodeClone(JsonNode? value) => value?.DeepClone();
 708    #endregion
 709}

Methods/Properties

Clone(Microsoft.OpenApi.OpenApiParameterReference)
Clone(Microsoft.OpenApi.OpenApiParameter)
Clone(Microsoft.OpenApi.IOpenApiParameter)
Clone(Microsoft.OpenApi.OpenApiRequestBodyReference)
Clone(Microsoft.OpenApi.OpenApiRequestBody)
ConvertToSchema(Microsoft.OpenApi.OpenApiRequestBody)
Clone(Microsoft.OpenApi.IOpenApiRequestBody)
Clone(System.Collections.Generic.IDictionary`2<System.String,Microsoft.OpenApi.IOpenApiExtension>)
Clone(Microsoft.OpenApi.IOpenApiExtension)
Clone(System.Collections.Generic.IDictionary`2<System.String,Microsoft.OpenApi.IOpenApiHeader>)
Clone(Microsoft.OpenApi.IOpenApiHeader)
Clone(Microsoft.OpenApi.OpenApiHeader)
Clone(Microsoft.OpenApi.OpenApiHeaderReference)
Clone(Microsoft.OpenApi.OpenApiResponse)
Clone(Microsoft.OpenApi.OpenApiResponseReference)
Clone(Microsoft.OpenApi.IOpenApiResponse)
Clone(System.Collections.Generic.IDictionary`2<System.String,Microsoft.OpenApi.IOpenApiMediaType>)
Clone(Microsoft.OpenApi.IOpenApiMediaType)
Clone(Microsoft.OpenApi.OpenApiMediaTypeReference)
Clone(Microsoft.OpenApi.OpenApiMediaType)
Clone(System.Collections.Generic.IDictionary`2<System.String,Microsoft.OpenApi.IOpenApiExample>)
Clone(Microsoft.OpenApi.OpenApiExampleReference)
Clone(Microsoft.OpenApi.OpenApiExample)
Clone(Microsoft.OpenApi.IOpenApiSchema)
Clone(Microsoft.OpenApi.OpenApiSchema)
Clone(Microsoft.OpenApi.OpenApiSchemaReference)
Clone(System.Collections.Generic.IList`1<Microsoft.OpenApi.IOpenApiSchema>)
Clone(System.Collections.Generic.IDictionary`2<System.String,Microsoft.OpenApi.IOpenApiSchema>)
Clone(Microsoft.OpenApi.IOpenApiCallback)
Clone(Microsoft.OpenApi.OpenApiCallback)
Clone(Microsoft.OpenApi.OpenApiCallbackReference)
Clone(System.Collections.Generic.IDictionary`2<System.String,Microsoft.OpenApi.IOpenApiLink>)
Clone(Microsoft.OpenApi.IOpenApiLink)
Clone(Microsoft.OpenApi.OpenApiLinkReference)
Clone(Microsoft.OpenApi.OpenApiLink)
Clone(Microsoft.OpenApi.OpenApiServer)
Clone(Microsoft.OpenApi.RuntimeExpressionAnyWrapper)
Clone(System.Collections.Generic.IDictionary`2<System.String,Microsoft.OpenApi.RuntimeExpressionAnyWrapper>)
JsonNodeClone(System.Text.Json.Nodes.JsonNode)