Skip to content

Commit f1ec813

Browse files
committed
Rename Read Result properties
1 parent 47bf1eb commit f1ec813

35 files changed

+174
-181
lines changed

src/Microsoft.OpenApi.Hidi/OpenApiService.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ private static async Task<OpenApiDocument> GetOpenApiAsync(HidiOptions options,
255255
{
256256
stream = await GetStreamAsync(options.OpenApi, logger, cancellationToken).ConfigureAwait(false);
257257
var result = await ParseOpenApiAsync(options.OpenApi, options.InlineExternal, logger, stream, cancellationToken).ConfigureAwait(false);
258-
document = result.OpenApiDocument;
258+
document = result.Document;
259259
}
260260
else throw new InvalidOperationException("No input file path or URL provided");
261261

@@ -358,7 +358,7 @@ private static MemoryStream ApplyFilterToCsdl(Stream csdlStream, string entitySe
358358
{
359359
var statsVisitor = new StatsVisitor();
360360
var walker = new OpenApiWalker(statsVisitor);
361-
walker.Walk(result.OpenApiDocument);
361+
walker.Walk(result.Document);
362362

363363
logger.LogTrace("Finished walking through the OpenApi document. Generating a statistics report..");
364364
#pragma warning disable CA2254
@@ -377,7 +377,7 @@ private static MemoryStream ApplyFilterToCsdl(Stream csdlStream, string entitySe
377377

378378
if (result is null) return null;
379379

380-
return result.OpenApiDiagnostic.Errors.Count == 0;
380+
return result.Diagnostic.Errors.Count == 0;
381381
}
382382

383383
private static async Task<ReadResult> ParseOpenApiAsync(string openApiFile, bool inlineExternal, ILogger logger, Stream stream, CancellationToken cancellationToken = default)
@@ -439,7 +439,7 @@ public static OpenApiDocument FixReferences(OpenApiDocument document, string for
439439
var sb = new StringBuilder();
440440
document.SerializeAsV3(new OpenApiYamlWriter(new StringWriter(sb)));
441441

442-
var doc = OpenApiDocument.Parse(sb.ToString(), format).OpenApiDocument;
442+
var doc = OpenApiDocument.Parse(sb.ToString(), format).Document;
443443

444444
return doc;
445445
}
@@ -649,7 +649,7 @@ private static string GetInputPathExtension(string? openapi = null, string? csdl
649649

650650
private static void LogErrors(ILogger logger, ReadResult result)
651651
{
652-
var context = result.OpenApiDiagnostic;
652+
var context = result.Diagnostic;
653653
if (context.Errors.Count != 0)
654654
{
655655
using (logger.BeginScope("Detected errors"))

src/Microsoft.OpenApi.Readers/OpenApiYamlReader.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ public async Task<ReadResult> ReadAsync(TextReader input,
3737
diagnostic.Errors.Add(new($"#line={ex.LineNumber}", ex.Message));
3838
return new()
3939
{
40-
OpenApiDocument = null,
41-
OpenApiDiagnostic = diagnostic
40+
Document = null,
41+
Diagnostic = diagnostic
4242
};
4343
}
4444

src/Microsoft.OpenApi.Workbench/MainModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,8 @@ internal async Task ParseDocumentAsync()
246246
}
247247

248248
var readResult = await OpenApiDocument.LoadAsync(stream, Format.GetDisplayName());
249-
var document = readResult.OpenApiDocument;
250-
var context = readResult.OpenApiDiagnostic;
249+
var document = readResult.Document;
250+
var context = readResult.Diagnostic;
251251

252252
stopwatch.Stop();
253253
ParseTime = $"{stopwatch.ElapsedMilliseconds} ms";

src/Microsoft.OpenApi/Reader/OpenApiJsonReader.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ public async Task<ReadResult> ReadAsync(TextReader input,
4949
diagnostic.Errors.Add(new OpenApiError($"#line={ex.LineNumber}", $"Please provide the correct format, {ex.Message}"));
5050
return new ReadResult
5151
{
52-
OpenApiDocument = null,
53-
OpenApiDiagnostic = diagnostic
52+
Document = null,
53+
Diagnostic = diagnostic
5454
};
5555
}
5656

@@ -118,8 +118,8 @@ public async Task<ReadResult> ReadAsync(JsonNode jsonNode,
118118

119119
return new()
120120
{
121-
OpenApiDocument = document,
122-
OpenApiDiagnostic = diagnostic
121+
Document = document,
122+
Diagnostic = diagnostic
123123
};
124124
}
125125

src/Microsoft.OpenApi/Reader/ReadResult.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ public class ReadResult
1313
/// <summary>
1414
/// The parsed OpenApiDocument. Null will be returned if the document could not be parsed.
1515
/// </summary>
16-
public OpenApiDocument OpenApiDocument { set; get; }
16+
public OpenApiDocument Document { get; set; }
1717
/// <summary>
1818
/// OpenApiDiagnostic contains the Errors reported while parsing
1919
/// </summary>
20-
public OpenApiDiagnostic OpenApiDiagnostic { set; get; }
20+
public OpenApiDiagnostic Diagnostic { get; set; }
2121
}
2222
}

src/Microsoft.OpenApi/Reader/Services/OpenApiWorkspaceLoader.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ internal async Task<OpenApiDiagnostic> LoadAsync(OpenApiReference reference,
4848
var input = await _loader.LoadAsync(new(item.ExternalResource, UriKind.RelativeOrAbsolute));
4949
var result = await OpenApiDocument.LoadAsync(input, format, _readerSettings, cancellationToken);
5050
// Merge diagnostics
51-
if (result.OpenApiDiagnostic != null)
51+
if (result.Diagnostic != null)
5252
{
53-
diagnostic.AppendDiagnostic(result.OpenApiDiagnostic, item.ExternalResource);
53+
diagnostic.AppendDiagnostic(result.Diagnostic, item.ExternalResource);
5454
}
55-
if (result.OpenApiDocument != null)
55+
if (result.Document != null)
5656
{
57-
var loadDiagnostic = await LoadAsync(item, result.OpenApiDocument, format, diagnostic, cancellationToken);
57+
var loadDiagnostic = await LoadAsync(item, result.Document, format, diagnostic, cancellationToken);
5858
diagnostic = loadDiagnostic;
5959
}
6060
}

test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ public void CopiesOverAllReferencedComponentsToTheSubsetDocumentCorrectly()
232232

233233
// Act
234234
using var stream = File.OpenRead(filePath);
235-
var doc = OpenApiDocument.Load(stream, "yaml").OpenApiDocument;
235+
var doc = OpenApiDocument.Load(stream, "yaml").Document;
236236

237237
var predicate = OpenApiFilterService.CreatePredicate(operationIds: operationIds);
238238
var subsetOpenApiDocument = OpenApiFilterService.CreateFilteredDocument(doc, predicate);

test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiDiagnosticTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,17 @@ public void DetectedSpecificationVersionShouldBeV2_0()
2727
{
2828
var actual = OpenApiDocument.Load("V2Tests/Samples/basic.v2.yaml");
2929

30-
actual.OpenApiDiagnostic.Should().NotBeNull();
31-
actual.OpenApiDiagnostic.SpecificationVersion.Should().Be(OpenApiSpecVersion.OpenApi2_0);
30+
actual.Diagnostic.Should().NotBeNull();
31+
actual.Diagnostic.SpecificationVersion.Should().Be(OpenApiSpecVersion.OpenApi2_0);
3232
}
3333

3434
[Fact]
3535
public void DetectedSpecificationVersionShouldBeV3_0()
3636
{
3737
var actual = OpenApiDocument.Load("V3Tests/Samples/OpenApiDocument/minimalDocument.yaml");
3838

39-
actual.OpenApiDiagnostic.Should().NotBeNull();
40-
actual.OpenApiDiagnostic.SpecificationVersion.Should().Be(OpenApiSpecVersion.OpenApi3_0);
39+
actual.Diagnostic.Should().NotBeNull();
40+
actual.Diagnostic.SpecificationVersion.Should().Be(OpenApiSpecVersion.OpenApi3_0);
4141
}
4242

4343
[Fact]
@@ -55,8 +55,8 @@ public async Task DiagnosticReportMergedForExternalReferenceAsync()
5555
result = await OpenApiDocument.LoadAsync("OpenApiReaderTests/Samples/OpenApiDiagnosticReportMerged/TodoMain.yaml", settings);
5656

5757
Assert.NotNull(result);
58-
Assert.NotNull(result.OpenApiDocument.Workspace);
59-
result.OpenApiDiagnostic.Errors.Should().BeEmpty();
58+
Assert.NotNull(result.Document.Workspace);
59+
result.Diagnostic.Errors.Should().BeEmpty();
6060
}
6161
}
6262

test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiStreamReaderTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public async Task StreamShouldReadWhenInitializedAsync()
6565

6666
// Read V3 as YAML
6767
var result = OpenApiDocument.Load(stream, "yaml");
68-
Assert.NotNull(result.OpenApiDocument);
68+
Assert.NotNull(result.Document);
6969
}
7070
}
7171
}

