Skip to content

Commit 2b10475

Browse files
authored
Make CorsOptions.maxAgeInSeconds x-nullable (Azure#17900)
Fixes Azure#16928
1 parent 5667deb commit 2b10475

File tree

5 files changed

+49
-6
lines changed

5 files changed

+49
-6
lines changed

eng/Packages.Data.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@
152152
<PackageReference Update="FsCheck.Xunit" Version="2.14.0" />
153153
<PackageReference Update="Microsoft.AspNetCore.Server.Kestrel" Version="2.2.0" />
154154
<PackageReference Update="Microsoft.AspNetCore.Server.WebListener" Version="1.0.2" />
155+
<PackageReference Update="Microsoft.Azure.Core.Spatial" Version="1.0.0" />
155156
<PackageReference Update="Microsoft.Azure.Devices" Version="1.19.0" />
156157
<PackageReference Update="Microsoft.Azure.Devices.Client" Version="1.27.0" />
157158
<PackageReference Update="Microsoft.Azure.Graph.RBAC" Version="2.2.2-preview" />
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<Project>
22
<ItemGroup>
3-
<!-- TODO: Convert this to a PackageReference when Microsoft.Azure.Core.Spatial is published -->
4-
<ProjectReference Include="$(MSBuildThisFileDirectory)$(MSBuildThisFileName).csproj" />
3+
<PackageReference Include="Microsoft.Azure.Core.Spatial" />
54
</ItemGroup>
65
</Project>

sdk/search/Azure.Search.Documents/src/Generated/Models/CorsOptions.Serialization.cs

Lines changed: 11 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/search/Azure.Search.Documents/src/autorest.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,14 @@ directive:
193193
$.properties.endTime["x-nullable"] = true;
194194
```
195195
196+
``` yaml
197+
directive:
198+
from: swagger-document
199+
where: $.definitions.CorsOptions
200+
transform: >
201+
$.properties.maxAgeInSeconds["x-nullable"] = true;
202+
```
203+
196204
#### Skills
197205
198206
``` yaml
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
using System.Text.Json;
5+
using Azure.Search.Documents.Indexes.Models;
6+
using NUnit.Framework;
7+
8+
namespace Azure.Search.Documents.Tests.Models
9+
{
10+
public class CorsOptionsTests
11+
{
12+
[Test]
13+
public void MaxAgeInSecondsNull()
14+
{
15+
JsonDocument doc = JsonDocument.Parse(@"{
16+
""allowedOrigins"": [
17+
""*""
18+
],
19+
""maxAgeInSeconds"": null
20+
}");
21+
22+
CorsOptions sut = CorsOptions.DeserializeCorsOptions(doc.RootElement);
23+
24+
CollectionAssert.AreEqual(sut.AllowedOrigins, new[] { "*" });
25+
Assert.IsNull(sut.MaxAgeInSeconds);
26+
}
27+
}
28+
}

0 commit comments

Comments
 (0)