File tree Expand file tree Collapse file tree 6 files changed +22
-7
lines changed
src/Microsoft.OpenApi/Models
test/Microsoft.OpenApi.Tests/Models Expand file tree Collapse file tree 6 files changed +22
-7
lines changed Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ public OpenApiContact() { }
46
46
public OpenApiContact ( OpenApiContact contact )
47
47
{
48
48
Name = contact . Name ;
49
- Url = contact . Url ;
49
+ Url = new Uri ( contact . Url . OriginalString ) ;
50
50
Email = contact . Email ;
51
51
Extensions = new Dictionary < string , IOpenApiExtension > ( contact . Extensions ) ;
52
52
}
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ public OpenApiExternalDocs() {}
40
40
public OpenApiExternalDocs ( OpenApiExternalDocs externalDocs )
41
41
{
42
42
Description = externalDocs . Description ;
43
- Url = externalDocs . Url ;
43
+ Url = new Uri ( externalDocs . Url . OriginalString ) ;
44
44
Extensions = new Dictionary < string , IOpenApiExtension > ( externalDocs . Extensions ) ;
45
45
}
46
46
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ public OpenApiLicense() {}
40
40
public OpenApiLicense ( OpenApiLicense license )
41
41
{
42
42
Name = license . Name ;
43
- Url = license . Url ;
43
+ Url = new Uri ( license . Url . OriginalString ) ;
44
44
Extensions = new Dictionary < string , IOpenApiExtension > ( license . Extensions ) ;
45
45
}
46
46
Original file line number Diff line number Diff line change @@ -51,9 +51,9 @@ public OpenApiOAuthFlow() {}
51
51
/// </summary>
52
52
public OpenApiOAuthFlow ( OpenApiOAuthFlow oAuthFlow )
53
53
{
54
- AuthorizationUrl = oAuthFlow . AuthorizationUrl ;
55
- TokenUrl = oAuthFlow . TokenUrl ;
56
- RefreshUrl = oAuthFlow . RefreshUrl ;
54
+ AuthorizationUrl = new Uri ( oAuthFlow . AuthorizationUrl . OriginalString ) ;
55
+ TokenUrl = new Uri ( oAuthFlow . TokenUrl . OriginalString ) ;
56
+ RefreshUrl = new Uri ( oAuthFlow . RefreshUrl . OriginalString ) ;
57
57
Scopes = new Dictionary < string , string > ( oAuthFlow . Scopes ) ;
58
58
Extensions = new Dictionary < string , IOpenApiExtension > ( oAuthFlow . Extensions ) ;
59
59
}
Original file line number Diff line number Diff line change @@ -91,7 +91,7 @@ public OpenApiSecurityScheme(OpenApiSecurityScheme securityScheme)
91
91
Scheme = securityScheme . Scheme ;
92
92
BearerFormat = securityScheme . BearerFormat ;
93
93
Flows = new ( securityScheme . Flows ) ;
94
- OpenIdConnectUrl = securityScheme . OpenIdConnectUrl ;
94
+ OpenIdConnectUrl = new Uri ( securityScheme . OpenIdConnectUrl . OriginalString ) ;
95
95
Extensions = new Dictionary < string , IOpenApiExtension > ( securityScheme . Extensions ) ;
96
96
UnresolvedReference = securityScheme . UnresolvedReference ;
97
97
Reference = new ( securityScheme . Reference ) ;
Original file line number Diff line number Diff line change @@ -108,5 +108,20 @@ public void SerializeAdvanceLicenseAsYamlWorks(OpenApiSpecVersion version)
108
108
expected = expected . MakeLineBreaksEnvironmentNeutral ( ) ;
109
109
actual . Should ( ) . Be ( expected ) ;
110
110
}
111
+
112
+ [ Fact ]
113
+ public void ShouldCopyFromOriginalObjectWithoutMutating ( )
114
+ {
115
+ // Arrange
116
+ var licenseCopy = new OpenApiLicense ( AdvanceLicense ) ;
117
+
118
+ // Act
119
+ licenseCopy . Name = "" ;
120
+ licenseCopy . Url = new Uri ( "https://exampleCopy.com" ) ;
121
+
122
+ // Assert
123
+ Assert . NotEqual ( AdvanceLicense . Name , licenseCopy . Name ) ;
124
+ Assert . NotEqual ( AdvanceLicense . Url , licenseCopy . Url ) ;
125
+ }
111
126
}
112
127
}
You can’t perform that action at this time.
0 commit comments