test/Microsoft.OpenApi.Readers.Tests/OpenApiWorkspaceTests/OpenApiWorkspaceStreamTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public async Task LoadingDocumentWithResolveAllReferencesShouldLoadDocumentIntoW
4646

4747
var result = await OpenApiDocument.LoadAsync(stream, OpenApiConstants.Yaml, settings: settings);
4848

49-
Assert.NotNull(result.OpenApiDocument.Workspace);
49+
Assert.NotNull(result.Document.Workspace);
5050
}
5151

5252
[Fact]
@@ -63,14 +63,14 @@ public async Task LoadDocumentWithExternalReferenceShouldLoadBothDocumentsIntoWo
6363
ReadResult result;
6464
result = await OpenApiDocument.LoadAsync("V3Tests/Samples/OpenApiWorkspace/TodoMain.yaml", settings);
6565

66-
var externalDocBaseUri = result.OpenApiDocument.Workspace.GetDocumentId("./TodoComponents.yaml");
66+
var externalDocBaseUri = result.Document.Workspace.GetDocumentId("./TodoComponents.yaml");
6767
var schemasPath = "/components/schemas/";
6868
var parametersPath = "/components/parameters/";
6969

7070
Assert.NotNull(externalDocBaseUri);
71-
Assert.True(result.OpenApiDocument.Workspace.Contains(externalDocBaseUri + schemasPath + "todo"));
72-
Assert.True(result.OpenApiDocument.Workspace.Contains(externalDocBaseUri + schemasPath + "entity"));
73-
Assert.True(result.OpenApiDocument.Workspace.Contains(externalDocBaseUri + parametersPath + "filter"));
71+
Assert.True(result.Document.Workspace.Contains(externalDocBaseUri + schemasPath + "todo"));
72+
Assert.True(result.Document.Workspace.Contains(externalDocBaseUri + schemasPath + "entity"));
73+
Assert.True(result.Document.Workspace.Contains(externalDocBaseUri + parametersPath + "filter"));
7474
}
7575
}
7676

0 commit comments

Comments
 (0)