Skip to content

Commit 176ff31

Browse files
committed
chore: another batch of NRT fixes
Signed-off-by: Vincent Biret <[email protected]>
1 parent c815412 commit 176ff31

File tree

4 files changed

+18
-16
lines changed

4 files changed

+18
-16
lines changed

src/Microsoft.OpenApi.OData.Reader/Edm/ODataPath.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace Microsoft.OpenApi.OData.Edm
2020
public class ODataPath : IEnumerable<ODataSegment>, IComparable<ODataPath>
2121
{
2222
private ODataPathKind? _pathKind;
23-
private string _defaultPathItemName;
23+
private string? _defaultPathItemName;
2424

2525
/// <summary>
2626
/// Initializes a new instance of <see cref="ODataPath"/> class.
@@ -54,7 +54,7 @@ public ODataPath(params ODataSegment[] segments)
5454
/// Gets/Sets the path template for this path.
5555
/// If it is set, it will be used to generate the path item.
5656
/// </summary>
57-
public string PathTemplate { get; set; }
57+
public string? PathTemplate { get; set; }
5858

5959
/// <summary>
6060
/// Gets the segments.
@@ -80,12 +80,12 @@ public virtual ODataPathKind Kind
8080
/// <summary>
8181
/// Gets the first segment in the path. Returns null if the path is empty.
8282
/// </summary>
83-
public ODataSegment FirstSegment => Segments.Count == 0 ? null : Segments[0];
83+
public ODataSegment? FirstSegment => Segments is null || Segments.Count == 0 ? null : Segments[0];
8484

8585
/// <summary>
8686
/// Get the last segment in the path. Returns null if the path is empty.
8787
/// </summary>
88-
public ODataSegment LastSegment => Segments.Count == 0 ? null : this.Segments[Segments.Count - 1];
88+
public ODataSegment? LastSegment => Segments is null || Segments.Count == 0 ? null : this.Segments[Segments.Count - 1];
8989

9090
/// <summary>
9191
/// Get the number of segments in this path.
@@ -365,7 +365,7 @@ private ODataPathKind CalcPathType()
365365
/// </summary>
366366
/// <param name="settings">The settings.</param>
367367
///<returns>The suffix.</returns>
368-
public string GetPathHash(OpenApiConvertSettings settings) =>
369-
LastSegment.GetPathHash(settings, this);
368+
public string? GetPathHash(OpenApiConvertSettings settings) =>
369+
LastSegment?.GetPathHash(settings, this);
370370
}
371371
}

src/Microsoft.OpenApi.OData.Reader/Operation/NavigationPropertyOperationHandler.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,12 @@ protected override void SetExtensions(OpenApiOperation operation)
113113
base.SetExtensions(operation);
114114
}
115115

116-
internal string GetOperationId(string? prefix = null)
117-
{
116+
internal string? GetOperationId(string? prefix = null)
117+
{
118+
if (Context is null || Path is null)
119+
{
120+
return null;
121+
}
118122
return EdmModelHelper.GenerateNavigationPropertyPathOperationId(Path, Context, prefix);
119123
}
120124

src/Microsoft.OpenApi.OData.Reader/Operation/ODataTypeCastGetOperationHandler.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -371,14 +371,12 @@ protected override void SetParameters(OpenApiOperation operation)
371371

372372
protected override void SetSecurity(OpenApiOperation operation)
373373
{
374-
if (restriction == null || restriction.ReadRestrictions == null)
374+
if (restriction is not {ReadRestrictions.Permissions: not null})
375375
{
376376
return;
377377
}
378378

379-
ReadRestrictionsBase readBase = restriction.ReadRestrictions;
380-
381-
operation.Security = Context?.CreateSecurityRequirements(readBase.Permissions, _document).ToList();
379+
operation.Security = Context?.CreateSecurityRequirements(restriction.ReadRestrictions.Permissions, _document).ToList();
382380
}
383381

384382
protected override void SetExtensions(OpenApiOperation operation)

src/Microsoft.OpenApi.OData.Reader/PublicAPI.Unshipped.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,17 @@ Microsoft.OpenApi.OData.Edm.ODataPath
4747
Microsoft.OpenApi.OData.Edm.ODataPath.Clone() -> Microsoft.OpenApi.OData.Edm.ODataPath!
4848
Microsoft.OpenApi.OData.Edm.ODataPath.CompareTo(Microsoft.OpenApi.OData.Edm.ODataPath! other) -> int
4949
Microsoft.OpenApi.OData.Edm.ODataPath.Count.get -> int
50-
Microsoft.OpenApi.OData.Edm.ODataPath.FirstSegment.get -> Microsoft.OpenApi.OData.Edm.ODataSegment!
50+
Microsoft.OpenApi.OData.Edm.ODataPath.FirstSegment.get -> Microsoft.OpenApi.OData.Edm.ODataSegment?
5151
Microsoft.OpenApi.OData.Edm.ODataPath.GetCount(bool keySegmentAsDepth) -> int
5252
Microsoft.OpenApi.OData.Edm.ODataPath.GetEnumerator() -> System.Collections.Generic.IEnumerator<Microsoft.OpenApi.OData.Edm.ODataSegment!>!
53-
Microsoft.OpenApi.OData.Edm.ODataPath.GetPathHash(Microsoft.OpenApi.OData.OpenApiConvertSettings! settings) -> string!
53+
Microsoft.OpenApi.OData.Edm.ODataPath.GetPathHash(Microsoft.OpenApi.OData.OpenApiConvertSettings! settings) -> string?
5454
Microsoft.OpenApi.OData.Edm.ODataPath.GetPathItemName() -> string!
5555
Microsoft.OpenApi.OData.Edm.ODataPath.GetPathItemName(Microsoft.OpenApi.OData.OpenApiConvertSettings! settings) -> string!
5656
Microsoft.OpenApi.OData.Edm.ODataPath.HttpMethods.get -> System.Collections.Generic.ISet<string!>!
57-
Microsoft.OpenApi.OData.Edm.ODataPath.LastSegment.get -> Microsoft.OpenApi.OData.Edm.ODataSegment!
57+
Microsoft.OpenApi.OData.Edm.ODataPath.LastSegment.get -> Microsoft.OpenApi.OData.Edm.ODataSegment?
5858
Microsoft.OpenApi.OData.Edm.ODataPath.ODataPath(params Microsoft.OpenApi.OData.Edm.ODataSegment![]! segments) -> void
5959
Microsoft.OpenApi.OData.Edm.ODataPath.ODataPath(System.Collections.Generic.IEnumerable<Microsoft.OpenApi.OData.Edm.ODataSegment!>! segments) -> void
60-
Microsoft.OpenApi.OData.Edm.ODataPath.PathTemplate.get -> string!
60+
Microsoft.OpenApi.OData.Edm.ODataPath.PathTemplate.get -> string?
6161
Microsoft.OpenApi.OData.Edm.ODataPath.PathTemplate.set -> void
6262
Microsoft.OpenApi.OData.Edm.ODataPath.Segments.get -> System.Collections.Generic.IList<Microsoft.OpenApi.OData.Edm.ODataSegment!>!
6363
Microsoft.OpenApi.OData.Edm.ODataPathKind

0 commit comments

Comments
 (0)