diff --git a/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs b/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs index 29cb684d2..176fb20d1 100644 --- a/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs +++ b/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System; @@ -135,5 +135,22 @@ public void ThrowsInvalidOperationExceptionInCreatePredicateWhenInvalidArguments var message2 = Assert.Throws(() => OpenApiFilterService.CreatePredicate("users.user.ListUser", "users.user")).Message; Assert.Equal("Cannot specify both operationIds and tags at the same time.", message2); } + + [Theory] + [InlineData("reports.getTeamsUserActivityUserDetail-a3f1", null)] + [InlineData(null, "reports.Functions")] + public void ReturnsPathParametersOnSlicingBasedOnOperationIdsOrTags(string operationIds, string tags) + { + // Act + var predicate = OpenApiFilterService.CreatePredicate(operationIds, tags); + var subsetOpenApiDocument = OpenApiFilterService.CreateFilteredDocument(_openApiDocumentMock, predicate); + + // Assert + foreach (var pathItem in subsetOpenApiDocument.Paths) + { + Assert.True(pathItem.Value.Parameters.Any()); + Assert.Equal(1, pathItem.Value.Parameters.Count); + } + } } } diff --git a/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/OpenApiDocumentMock.cs b/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/OpenApiDocumentMock.cs index d21fccb9a..58b85d91d 100644 --- a/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/OpenApiDocumentMock.cs +++ b/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/OpenApiDocumentMock.cs @@ -116,6 +116,21 @@ public static OpenApiDocument CreateOpenApiDocument() } } } + }, + Parameters = new List + { + { + new OpenApiParameter() + { + Name = "period", + In = ParameterLocation.Path, + Required = true, + Schema = new OpenApiSchema() + { + Type = "string" + } + } + } } }, ["/reports/microsoft.graph.getTeamsUserActivityUserDetail(date={date})"] = new OpenApiPathItem() @@ -175,7 +190,20 @@ public static OpenApiDocument CreateOpenApiDocument() } } } - } + }, + Parameters = new List + { + new OpenApiParameter + { + Name = "period", + In = ParameterLocation.Path, + Required = true, + Schema = new OpenApiSchema() + { + Type = "string" + } + } + } }, ["/users"] = new OpenApiPathItem() { diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 7f0f6e9c0..bfc937cba 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -3,6 +3,6 @@ $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb - + \ No newline at end of file diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index 1cb71a20a..cb67b1211 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -15,7 +15,7 @@ Microsoft.OpenApi.Hidi hidi ./../../artifacts - 1.0.0-preview8 + 1.0.0-preview9 OpenAPI.NET CLI tool for slicing OpenAPI documents © Microsoft Corporation. All rights reserved. OpenAPI .NET @@ -43,7 +43,7 @@ - + @@ -51,8 +51,4 @@ - - - - diff --git a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj index e9d3ba283..072fdcbf1 100644 --- a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj +++ b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj @@ -33,10 +33,6 @@ true - - - - diff --git a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj index 96dae450b..5b0cbf1e4 100644 --- a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj +++ b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj @@ -7,7 +7,6 @@ true - all diff --git a/src/Microsoft.OpenApi/Any/OpenApiAnyCloneHelper.cs b/src/Microsoft.OpenApi/Any/OpenApiAnyCloneHelper.cs new file mode 100644 index 000000000..4a67e074e --- /dev/null +++ b/src/Microsoft.OpenApi/Any/OpenApiAnyCloneHelper.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. + +using System.Reflection; + +namespace Microsoft.OpenApi.Any +{ + /// + /// Contains logic for cloning objects through copy constructors. + /// + public class OpenApiAnyCloneHelper + { + /// + /// Clones an instance of object from the copy constructor + /// + /// The object instance. + /// A clone copy or the object itself. + public static IOpenApiAny CloneFromCopyConstructor(IOpenApiAny obj) + { + if (obj != null) + { + var t = obj.GetType(); + foreach (ConstructorInfo ci in t.GetConstructors()) + { + ParameterInfo[] pi = ci.GetParameters(); + if (pi.Length == 1 && pi[0].ParameterType == t) + { + return (IOpenApiAny)ci.Invoke(new object[] { obj }); + } + } + } + + return obj; + } + } +} diff --git a/src/Microsoft.OpenApi/Any/OpenApiArray.cs b/src/Microsoft.OpenApi/Any/OpenApiArray.cs index 5ef0087f2..2c877d631 100644 --- a/src/Microsoft.OpenApi/Any/OpenApiArray.cs +++ b/src/Microsoft.OpenApi/Any/OpenApiArray.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. using Microsoft.OpenApi.Writers; +using System; using System.Collections.Generic; namespace Microsoft.OpenApi.Any @@ -16,6 +17,19 @@ public class OpenApiArray : List, IOpenApiAny /// public AnyType AnyType { get; } = AnyType.Array; + /// + /// Parameterless constructor + /// + public OpenApiArray() { } + + /// + /// Initializes a copy of object + /// + public OpenApiArray(OpenApiArray array) + { + AnyType = array.AnyType; + } + /// /// Write out contents of OpenApiArray to passed writer /// diff --git a/src/Microsoft.OpenApi/Any/OpenApiNull.cs b/src/Microsoft.OpenApi/Any/OpenApiNull.cs index 229409d95..f1772c3e4 100644 --- a/src/Microsoft.OpenApi/Any/OpenApiNull.cs +++ b/src/Microsoft.OpenApi/Any/OpenApiNull.cs @@ -15,6 +15,19 @@ public class OpenApiNull : IOpenApiAny /// public AnyType AnyType { get; } = AnyType.Null; + /// + /// Parameterless constructor + /// + public OpenApiNull() { } + + /// + /// Initializes a copy of object + /// + public OpenApiNull(OpenApiNull openApiNull) + { + AnyType = openApiNull.AnyType; + } + /// /// Write out null representation /// diff --git a/src/Microsoft.OpenApi/Any/OpenApiObject.cs b/src/Microsoft.OpenApi/Any/OpenApiObject.cs index cd2f6ee64..d7e56e341 100644 --- a/src/Microsoft.OpenApi/Any/OpenApiObject.cs +++ b/src/Microsoft.OpenApi/Any/OpenApiObject.cs @@ -16,6 +16,19 @@ public class OpenApiObject : Dictionary, IOpenApiAny /// public AnyType AnyType { get; } = AnyType.Object; + /// + /// Parameterless constructor + /// + public OpenApiObject() { } + + /// + /// Initializes a copy of object + /// + public OpenApiObject(OpenApiObject obj) + { + AnyType = obj.AnyType; + } + /// /// Serialize OpenApiObject to writer /// diff --git a/src/Microsoft.OpenApi/Any/OpenApiPrimitive.cs b/src/Microsoft.OpenApi/Any/OpenApiPrimitive.cs index b6a111e35..e0abda167 100644 --- a/src/Microsoft.OpenApi/Any/OpenApiPrimitive.cs +++ b/src/Microsoft.OpenApi/Any/OpenApiPrimitive.cs @@ -24,6 +24,15 @@ public OpenApiPrimitive(T value) Value = value; } + /// + /// Initializes a copy of an object + /// + /// + public OpenApiPrimitive(OpenApiPrimitive openApiPrimitive) + { + Value = openApiPrimitive.Value; + } + /// /// The kind of . /// diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj index 933b2bdb2..b30c7c1ca 100644 --- a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj +++ b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj @@ -34,10 +34,6 @@ true - - - - True diff --git a/src/Microsoft.OpenApi/Models/OpenApiCallback.cs b/src/Microsoft.OpenApi/Models/OpenApiCallback.cs index 57aa3c888..e9701b17c 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiCallback.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiCallback.cs @@ -35,6 +35,22 @@ public class OpenApiCallback : IOpenApiSerializable, IOpenApiReferenceable, IOpe /// public IDictionary Extensions { get; set; } = new Dictionary(); + /// + /// Parameter-less constructor + /// + public OpenApiCallback() { } + + /// + /// Initializes a copy of an object + /// + public OpenApiCallback(OpenApiCallback callback) + { + PathItems = new(callback.PathItems); + UnresolvedReference = callback.UnresolvedReference; + Reference = new(callback.Reference); + Extensions = new Dictionary(callback.Extensions); + } + /// /// Add a into the . /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiComponents.cs b/src/Microsoft.OpenApi/Models/OpenApiComponents.cs index cd8cdae74..c23e569c5 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiComponents.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiComponents.cs @@ -68,6 +68,28 @@ public class OpenApiComponents : IOpenApiSerializable, IOpenApiExtensible /// public IDictionary Extensions { get; set; } = new Dictionary(); + /// + /// Parameter-less constructor + /// + public OpenApiComponents() { } + + /// + /// Initializes a copy of an object + /// + public OpenApiComponents(OpenApiComponents components) + { + Schemas = new Dictionary(components.Schemas); + Responses = new Dictionary(components.Responses); + Parameters = new Dictionary(components.Parameters); + Examples = new Dictionary(components.Examples); + RequestBodies = new Dictionary(components.RequestBodies); + Headers = new Dictionary(components.Headers); + SecuritySchemes = new Dictionary(components.SecuritySchemes); + Links = new Dictionary(components.Links); + Callbacks = new Dictionary(components.Callbacks); + Extensions = new Dictionary(components.Extensions); + } + /// /// Serialize to Open Api v3.0. /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiContact.cs b/src/Microsoft.OpenApi/Models/OpenApiContact.cs index 848560ead..9447d424e 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiContact.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiContact.cs @@ -35,6 +35,22 @@ public class OpenApiContact : IOpenApiSerializable, IOpenApiExtensible /// public IDictionary Extensions { get; set; } = new Dictionary(); + /// + /// Parameter-less constructor + /// + public OpenApiContact() { } + + /// + /// Initializes a copy of an instance + /// + public OpenApiContact(OpenApiContact contact) + { + Name = contact.Name; + Url = new Uri(contact.Url.OriginalString); + Email = contact.Email; + Extensions = new Dictionary(contact.Extensions); + } + /// /// Serialize to Open Api v3.0 /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiDiscriminator.cs b/src/Microsoft.OpenApi/Models/OpenApiDiscriminator.cs index a0739dc25..e03c7d59a 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiDiscriminator.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiDiscriminator.cs @@ -22,6 +22,20 @@ public class OpenApiDiscriminator : IOpenApiSerializable /// public IDictionary Mapping { get; set; } = new Dictionary(); + /// + /// Parameter-less constructor + /// + public OpenApiDiscriminator() { } + + /// + /// Initializes a copy of an instance + /// + public OpenApiDiscriminator(OpenApiDiscriminator discriminator) + { + PropertyName = discriminator.PropertyName; + Mapping = new Dictionary(discriminator.Mapping); + } + /// /// Serialize to Open Api v3.0 /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs index 59b8da16c..44cbc71ab 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs @@ -4,8 +4,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Runtime.CompilerServices; -using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Exceptions; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Services; @@ -64,6 +62,27 @@ public class OpenApiDocument : IOpenApiSerializable, IOpenApiExtensible /// public IDictionary Extensions { get; set; } = new Dictionary(); + /// + /// Parameter-less constructor + /// + public OpenApiDocument() {} + + /// + /// Initializes a copy of an an object + /// + public OpenApiDocument(OpenApiDocument document) + { + Workspace = new(document.Workspace); + Info = new(document.Info); + Servers = new List(document.Servers); + Paths = new(document.Paths); + Components = new(document.Components); + SecurityRequirements = new List(document.SecurityRequirements); + Tags = new List(document.Tags); + ExternalDocs = new(document.ExternalDocs); + Extensions = new Dictionary(document.Extensions); + } + /// /// Serialize to the latest patch of OpenAPI object V3.0. /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiEncoding.cs b/src/Microsoft.OpenApi/Models/OpenApiEncoding.cs index 0d02c384e..533cb7e80 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiEncoding.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiEncoding.cs @@ -53,6 +53,24 @@ public class OpenApiEncoding : IOpenApiSerializable, IOpenApiExtensible /// public IDictionary Extensions { get; set; } = new Dictionary(); + /// + /// Parameter-less constructor + /// + public OpenApiEncoding() {} + + /// + /// Initializes a copy of an object + /// + public OpenApiEncoding(OpenApiEncoding encoding) + { + ContentType = encoding.ContentType; + Headers = new Dictionary(encoding.Headers); + Style = encoding.Style; + Explode = encoding.Explode; + AllowReserved = encoding.AllowReserved; + Extensions = new Dictionary(encoding.Extensions); + } + /// /// Serialize to Open Api v3.0. /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiError.cs b/src/Microsoft.OpenApi/Models/OpenApiError.cs index 98bf7ec82..82f2a14df 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiError.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiError.cs @@ -26,6 +26,15 @@ public OpenApiError(string pointer, string message) Message = message; } + /// + /// Initializes a copy of an object + /// + public OpenApiError(OpenApiError error) + { + Pointer = error.Pointer; + Message = error.Message; + } + /// /// Message explaining the error. /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiExample.cs b/src/Microsoft.OpenApi/Models/OpenApiExample.cs index d4c268584..5e105be26 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiExample.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiExample.cs @@ -54,6 +54,25 @@ public class OpenApiExample : IOpenApiSerializable, IOpenApiReferenceable, IOpen /// public bool UnresolvedReference { get; set; } = false; + /// + /// Parameter-less constructor + /// + public OpenApiExample() {} + + /// + /// Initializes a copy of object + /// + public OpenApiExample(OpenApiExample example) + { + Summary = example.Summary; + Description = example.Description; + Value = OpenApiAnyCloneHelper.CloneFromCopyConstructor(example.Value); + ExternalValue = example.ExternalValue; + Extensions = new Dictionary(example.Extensions); + Reference = new(example.Reference); + UnresolvedReference = example.UnresolvedReference; + } + /// /// Serialize to Open Api v3.0 /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiExternalDocs.cs b/src/Microsoft.OpenApi/Models/OpenApiExternalDocs.cs index a47fb9906..95af8f01b 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiExternalDocs.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiExternalDocs.cs @@ -29,6 +29,21 @@ public class OpenApiExternalDocs : IOpenApiSerializable, IOpenApiExtensible /// public IDictionary Extensions { get; set; } = new Dictionary(); + /// + /// Parameter-less constructor + /// + public OpenApiExternalDocs() {} + + /// + /// Initializes a copy of an object + /// + public OpenApiExternalDocs(OpenApiExternalDocs externalDocs) + { + Description = externalDocs.Description; + Url = new Uri(externalDocs.Url.OriginalString); + Extensions = new Dictionary(externalDocs.Extensions); + } + /// /// Serialize to Open Api v3.0. /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiHeader.cs b/src/Microsoft.OpenApi/Models/OpenApiHeader.cs index e8576a0ca..b91440df8 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiHeader.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiHeader.cs @@ -86,6 +86,32 @@ public class OpenApiHeader : IOpenApiSerializable, IOpenApiReferenceable, IOpenA /// public IDictionary Extensions { get; set; } = new Dictionary(); + /// + /// Parameter-less constructor + /// + public OpenApiHeader() {} + + /// + /// Initializes a copy of an object + /// + public OpenApiHeader(OpenApiHeader header) + { + UnresolvedReference = header.UnresolvedReference; + Reference = new(header.Reference); + Description = header.Description; + Required = header.Required; + Deprecated = header.Deprecated; + AllowEmptyValue = header.AllowEmptyValue; + Style = header.Style; + Explode = header.Explode; + AllowReserved = header.AllowReserved; + Schema = new(header.Schema); + Example = OpenApiAnyCloneHelper.CloneFromCopyConstructor(header.Example); + Examples = new Dictionary(header.Examples); + Content = new Dictionary(header.Content); + Extensions = new Dictionary(header.Extensions); + } + /// /// Serialize to Open Api v3.0 /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiInfo.cs b/src/Microsoft.OpenApi/Models/OpenApiInfo.cs index 17364ba3b..c5a44c448 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiInfo.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiInfo.cs @@ -49,6 +49,25 @@ public class OpenApiInfo : IOpenApiSerializable, IOpenApiExtensible /// public IDictionary Extensions { get; set; } = new Dictionary(); + /// + /// Parameter-less constructor + /// + public OpenApiInfo() {} + + /// + /// Initializes a copy of an object + /// + public OpenApiInfo(OpenApiInfo info) + { + Title = info.Title; + Description = info.Description; + Version = info.Version; + TermsOfService = info.TermsOfService; + Contact = new(info.Contact); + License = new(info.License); + Extensions = new Dictionary(info.Extensions); + } + /// /// Serialize to Open Api v3.0 /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiLicense.cs b/src/Microsoft.OpenApi/Models/OpenApiLicense.cs index 0de7540c8..431789aac 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiLicense.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiLicense.cs @@ -29,6 +29,21 @@ public class OpenApiLicense : IOpenApiSerializable, IOpenApiExtensible /// public IDictionary Extensions { get; set; } = new Dictionary(); + /// + /// Parameterless constructor + /// + public OpenApiLicense() {} + + /// + /// Initializes a copy of an object + /// + public OpenApiLicense(OpenApiLicense license) + { + Name = license.Name; + Url = new Uri(license.Url.OriginalString); + Extensions = new Dictionary(license.Extensions); + } + /// /// Serialize to Open Api v3.0 /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiLink.cs b/src/Microsoft.OpenApi/Models/OpenApiLink.cs index f5acb0d3f..6ba3a65fd 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiLink.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiLink.cs @@ -61,6 +61,27 @@ public class OpenApiLink : IOpenApiSerializable, IOpenApiReferenceable, IOpenApi /// public OpenApiReference Reference { get; set; } + /// + /// Parameterless constructor + /// + public OpenApiLink() {} + + /// + /// Initializes a copy of an object + /// + public OpenApiLink(OpenApiLink link) + { + OperationRef = link.OperationRef; + OperationId = link.OperationId; + Parameters = new(link.Parameters); + RequestBody = new(link.RequestBody); + Description = link.Description; + Server = new(link.Server); + Extensions = new Dictionary(link.Extensions); + UnresolvedReference = link.UnresolvedReference; + Reference = new(link.Reference); + } + /// /// Serialize to Open Api v3.0 /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs b/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs index 414f46b30..94dcbdfa7 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiMediaType.cs @@ -43,6 +43,23 @@ public class OpenApiMediaType : IOpenApiSerializable, IOpenApiExtensible /// public IDictionary Extensions { get; set; } = new Dictionary(); + /// + /// Parameterless constructor + /// + public OpenApiMediaType() {} + + /// + /// Initializes a copy of an object + /// + public OpenApiMediaType(OpenApiMediaType mediaType) + { + Schema = new(mediaType.Schema); + Example = OpenApiAnyCloneHelper.CloneFromCopyConstructor(mediaType.Example); + Examples = new Dictionary(mediaType.Examples); + Encoding = new Dictionary(mediaType.Encoding); + Extensions = new Dictionary(mediaType.Extensions); + } + /// /// Serialize to Open Api v3.0. /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiOAuthFlow.cs b/src/Microsoft.OpenApi/Models/OpenApiOAuthFlow.cs index e478944aa..02856d4cd 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiOAuthFlow.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiOAuthFlow.cs @@ -41,6 +41,23 @@ public class OpenApiOAuthFlow : IOpenApiSerializable, IOpenApiExtensible /// public IDictionary Extensions { get; set; } = new Dictionary(); + /// + /// Parameterless constructor + /// + public OpenApiOAuthFlow() {} + + /// + /// Initializes a copy of an object + /// + public OpenApiOAuthFlow(OpenApiOAuthFlow oAuthFlow) + { + AuthorizationUrl = new Uri(oAuthFlow.AuthorizationUrl.OriginalString); + TokenUrl = new Uri(oAuthFlow.TokenUrl.OriginalString); + RefreshUrl = new Uri(oAuthFlow.RefreshUrl.OriginalString); + Scopes = new Dictionary(oAuthFlow.Scopes); + Extensions = new Dictionary(oAuthFlow.Extensions); + } + /// /// Serialize to Open Api v3.0 /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiOAuthFlows.cs b/src/Microsoft.OpenApi/Models/OpenApiOAuthFlows.cs index fa2db10db..973a403e0 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiOAuthFlows.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiOAuthFlows.cs @@ -38,6 +38,24 @@ public class OpenApiOAuthFlows : IOpenApiSerializable, IOpenApiExtensible /// public IDictionary Extensions { get; set; } = new Dictionary(); + /// + /// Parameterless constructor + /// + public OpenApiOAuthFlows() {} + + /// + /// Initializes a copy of an object + /// + /// + public OpenApiOAuthFlows(OpenApiOAuthFlows oAuthFlows) + { + Implicit = new(oAuthFlows.Implicit); + Password = new(oAuthFlows.Password); + ClientCredentials = new(oAuthFlows.ClientCredentials); + AuthorizationCode = new(oAuthFlows.AuthorizationCode); + Extensions = new Dictionary(oAuthFlows.Extensions); + } + /// /// Serialize to Open Api v3.0 /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiOperation.cs b/src/Microsoft.OpenApi/Models/OpenApiOperation.cs index f17f81328..775532684 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiOperation.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiOperation.cs @@ -106,6 +106,31 @@ public class OpenApiOperation : IOpenApiSerializable, IOpenApiExtensible /// public IDictionary Extensions { get; set; } = new Dictionary(); + /// + /// Parameterless constructor + /// + public OpenApiOperation() {} + + /// + /// Initializes a copy of an object + /// + public OpenApiOperation(OpenApiOperation operation) + { + Tags = new List(operation.Tags); + Summary = operation.Summary; + Description = operation.Description; + ExternalDocs = new(operation.ExternalDocs); + OperationId = operation.OperationId; + Parameters = new List(operation.Parameters); + RequestBody = new(operation.RequestBody); + Responses = new(operation.Responses); + Callbacks = new Dictionary(operation.Callbacks); + Deprecated = operation.Deprecated; + Security = new List(operation.Security); + Servers = new List(operation.Servers); + Extensions = new Dictionary(operation.Extensions); + } + /// /// Serialize to Open Api v3.0. /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiParameter.cs b/src/Microsoft.OpenApi/Models/OpenApiParameter.cs index 12f37f61a..f0b21b0d9 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiParameter.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiParameter.cs @@ -136,6 +136,34 @@ public bool Explode /// public IDictionary Extensions { get; set; } = new Dictionary(); + /// + /// A parameterless constructor + /// + public OpenApiParameter() {} + + /// + /// Initializes a clone instance of object + /// + public OpenApiParameter(OpenApiParameter parameter) + { + UnresolvedReference = parameter.UnresolvedReference; + Reference = new(parameter.Reference); + Name = parameter.Name; + In = parameter.In; + Description = parameter.Description; + Required = parameter.Required; + Style = parameter.Style; + Explode = parameter.Explode; + AllowReserved = parameter.AllowReserved; + Schema = new(parameter.Schema); + Examples = new Dictionary(parameter.Examples); + Example = OpenApiAnyCloneHelper.CloneFromCopyConstructor(parameter.Example); + Content = new Dictionary(parameter.Content); + Extensions = new Dictionary(parameter.Extensions); + AllowEmptyValue = parameter.AllowEmptyValue; + Deprecated = parameter.Deprecated; + } + /// /// Serialize to Open Api v3.0 /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiPathItem.cs b/src/Microsoft.OpenApi/Models/OpenApiPathItem.cs index 375f1f034..8ce83c9eb 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiPathItem.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiPathItem.cs @@ -65,6 +65,26 @@ public void AddOperation(OperationType operationType, OpenApiOperation operation Operations[operationType] = operation; } + /// + /// Parameterless constructor + /// + public OpenApiPathItem() {} + + /// + /// Initializes a clone of an object + /// + public OpenApiPathItem(OpenApiPathItem pathItem) + { + Summary = pathItem.Summary; + Description = pathItem.Description; + Operations = new Dictionary(pathItem.Operations); + Servers = new List(pathItem.Servers); + Parameters = new List(pathItem.Parameters); + Extensions = new Dictionary(pathItem.Extensions); + UnresolvedReference = pathItem.UnresolvedReference; + Reference = new(pathItem.Reference); + } + /// /// Serialize to Open Api v3.0 /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiPaths.cs b/src/Microsoft.OpenApi/Models/OpenApiPaths.cs index 72d0576d3..f65ccb9c4 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiPaths.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiPaths.cs @@ -8,5 +8,15 @@ namespace Microsoft.OpenApi.Models /// public class OpenApiPaths : OpenApiExtensibleDictionary { + /// + /// Parameterless constructor + /// + public OpenApiPaths() {} + + /// + /// Initializes a copy of object + /// + public OpenApiPaths(OpenApiPaths paths) {} + } } diff --git a/src/Microsoft.OpenApi/Models/OpenApiReference.cs b/src/Microsoft.OpenApi/Models/OpenApiReference.cs index 3f1370800..9213e77bc 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiReference.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiReference.cs @@ -112,6 +112,22 @@ public string ReferenceV2 } } + /// + /// Parameterless constructor + /// + public OpenApiReference() {} + + /// + /// Initializes a copy instance of the object + /// + public OpenApiReference(OpenApiReference reference) + { + ExternalResource = reference.ExternalResource; + Type = reference.Type; + Id = reference.Id; + HostDocument = new(reference.HostDocument); + } + /// /// Serialize to Open Api v3.0. /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs b/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs index 8a65f1fde..b82b67e8a 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs @@ -45,6 +45,24 @@ public class OpenApiRequestBody : IOpenApiSerializable, IOpenApiReferenceable, I /// public IDictionary Extensions { get; set; } = new Dictionary(); + /// + /// Parameter-less constructor + /// + public OpenApiRequestBody() { } + + /// + /// Initializes a copy instance of an object + /// + public OpenApiRequestBody(OpenApiRequestBody requestBody) + { + UnresolvedReference = requestBody.UnresolvedReference; + Reference = new(requestBody.Reference); + Description = requestBody.Description; + Required = requestBody.Required; + Content = new Dictionary(requestBody.Content); + Extensions = new Dictionary(requestBody.Extensions); + } + /// /// Serialize to Open Api v3.0 /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiResponse.cs b/src/Microsoft.OpenApi/Models/OpenApiResponse.cs index 0a31ca0a4..cf0c796e6 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiResponse.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiResponse.cs @@ -51,6 +51,25 @@ public class OpenApiResponse : IOpenApiSerializable, IOpenApiReferenceable, IOpe /// public OpenApiReference Reference { get; set; } + /// + /// Parameterless constructor + /// + public OpenApiResponse() {} + + /// + /// Initializes a copy of object + /// + public OpenApiResponse(OpenApiResponse response) + { + Description = response.Description; + Headers = new Dictionary(response.Headers); + Content = new Dictionary(response.Content); + Links = new Dictionary(response.Links); + Extensions = new Dictionary(response.Extensions); + UnresolvedReference = response.UnresolvedReference; + Reference = new(response.Reference); + } + /// /// Serialize to Open Api v3.0. /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiResponses.cs b/src/Microsoft.OpenApi/Models/OpenApiResponses.cs index 818bf4ced..24f4eba0d 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiResponses.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiResponses.cs @@ -8,5 +8,15 @@ namespace Microsoft.OpenApi.Models /// public class OpenApiResponses : OpenApiExtensibleDictionary { + /// + /// Parameterless constructor + /// + public OpenApiResponses() { } + + /// + /// Initializes a copy of object + /// + public OpenApiResponses(OpenApiResponses openApiResponses) { } + } } diff --git a/src/Microsoft.OpenApi/Models/OpenApiSchema.cs b/src/Microsoft.OpenApi/Models/OpenApiSchema.cs index 036222261..d43756887 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiSchema.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiSchema.cs @@ -242,6 +242,56 @@ public class OpenApiSchema : IOpenApiSerializable, IOpenApiReferenceable, IEffec /// public OpenApiReference Reference { get; set; } + /// + /// Parameterless constructor + /// + public OpenApiSchema() {} + + /// + /// Initializes a copy of object + /// + public OpenApiSchema(OpenApiSchema schema) + { + Title = schema.Title; + Type = schema.Type; + Format = schema.Format; + Description = schema.Description; + Maximum = schema.Maximum; + ExclusiveMaximum = schema.ExclusiveMaximum; + Minimum = schema.Minimum; + ExclusiveMinimum = schema.ExclusiveMinimum; + MaxLength = schema.MaxLength; + MinLength = schema.MinLength; + Pattern = schema.Pattern; + MultipleOf = schema.MultipleOf; + Default = OpenApiAnyCloneHelper.CloneFromCopyConstructor(schema.Default); + ReadOnly = schema.ReadOnly; + WriteOnly = schema.WriteOnly; + AllOf = new List(schema.AllOf); + OneOf = new List(schema.OneOf); + AnyOf = new List(schema.AnyOf); + Not = new(schema.Not); + Required = new HashSet(schema.Required); + Items = new(schema.Items); + MaxItems = schema.MaxItems; + MinItems = schema.MinItems; + UniqueItems = schema.UniqueItems; + Properties = new Dictionary(schema.Properties); + MaxProperties = schema.MaxProperties; + MinProperties = schema.MinProperties; + AdditionalPropertiesAllowed = schema.AdditionalPropertiesAllowed; + AdditionalProperties = new(schema.AdditionalProperties); + Discriminator = new(schema.Discriminator); + Example = OpenApiAnyCloneHelper.CloneFromCopyConstructor(schema.Example); + Enum = new List(schema.Enum); + Nullable = schema.Nullable; + ExternalDocs = new(schema.ExternalDocs); + Deprecated = schema.Deprecated; + Xml = new(schema.Xml); + UnresolvedReference = schema.UnresolvedReference; + Reference = new(schema.Reference); + } + /// /// Serialize to Open Api v3.0 /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs b/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs index 902ce19bc..b87adf573 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs @@ -74,6 +74,29 @@ public class OpenApiSecurityScheme : IOpenApiSerializable, IOpenApiReferenceable /// public OpenApiReference Reference { get; set; } + /// + /// Parameterless constructor + /// + public OpenApiSecurityScheme() {} + + /// + /// Initializes a copy of object + /// + public OpenApiSecurityScheme(OpenApiSecurityScheme securityScheme) + { + Type = securityScheme.Type; + Description = securityScheme.Description; + Name = securityScheme.Name; + In = securityScheme.In; + Scheme = securityScheme.Scheme; + BearerFormat = securityScheme.BearerFormat; + Flows = new(securityScheme.Flows); + OpenIdConnectUrl = new Uri(securityScheme.OpenIdConnectUrl.OriginalString); + Extensions = new Dictionary(securityScheme.Extensions); + UnresolvedReference = securityScheme.UnresolvedReference; + Reference = new(securityScheme.Reference); + } + /// /// Serialize to Open Api v3.0 /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiServer.cs b/src/Microsoft.OpenApi/Models/OpenApiServer.cs index ea988ec13..875bef5c7 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiServer.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiServer.cs @@ -36,6 +36,22 @@ public class OpenApiServer : IOpenApiSerializable, IOpenApiExtensible /// public IDictionary Extensions { get; set; } = new Dictionary(); + /// + /// Parameterless constructor + /// + public OpenApiServer() {} + + /// + /// Initializes a copy of an object + /// + public OpenApiServer(OpenApiServer server) + { + Description = server.Description; + Url = server.Url; + Variables = new Dictionary(server.Variables); + Extensions = new Dictionary(server.Extensions); + } + /// /// Serialize to Open Api v3.0 /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiServerVariable.cs b/src/Microsoft.OpenApi/Models/OpenApiServerVariable.cs index 8ae39a04c..b1f222e83 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiServerVariable.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiServerVariable.cs @@ -34,6 +34,22 @@ public class OpenApiServerVariable : IOpenApiSerializable, IOpenApiExtensible /// public IDictionary Extensions { get; set; } = new Dictionary(); + /// + /// Parameterless constructor + /// + public OpenApiServerVariable() {} + + /// + /// Initializes a copy of an object + /// + public OpenApiServerVariable(OpenApiServerVariable serverVariable) + { + Description = serverVariable.Description; + Default = serverVariable.Default; + Enum = new List(serverVariable.Enum); + Extensions = new Dictionary(serverVariable.Extensions); + } + /// /// Serialize to Open Api v3.0 /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiTag.cs b/src/Microsoft.OpenApi/Models/OpenApiTag.cs index 4d743a13a..5ecfa0363 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiTag.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiTag.cs @@ -43,6 +43,24 @@ public class OpenApiTag : IOpenApiSerializable, IOpenApiReferenceable, IOpenApiE /// public OpenApiReference Reference { get; set; } + /// + /// Parameterless constructor + /// + public OpenApiTag() {} + + /// + /// Initializes a copy of an object + /// + public OpenApiTag(OpenApiTag tag) + { + Name = tag.Name; + Description = tag.Description; + ExternalDocs = new(tag.ExternalDocs); + Extensions = new Dictionary(tag.Extensions); + UnresolvedReference = tag.UnresolvedReference; + Reference = new(tag.Reference); + } + /// /// Serialize to Open Api v3.0 /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiXml.cs b/src/Microsoft.OpenApi/Models/OpenApiXml.cs index 59218970f..eb48132ad 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiXml.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiXml.cs @@ -46,6 +46,24 @@ public class OpenApiXml : IOpenApiSerializable, IOpenApiExtensible /// public IDictionary Extensions { get; set; } = new Dictionary(); + /// + /// Parameterless constructor + /// + public OpenApiXml() {} + + /// + /// Initializes a copy of an object + /// + public OpenApiXml(OpenApiXml xml) + { + Name = xml.Name; + Namespace = xml.Namespace; + Prefix = xml.Prefix; + Attribute = xml.Attribute; + Wrapped = xml.Wrapped; + Extensions = new Dictionary(xml.Extensions); + } + /// /// Serialize to Open Api v3.0 /// diff --git a/src/Microsoft.OpenApi/Models/RuntimeExpressionAnyWrapper.cs b/src/Microsoft.OpenApi/Models/RuntimeExpressionAnyWrapper.cs index 12a525b4f..85c64dd30 100644 --- a/src/Microsoft.OpenApi/Models/RuntimeExpressionAnyWrapper.cs +++ b/src/Microsoft.OpenApi/Models/RuntimeExpressionAnyWrapper.cs @@ -16,6 +16,20 @@ public class RuntimeExpressionAnyWrapper : IOpenApiElement private IOpenApiAny _any; private RuntimeExpression _expression; + /// + /// Parameterless constructor + /// + public RuntimeExpressionAnyWrapper() {} + + /// + /// Initializes a copy of an object + /// + public RuntimeExpressionAnyWrapper(RuntimeExpressionAnyWrapper runtimeExpressionAnyWrapper) + { + Any = OpenApiAnyCloneHelper.CloneFromCopyConstructor(runtimeExpressionAnyWrapper.Any); + Expression = runtimeExpressionAnyWrapper.Expression; + } + /// /// Gets/Sets the /// diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs index 11dcaec14..7b9df3d0e 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs @@ -164,6 +164,14 @@ public static OpenApiDocument CreateFilteredDocument(OpenApiDocument source, Fun if (result.CurrentKeys.Operation != null) { pathItem.Operations.Add((OperationType)result.CurrentKeys.Operation, result.Operation); + + if (result.Parameters?.Any() ?? false) + { + foreach (var parameter in result.Parameters) + { + pathItem.Parameters.Add(parameter); + } + } } } diff --git a/src/Microsoft.OpenApi/Services/OpenApiWorkspace.cs b/src/Microsoft.OpenApi/Services/OpenApiWorkspace.cs index 4e6a619a6..7827a50c1 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiWorkspace.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiWorkspace.cs @@ -63,6 +63,11 @@ public OpenApiWorkspace() BaseUrl = new Uri("file://" + Environment.CurrentDirectory + "\\" ); } + /// + /// Initializes a copy of an object + /// + public OpenApiWorkspace(OpenApiWorkspace workspace){} + /// /// Verify if workspace contains a document based on its URL. /// diff --git a/src/Microsoft.OpenApi/Services/OperationSearch.cs b/src/Microsoft.OpenApi/Services/OperationSearch.cs index 95b3a6341..90e88cc70 100644 --- a/src/Microsoft.OpenApi/Services/OperationSearch.cs +++ b/src/Microsoft.OpenApi/Services/OperationSearch.cs @@ -31,18 +31,25 @@ public OperationSearch(Func predi } /// - /// Visits . + /// Visits /// - /// The target . - public override void Visit(OpenApiOperation operation) + /// The target . + public override void Visit(OpenApiPathItem pathItem) { - if (_predicate(CurrentKeys.Path, CurrentKeys.Operation, operation)) + foreach (var item in pathItem.Operations) { - _searchResults.Add(new SearchResult() + var operation = item.Value; + var operationType = item.Key; + + if (_predicate(CurrentKeys.Path, operationType, operation)) { - Operation = operation, - CurrentKeys = CopyCurrentKeys(CurrentKeys) - }); + _searchResults.Add(new SearchResult() + { + Operation = operation, + Parameters = pathItem.Parameters, + CurrentKeys = CopyCurrentKeys(CurrentKeys, operationType) + }); + } } } @@ -65,12 +72,12 @@ public override void Visit(IList parameters) base.Visit(parameters); } - private static CurrentKeys CopyCurrentKeys(CurrentKeys currentKeys) + private static CurrentKeys CopyCurrentKeys(CurrentKeys currentKeys, OperationType operationType) { return new CurrentKeys { Path = currentKeys.Path, - Operation = currentKeys.Operation + Operation = operationType, }; } } diff --git a/src/Microsoft.OpenApi/Services/SearchResult.cs b/src/Microsoft.OpenApi/Services/SearchResult.cs index 381a11f95..435711128 100644 --- a/src/Microsoft.OpenApi/Services/SearchResult.cs +++ b/src/Microsoft.OpenApi/Services/SearchResult.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. +using System.Collections.Generic; using Microsoft.OpenApi.Models; namespace Microsoft.OpenApi.Services @@ -19,5 +20,11 @@ public class SearchResult /// An Operation object. /// public OpenApiOperation Operation { get; set; } + + /// + /// Parameters object + /// + public IList Parameters { get; set; } + } } diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs index 57593a79e..39bc0db80 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs @@ -174,15 +174,6 @@ public void ShouldParseProducesInAnyOrder() }, Items = new OpenApiSchema() { - //Properties = new Dictionary() - // { - // { "id", new OpenApiSchema() - // { - // Type = "string", - // Description = "Item identifier." - // } - // } - // }, Reference = new OpenApiReference() { Type = ReferenceType.Schema, diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiLicenseTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiLicenseTests.cs index 52e99b0b4..46717ecec 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiLicenseTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiLicenseTests.cs @@ -108,5 +108,20 @@ public void SerializeAdvanceLicenseAsYamlWorks(OpenApiSpecVersion version) expected = expected.MakeLineBreaksEnvironmentNeutral(); actual.Should().Be(expected); } + + [Fact] + public void ShouldCopyFromOriginalObjectWithoutMutating() + { + // Arrange + var licenseCopy = new OpenApiLicense(AdvanceLicense); + + // Act + licenseCopy.Name = ""; + licenseCopy.Url = new Uri("https://exampleCopy.com"); + + // Assert + Assert.NotEqual(AdvanceLicense.Name, licenseCopy.Name); + Assert.NotEqual(AdvanceLicense.Url, licenseCopy.Url); + } } } diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index 02400ddd7..a3c284b0e 100755 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -19,9 +19,15 @@ namespace Microsoft.OpenApi.Any { Microsoft.OpenApi.Any.PrimitiveType PrimitiveType { get; } } + public class OpenApiAnyCloneHelper + { + public OpenApiAnyCloneHelper() { } + public static Microsoft.OpenApi.Any.IOpenApiAny CloneFromCopyConstructor(Microsoft.OpenApi.Any.IOpenApiAny obj) { } + } public class OpenApiArray : System.Collections.Generic.List, Microsoft.OpenApi.Any.IOpenApiAny, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtension { public OpenApiArray() { } + public OpenApiArray(Microsoft.OpenApi.Any.OpenApiArray array) { } public Microsoft.OpenApi.Any.AnyType AnyType { get; } public void Write(Microsoft.OpenApi.Writers.IOpenApiWriter writer, Microsoft.OpenApi.OpenApiSpecVersion specVersion) { } } @@ -74,12 +80,14 @@ namespace Microsoft.OpenApi.Any public class OpenApiNull : Microsoft.OpenApi.Any.IOpenApiAny, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtension { public OpenApiNull() { } + public OpenApiNull(Microsoft.OpenApi.Any.OpenApiNull openApiNull) { } public Microsoft.OpenApi.Any.AnyType AnyType { get; } public void Write(Microsoft.OpenApi.Writers.IOpenApiWriter writer, Microsoft.OpenApi.OpenApiSpecVersion specVersion) { } } public class OpenApiObject : System.Collections.Generic.Dictionary, Microsoft.OpenApi.Any.IOpenApiAny, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtension { public OpenApiObject() { } + public OpenApiObject(Microsoft.OpenApi.Any.OpenApiObject obj) { } public Microsoft.OpenApi.Any.AnyType AnyType { get; } public void Write(Microsoft.OpenApi.Writers.IOpenApiWriter writer, Microsoft.OpenApi.OpenApiSpecVersion specVersion) { } } @@ -90,6 +98,7 @@ namespace Microsoft.OpenApi.Any } public abstract class OpenApiPrimitive : Microsoft.OpenApi.Any.IOpenApiAny, Microsoft.OpenApi.Any.IOpenApiPrimitive, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtension { + public OpenApiPrimitive(Microsoft.OpenApi.Any.OpenApiPrimitive openApiPrimitive) { } public OpenApiPrimitive(T value) { } public Microsoft.OpenApi.Any.AnyType AnyType { get; } public abstract Microsoft.OpenApi.Any.PrimitiveType PrimitiveType { get; } @@ -323,6 +332,7 @@ namespace Microsoft.OpenApi.Models public class OpenApiCallback : Microsoft.OpenApi.Interfaces.IEffective, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { public OpenApiCallback() { } + public OpenApiCallback(Microsoft.OpenApi.Models.OpenApiCallback callback) { } public System.Collections.Generic.IDictionary Extensions { get; set; } public System.Collections.Generic.Dictionary PathItems { get; set; } public Microsoft.OpenApi.Models.OpenApiReference Reference { get; set; } @@ -337,6 +347,7 @@ namespace Microsoft.OpenApi.Models public class OpenApiComponents : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { public OpenApiComponents() { } + public OpenApiComponents(Microsoft.OpenApi.Models.OpenApiComponents components) { } public System.Collections.Generic.IDictionary Callbacks { get; set; } public System.Collections.Generic.IDictionary Examples { get; set; } public System.Collections.Generic.IDictionary Extensions { get; set; } @@ -481,6 +492,7 @@ namespace Microsoft.OpenApi.Models public class OpenApiContact : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { public OpenApiContact() { } + public OpenApiContact(Microsoft.OpenApi.Models.OpenApiContact contact) { } public string Email { get; set; } public System.Collections.Generic.IDictionary Extensions { get; set; } public string Name { get; set; } @@ -491,6 +503,7 @@ namespace Microsoft.OpenApi.Models public class OpenApiDiscriminator : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { public OpenApiDiscriminator() { } + public OpenApiDiscriminator(Microsoft.OpenApi.Models.OpenApiDiscriminator discriminator) { } public System.Collections.Generic.IDictionary Mapping { get; set; } public string PropertyName { get; set; } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -499,6 +512,7 @@ namespace Microsoft.OpenApi.Models public class OpenApiDocument : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { public OpenApiDocument() { } + public OpenApiDocument(Microsoft.OpenApi.Models.OpenApiDocument document) { } public Microsoft.OpenApi.Models.OpenApiComponents Components { get; set; } public System.Collections.Generic.IDictionary Extensions { get; set; } public Microsoft.OpenApi.Models.OpenApiExternalDocs ExternalDocs { get; set; } @@ -516,6 +530,7 @@ namespace Microsoft.OpenApi.Models public class OpenApiEncoding : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { public OpenApiEncoding() { } + public OpenApiEncoding(Microsoft.OpenApi.Models.OpenApiEncoding encoding) { } public bool? AllowReserved { get; set; } public string ContentType { get; set; } public bool? Explode { get; set; } @@ -528,6 +543,7 @@ namespace Microsoft.OpenApi.Models public class OpenApiError { public OpenApiError(Microsoft.OpenApi.Exceptions.OpenApiException exception) { } + public OpenApiError(Microsoft.OpenApi.Models.OpenApiError error) { } public OpenApiError(string pointer, string message) { } public string Message { get; set; } public string Pointer { get; set; } @@ -536,6 +552,7 @@ namespace Microsoft.OpenApi.Models public class OpenApiExample : Microsoft.OpenApi.Interfaces.IEffective, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { public OpenApiExample() { } + public OpenApiExample(Microsoft.OpenApi.Models.OpenApiExample example) { } public string Description { get; set; } public System.Collections.Generic.IDictionary Extensions { get; set; } public string ExternalValue { get; set; } @@ -560,6 +577,7 @@ namespace Microsoft.OpenApi.Models public class OpenApiExternalDocs : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { public OpenApiExternalDocs() { } + public OpenApiExternalDocs(Microsoft.OpenApi.Models.OpenApiExternalDocs externalDocs) { } public string Description { get; set; } public System.Collections.Generic.IDictionary Extensions { get; set; } public System.Uri Url { get; set; } @@ -569,6 +587,7 @@ namespace Microsoft.OpenApi.Models public class OpenApiHeader : Microsoft.OpenApi.Interfaces.IEffective, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { public OpenApiHeader() { } + public OpenApiHeader(Microsoft.OpenApi.Models.OpenApiHeader header) { } public bool AllowEmptyValue { get; set; } public bool AllowReserved { get; set; } public System.Collections.Generic.IDictionary Content { get; set; } @@ -592,6 +611,7 @@ namespace Microsoft.OpenApi.Models public class OpenApiInfo : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { public OpenApiInfo() { } + public OpenApiInfo(Microsoft.OpenApi.Models.OpenApiInfo info) { } public Microsoft.OpenApi.Models.OpenApiContact Contact { get; set; } public string Description { get; set; } public System.Collections.Generic.IDictionary Extensions { get; set; } @@ -605,6 +625,7 @@ namespace Microsoft.OpenApi.Models public class OpenApiLicense : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { public OpenApiLicense() { } + public OpenApiLicense(Microsoft.OpenApi.Models.OpenApiLicense license) { } public System.Collections.Generic.IDictionary Extensions { get; set; } public string Name { get; set; } public System.Uri Url { get; set; } @@ -614,6 +635,7 @@ namespace Microsoft.OpenApi.Models public class OpenApiLink : Microsoft.OpenApi.Interfaces.IEffective, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { public OpenApiLink() { } + public OpenApiLink(Microsoft.OpenApi.Models.OpenApiLink link) { } public string Description { get; set; } public System.Collections.Generic.IDictionary Extensions { get; set; } public string OperationId { get; set; } @@ -632,6 +654,7 @@ namespace Microsoft.OpenApi.Models public class OpenApiMediaType : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { public OpenApiMediaType() { } + public OpenApiMediaType(Microsoft.OpenApi.Models.OpenApiMediaType mediaType) { } public System.Collections.Generic.IDictionary Encoding { get; set; } public Microsoft.OpenApi.Any.IOpenApiAny Example { get; set; } public System.Collections.Generic.IDictionary Examples { get; set; } @@ -643,6 +666,7 @@ namespace Microsoft.OpenApi.Models public class OpenApiOAuthFlow : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { public OpenApiOAuthFlow() { } + public OpenApiOAuthFlow(Microsoft.OpenApi.Models.OpenApiOAuthFlow oAuthFlow) { } public System.Uri AuthorizationUrl { get; set; } public System.Collections.Generic.IDictionary Extensions { get; set; } public System.Uri RefreshUrl { get; set; } @@ -654,6 +678,7 @@ namespace Microsoft.OpenApi.Models public class OpenApiOAuthFlows : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { public OpenApiOAuthFlows() { } + public OpenApiOAuthFlows(Microsoft.OpenApi.Models.OpenApiOAuthFlows oAuthFlows) { } public Microsoft.OpenApi.Models.OpenApiOAuthFlow AuthorizationCode { get; set; } public Microsoft.OpenApi.Models.OpenApiOAuthFlow ClientCredentials { get; set; } public System.Collections.Generic.IDictionary Extensions { get; set; } @@ -666,6 +691,7 @@ namespace Microsoft.OpenApi.Models { public const bool DeprecatedDefault = false; public OpenApiOperation() { } + public OpenApiOperation(Microsoft.OpenApi.Models.OpenApiOperation operation) { } public System.Collections.Generic.IDictionary Callbacks { get; set; } public bool Deprecated { get; set; } public string Description { get; set; } @@ -685,6 +711,7 @@ namespace Microsoft.OpenApi.Models public class OpenApiParameter : Microsoft.OpenApi.Interfaces.IEffective, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { public OpenApiParameter() { } + public OpenApiParameter(Microsoft.OpenApi.Models.OpenApiParameter parameter) { } public bool AllowEmptyValue { get; set; } public bool AllowReserved { get; set; } public System.Collections.Generic.IDictionary Content { get; set; } @@ -710,6 +737,7 @@ namespace Microsoft.OpenApi.Models public class OpenApiPathItem : Microsoft.OpenApi.Interfaces.IEffective, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { public OpenApiPathItem() { } + public OpenApiPathItem(Microsoft.OpenApi.Models.OpenApiPathItem pathItem) { } public string Description { get; set; } public System.Collections.Generic.IDictionary Extensions { get; set; } public System.Collections.Generic.IDictionary Operations { get; set; } @@ -728,10 +756,12 @@ namespace Microsoft.OpenApi.Models public class OpenApiPaths : Microsoft.OpenApi.Models.OpenApiExtensibleDictionary { public OpenApiPaths() { } + public OpenApiPaths(Microsoft.OpenApi.Models.OpenApiPaths paths) { } } public class OpenApiReference : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { public OpenApiReference() { } + public OpenApiReference(Microsoft.OpenApi.Models.OpenApiReference reference) { } public string ExternalResource { get; set; } public Microsoft.OpenApi.Models.OpenApiDocument HostDocument { get; set; } public string Id { get; set; } @@ -746,6 +776,7 @@ namespace Microsoft.OpenApi.Models public class OpenApiRequestBody : Microsoft.OpenApi.Interfaces.IEffective, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { public OpenApiRequestBody() { } + public OpenApiRequestBody(Microsoft.OpenApi.Models.OpenApiRequestBody requestBody) { } public System.Collections.Generic.IDictionary Content { get; set; } public string Description { get; set; } public System.Collections.Generic.IDictionary Extensions { get; set; } @@ -761,6 +792,7 @@ namespace Microsoft.OpenApi.Models public class OpenApiResponse : Microsoft.OpenApi.Interfaces.IEffective, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { public OpenApiResponse() { } + public OpenApiResponse(Microsoft.OpenApi.Models.OpenApiResponse response) { } public System.Collections.Generic.IDictionary Content { get; set; } public string Description { get; set; } public System.Collections.Generic.IDictionary Extensions { get; set; } @@ -777,10 +809,12 @@ namespace Microsoft.OpenApi.Models public class OpenApiResponses : Microsoft.OpenApi.Models.OpenApiExtensibleDictionary { public OpenApiResponses() { } + public OpenApiResponses(Microsoft.OpenApi.Models.OpenApiResponses openApiResponses) { } } public class OpenApiSchema : Microsoft.OpenApi.Interfaces.IEffective, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { public OpenApiSchema() { } + public OpenApiSchema(Microsoft.OpenApi.Models.OpenApiSchema schema) { } public Microsoft.OpenApi.Models.OpenApiSchema AdditionalProperties { get; set; } public bool AdditionalPropertiesAllowed { get; set; } public System.Collections.Generic.IList AllOf { get; set; } @@ -835,6 +869,7 @@ namespace Microsoft.OpenApi.Models public class OpenApiSecurityScheme : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { public OpenApiSecurityScheme() { } + public OpenApiSecurityScheme(Microsoft.OpenApi.Models.OpenApiSecurityScheme securityScheme) { } public string BearerFormat { get; set; } public string Description { get; set; } public System.Collections.Generic.IDictionary Extensions { get; set; } @@ -854,6 +889,7 @@ namespace Microsoft.OpenApi.Models public class OpenApiServer : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { public OpenApiServer() { } + public OpenApiServer(Microsoft.OpenApi.Models.OpenApiServer server) { } public string Description { get; set; } public System.Collections.Generic.IDictionary Extensions { get; set; } public string Url { get; set; } @@ -864,6 +900,7 @@ namespace Microsoft.OpenApi.Models public class OpenApiServerVariable : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { public OpenApiServerVariable() { } + public OpenApiServerVariable(Microsoft.OpenApi.Models.OpenApiServerVariable serverVariable) { } public string Default { get; set; } public string Description { get; set; } public System.Collections.Generic.List Enum { get; set; } @@ -874,6 +911,7 @@ namespace Microsoft.OpenApi.Models public class OpenApiTag : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { public OpenApiTag() { } + public OpenApiTag(Microsoft.OpenApi.Models.OpenApiTag tag) { } public string Description { get; set; } public System.Collections.Generic.IDictionary Extensions { get; set; } public Microsoft.OpenApi.Models.OpenApiExternalDocs ExternalDocs { get; set; } @@ -888,6 +926,7 @@ namespace Microsoft.OpenApi.Models public class OpenApiXml : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { public OpenApiXml() { } + public OpenApiXml(Microsoft.OpenApi.Models.OpenApiXml xml) { } public bool Attribute { get; set; } public System.Collections.Generic.IDictionary Extensions { get; set; } public string Name { get; set; } @@ -941,6 +980,7 @@ namespace Microsoft.OpenApi.Models public class RuntimeExpressionAnyWrapper : Microsoft.OpenApi.Interfaces.IOpenApiElement { public RuntimeExpressionAnyWrapper() { } + public RuntimeExpressionAnyWrapper(Microsoft.OpenApi.Models.RuntimeExpressionAnyWrapper runtimeExpressionAnyWrapper) { } public Microsoft.OpenApi.Any.IOpenApiAny Any { get; set; } public Microsoft.OpenApi.Expressions.RuntimeExpression Expression { get; set; } public void WriteValue(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -1054,6 +1094,7 @@ namespace Microsoft.OpenApi.Services public class OpenApiWorkspace { public OpenApiWorkspace() { } + public OpenApiWorkspace(Microsoft.OpenApi.Services.OpenApiWorkspace workspace) { } public OpenApiWorkspace(System.Uri baseUrl) { } public System.Collections.Generic.IEnumerable Artifacts { get; } public System.Uri BaseUrl { get; } @@ -1070,7 +1111,7 @@ namespace Microsoft.OpenApi.Services { public OperationSearch(System.Func predicate) { } public System.Collections.Generic.IList SearchResults { get; } - public override void Visit(Microsoft.OpenApi.Models.OpenApiOperation operation) { } + public override void Visit(Microsoft.OpenApi.Models.OpenApiPathItem pathItem) { } public override void Visit(System.Collections.Generic.IList parameters) { } } public class SearchResult @@ -1078,6 +1119,7 @@ namespace Microsoft.OpenApi.Services public SearchResult() { } public Microsoft.OpenApi.Services.CurrentKeys CurrentKeys { get; set; } public Microsoft.OpenApi.Models.OpenApiOperation Operation { get; set; } + public System.Collections.Generic.IList Parameters { get; set; } } } namespace Microsoft.OpenApi.Validations