Skip to content

Commit 25df365

Browse files
committed
Merge branch 'main' into feat/use-put-for-update
2 parents acfbbf5 + 286be91 commit 25df365

36 files changed

+374
-808
lines changed

.github/workflows/auto-merge-dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
steps:
2020
- name: Dependabot metadata
2121
id: metadata
22-
uses: dependabot/fetch-metadata@v2.4.0
22+
uses: dependabot/fetch-metadata@v2.5.0
2323
with:
2424
github-token: "${{ secrets.GITHUB_TOKEN }}"
2525

.github/workflows/sonarcloud.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
with:
4949
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
5050
- name: Cache SonarCloud packages
51-
uses: actions/cache@v4
51+
uses: actions/cache@v5
5252
with:
5353
path: ~/.sonar/cache
5454
key: ${{ runner.os }}-sonar

Build.props

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,4 @@
1515
<EnlistmentRoot Condition="'$(EnlistmentRoot)' == ''">$(MSBuildThisFileDirectory.TrimEnd('\'))</EnlistmentRoot>
1616
</PropertyGroup>
1717

18-
<Import Project="$(EnlistmentRoot)\tool\Build.props" />
19-
2018
</Project>

Microsoft.OpenApi.OData.sln

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 16
44
VisualStudioVersion = 16.0.30907.101
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.OpenApi.OData.Reader", "src\Microsoft.OpenApi.OData.Reader\Microsoft.OpenAPI.OData.Reader.csproj", "{FF3ACD93-19E0-486C-9C0F-FA1C2E7FC8C2}"
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.OpenAPI.OData.Reader", "src\Microsoft.OpenApi.OData.Reader\Microsoft.OpenAPI.OData.Reader.csproj", "{FF3ACD93-19E0-486C-9C0F-FA1C2E7FC8C2}"
77
EndProject
8-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.OpenApi.OData.Reader.Tests", "test\Microsoft.OpenAPI.OData.Reader.Tests\Microsoft.OpenAPI.OData.Reader.Tests.csproj", "{90A98718-75EB-4E2B-A51E-66ACF66F15B4}"
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.OpenAPI.OData.Reader.Tests", "test\Microsoft.OpenAPI.OData.Reader.Tests\Microsoft.OpenAPI.OData.Reader.Tests.csproj", "{90A98718-75EB-4E2B-A51E-66ACF66F15B4}"
99
EndProject
1010
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OoasUtil", "src\OoasUtil\OoasUtil.csproj", "{2D06C660-B550-432C-8062-D4070F7C371F}"
1111
EndProject
@@ -16,10 +16,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1616
.editorconfig = .editorconfig
1717
EndProjectSection
1818
EndProject
19-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tool", "tool", "{DE8F8E75-A119-4CF3-AFDD-4132B55DAE76}"
20-
EndProject
21-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UpdateDocs", "tool\UpdateDocs\UpdateDocs.csproj", "{AAC31ECB-05F9-444A-9B86-42ECD50AA468}"
22-
EndProject
2319
Global
2420
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2521
Debug|Any CPU = Debug|Any CPU
@@ -42,18 +38,11 @@ Global
4238
{79B190E8-EDB0-4C03-8FD8-EB48E4807CFB}.Debug|Any CPU.Build.0 = Debug|Any CPU
4339
{79B190E8-EDB0-4C03-8FD8-EB48E4807CFB}.Release|Any CPU.ActiveCfg = Release|Any CPU
4440
{79B190E8-EDB0-4C03-8FD8-EB48E4807CFB}.Release|Any CPU.Build.0 = Release|Any CPU
45-
{AAC31ECB-05F9-444A-9B86-42ECD50AA468}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
46-
{AAC31ECB-05F9-444A-9B86-42ECD50AA468}.Debug|Any CPU.Build.0 = Debug|Any CPU
47-
{AAC31ECB-05F9-444A-9B86-42ECD50AA468}.Release|Any CPU.ActiveCfg = Release|Any CPU
48-
{AAC31ECB-05F9-444A-9B86-42ECD50AA468}.Release|Any CPU.Build.0 = Release|Any CPU
4941
EndGlobalSection
5042
GlobalSection(SolutionProperties) = preSolution
5143
HideSolutionNode = FALSE
5244
EndGlobalSection
5345
GlobalSection(ExtensibilityGlobals) = postSolution
5446
SolutionGuid = {9AE22713-F94E-45CA-81F4-0806CA195B69}
5547
EndGlobalSection
56-
GlobalSection(NestedProjects) = preSolution
57-
{AAC31ECB-05F9-444A-9B86-42ECD50AA468} = {DE8F8E75-A119-4CF3-AFDD-4132B55DAE76}
58-
EndGlobalSection
5948
EndGlobal

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -872,16 +872,16 @@ private void RetrieveBoundOperationPaths(OpenApiConvertSettings convertSettings)
872872
var functionPaths = _allOperationPaths.Where(x => x.LastSegment is ODataOperationSegment operationSegment
873873
&& operationSegment.Operation is IEdmFunction edmFunction
874874
&& edmFunction.IsComposable
875-
&& edmFunction.ReturnType != null
876-
&& edmFunction.ReturnType.Definition is IEdmEntityType);
875+
&& edmFunction.GetReturn()?.Type is { } retType
876+
&& retType.Definition is IEdmEntityType);
877877

878878
foreach( var functionPath in functionPaths)
879879
{
880880
if (functionPath.LastSegment is not ODataOperationSegment operationSegment
881881
|| operationSegment.Operation is not IEdmFunction edmFunction
882882
|| !edmFunction.IsComposable
883-
|| edmFunction.ReturnType == null
884-
|| edmFunction.ReturnType.Definition is not IEdmEntityType returnBindingEntityType)
883+
|| edmFunction.GetReturn()?.Type is not { } retType
884+
|| retType.Definition is not IEdmEntityType returnBindingEntityType)
885885
{
886886
continue;
887887
}
@@ -1194,7 +1194,7 @@ private void AppendBoundOperationOnOperationPath(IEdmOperation edmOperation, boo
11941194
if (path.LastSegment is not ODataOperationSegment operationSegment
11951195
|| (path.Segments.Count > 1 && path.Segments[path.Segments.Count - 2] is ODataOperationSegment)
11961196
|| operationSegment.Operation is not IEdmFunction edmFunction || !edmFunction.IsComposable
1197-
|| edmFunction.ReturnType == null || !edmFunction.ReturnType.Definition.Equals(bindingEntityType)
1197+
|| edmFunction.GetReturn()?.Type is not { } retType || !retType.Definition.Equals(bindingEntityType)
11981198
|| isCollection
11991199
|| _model is not null && !EdmModelHelper.IsOperationAllowed(_model, edmOperation, operationSegment.Operation, true))
12001200
{

src/Microsoft.OpenApi.OData.Reader/Generator/EdmSpatialTypeVisitor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ public void Visit(IEdmModel model)
4949

5050
private void VisitOperation(IEdmOperation operation)
5151
{
52-
if (operation.ReturnType != null)
52+
if (operation.GetReturn() is {} operationReturn)
5353
{
54-
this.VisitTypeReference(operation.ReturnType);
54+
this.VisitTypeReference(operationReturn.Type);
5555
}
5656

5757
foreach (var parameter in operation.Parameters)

src/Microsoft.OpenApi.OData.Reader/Generator/OpenApiResponseGenerator.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public static OpenApiResponses CreateResponses(this ODataContext context, IEdmOp
117117

118118
OpenApiResponses responses = new();
119119

120-
if (operation.IsAction() && operation.ReturnType == null && Constants.StatusCode204.GetResponse(document) is {} x204Response)
120+
if (operation.IsAction() && operation.GetReturn()?.Type == null && Constants.StatusCode204.GetResponse(document) is {} x204Response)
121121
{
122122
responses.Add(Constants.StatusCode204, x204Response);
123123
}
@@ -150,19 +150,19 @@ public static OpenApiResponses CreateResponses(this ODataContext context, IEdmOp
150150

151151
public static OpenApiResponse? CreateOperationResponse(this ODataContext context, IEdmOperation operation, OpenApiDocument document)
152152
{
153-
if (operation.ReturnType == null)
153+
if (operation.GetReturn()?.Type is not {} returnType)
154154
return null;
155155

156156
IOpenApiSchema schema;
157-
if (operation.ReturnType.IsCollection())
157+
if (returnType.IsCollection())
158158
{
159159
OpenApiSchema baseSchema = new()
160160
{
161161
Type = JsonSchemaType.Object,
162162
Properties = new Dictionary<string, IOpenApiSchema>
163163
{
164164
{
165-
"value", context.CreateEdmTypeSchema(operation.ReturnType, document)
165+
"value", context.CreateEdmTypeSchema(returnType, document)
166166
}
167167
}
168168
};
@@ -202,12 +202,12 @@ public static OpenApiResponses CreateResponses(this ODataContext context, IEdmOp
202202

203203
if (schema is OpenApiSchema openApiSchema)
204204
{
205-
openApiSchema.Title = operation.ReturnType.Definition.AsElementType() is not IEdmEntityType entityType
205+
openApiSchema.Title = returnType.Definition.AsElementType() is not IEdmEntityType entityType
206206
? null : $"Collection of {entityType.Name}";
207207
openApiSchema.Type = JsonSchemaType.Object;
208208
}
209209
}
210-
else if (operation.ReturnType.IsPrimitive())
210+
else if (returnType.IsPrimitive())
211211
{
212212
// A property or operation response that is of a primitive type is represented as an object with a single name/value pair,
213213
// whose name is value and whose value is a primitive value.
@@ -217,18 +217,18 @@ public static OpenApiResponses CreateResponses(this ODataContext context, IEdmOp
217217
Properties = new Dictionary<string, IOpenApiSchema>
218218
{
219219
{
220-
"value", context.CreateEdmTypeSchema(operation.ReturnType, document)
220+
"value", context.CreateEdmTypeSchema(returnType, document)
221221
}
222222
}
223223
};
224224
}
225225
else
226226
{
227-
schema = context.CreateEdmTypeSchema(operation.ReturnType, document);
227+
schema = context.CreateEdmTypeSchema(returnType, document);
228228
}
229229

230230
string? mediaType = Constants.ApplicationJsonMediaType;
231-
if (operation.ReturnType.AsPrimitive()?.PrimitiveKind() == EdmPrimitiveTypeKind.Stream)
231+
if (returnType.AsPrimitive()?.PrimitiveKind() == EdmPrimitiveTypeKind.Stream)
232232
{
233233
mediaType = context.Model.GetString(operation, CoreConstants.MediaType);
234234

src/Microsoft.OpenApi.OData.Reader/Microsoft.OpenAPI.OData.Reader.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3131
</PackageReference>
3232
<PackageReference Include="Microsoft.OData.Edm" Version="8.4.3" />
33-
<PackageReference Include="Microsoft.OpenApi" Version="3.0.1" />
33+
<PackageReference Include="Microsoft.OpenApi" Version="3.1.2" />
3434
<None Include="..\..\README.md" Pack="true" PackagePath="\" />
3535
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.14.15">
3636
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ protected override void AppendCustomParameters(OpenApiOperation operation)
254254

255255
private void AppendSystemQueryOptions(IEdmFunction function, OpenApiOperation operation)
256256
{
257-
if (function.ReturnType.IsCollection() && Context is not null)
257+
if (function.GetReturn()?.Type is {} functionReturnType && functionReturnType.IsCollection() && Context is not null)
258258
{
259259
operation.Parameters ??= [];
260260
// $top
@@ -287,7 +287,7 @@ private void AppendSystemQueryOptions(IEdmFunction function, OpenApiOperation op
287287
operation.Parameters.AppendParameter(countParameter);
288288
}
289289

290-
if (function.ReturnType?.Definition?.AsElementType() is IEdmEntityType entityType)
290+
if (functionReturnType?.Definition?.AsElementType() is IEdmEntityType entityType)
291291
{
292292
// $select
293293
if (Context.CreateSelect(function, entityType) is {} selectParameter)
@@ -347,7 +347,7 @@ protected override void SetExternalDocs(OpenApiOperation operation)
347347
// <inheritdoc/>
348348
protected override void SetExtensions(OpenApiOperation operation)
349349
{
350-
if (Context is { Settings.EnablePagination: true } && EdmOperation?.ReturnType?.TypeKind() == EdmTypeKind.Collection)
350+
if (Context is { Settings.EnablePagination: true } && EdmOperation?.GetReturn()?.Type?.TypeKind() == EdmTypeKind.Collection)
351351
{
352352
var extension = new JsonObject
353353
{

test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiSchemaGeneratorTests.cs

Lines changed: 43 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -368,75 +368,71 @@ public async Task CreateStructuredTypePropertiesSchemaWithCustomAttributeReturns
368368

369369
// Assert
370370
Assert.NotNull(json);
371-
Assert.True(JsonObject.DeepEquals(JsonObject.Parse(@"{
372-
""allOf"": [
371+
Assert.True(JsonNode.DeepEquals(JsonNode.Parse(
372+
"""
373+
{
374+
"allOf": [
373375
{
374-
""$ref"": ""#/components/schemas/microsoft.graph.entity""
376+
"$ref": "#/components/schemas/microsoft.graph.entity"
375377
},
376378
{
377-
""title"": ""userSettings"",
378-
""type"": ""object"",
379-
""properties"": {
380-
""contributionToContentDiscoveryAsOrganizationDisabled"": {
381-
""type"": ""boolean"",
382-
""description"": ""Reflects the Office Delve organization level setting. When set to true, the organization doesn't have access to Office Delve. This setting is read-only and can only be changed by administrators in the SharePoint admin center.""
379+
"title": "userSettings",
380+
"type": "object",
381+
"properties": {
382+
"contributionToContentDiscoveryAsOrganizationDisabled": {
383+
"type": "boolean",
384+
"description": "Reflects the Office Delve organization level setting. When set to true, the organization doesn't have access to Office Delve. This setting is read-only and can only be changed by administrators in the SharePoint admin center."
383385
},
384-
""contributionToContentDiscoveryDisabled"": {
385-
""type"": ""boolean"",
386-
""description"": ""When set to true, documents in the user's Office Delve are disabled. Users can control this setting in Office Delve.""
386+
"contributionToContentDiscoveryDisabled": {
387+
"type": "boolean",
388+
"description": "When set to true, documents in the user's Office Delve are disabled. Users can control this setting in Office Delve."
387389
},
388-
""itemInsights"": {
389-
""anyOf"": [
390+
"itemInsights": {
391+
"anyOf": [
390392
{
391-
""$ref"": ""#/components/schemas/microsoft.graph.userInsightsSettings""
392-
},
393-
{
394-
""nullable"": true
393+
"$ref": "#/components/schemas/microsoft.graph.userInsightsSettings"
395394
}
396395
],
397-
""description"": ""The user's settings for the visibility of meeting hour insights, and insights derived between a user and other items in Microsoft 365, such as documents or sites. Get userInsightsSettings through this navigation property."",
398-
""x-ms-navigationProperty"": true
396+
"description": "The user's settings for the visibility of meeting hour insights, and insights derived between a user and other items in Microsoft 365, such as documents or sites. Get userInsightsSettings through this navigation property.",
397+
"nullable": true,
398+
"x-ms-navigationProperty": true
399399
},
400-
""contactMergeSuggestions"": {
401-
""anyOf"": [
400+
"contactMergeSuggestions": {
401+
"anyOf": [
402402
{
403-
""$ref"": ""#/components/schemas/microsoft.graph.contactMergeSuggestions""
404-
},
405-
{
406-
""nullable"": true
403+
"$ref": "#/components/schemas/microsoft.graph.contactMergeSuggestions"
407404
}
408405
],
409-
""description"": ""The user's settings for the visibility of merge suggestion for the duplicate contacts in the user's contact list."",
410-
""x-ms-navigationProperty"": true
406+
"description": "The user's settings for the visibility of merge suggestion for the duplicate contacts in the user's contact list.",
407+
"nullable": true,
408+
"x-ms-navigationProperty": true
411409
},
412-
""regionalAndLanguageSettings"": {
413-
""anyOf"": [
414-
{
415-
""$ref"": ""#/components/schemas/microsoft.graph.regionalAndLanguageSettings""
416-
},
410+
"regionalAndLanguageSettings": {
411+
"anyOf": [
417412
{
418-
""nullable"": true
413+
"$ref": "#/components/schemas/microsoft.graph.regionalAndLanguageSettings"
419414
}
420415
],
421-
""description"": ""The user's preferences for languages, regional locale and date/time formatting."",
422-
""x-ms-navigationProperty"": true
416+
"description": "The user's preferences for languages, regional locale and date/time formatting.",
417+
"nullable": true,
418+
"x-ms-navigationProperty": true
423419
},
424-
""shiftPreferences"": {
425-
""anyOf"": [
426-
{
427-
""$ref"": ""#/components/schemas/microsoft.graph.shiftPreferences""
428-
},
420+
"shiftPreferences": {
421+
"anyOf": [
429422
{
430-
""nullable"": true
423+
"$ref": "#/components/schemas/microsoft.graph.shiftPreferences"
431424
}
432425
],
433-
""description"": ""The shift preferences for the user."",
434-
""x-ms-navigationProperty"": true
426+
"description": "The shift preferences for the user.",
427+
"nullable": true,
428+
"x-ms-navigationProperty": true
435429
}
436430
}
437431
}
438432
]
439-
}"), JsonObject.Parse(json)));
433+
}
434+
"""
435+
), JsonNode.Parse(json)));
440436
}
441437

442438
[Fact]
@@ -920,12 +916,10 @@ public async Task CreatePropertySchemaForNullableEnumPropertyReturnSchema(OpenAp
920916
"anyOf": [
921917
{
922918
"$ref": "#/components/schemas/DefaultNs.Color"
923-
},
924-
{
925-
"nullable": true
926919
}
927920
],
928-
"default": "yellow"
921+
"default": "yellow",
922+
"nullable": true
929923
}
930924
""",
931925
OpenApiSpecVersion.OpenApi3_1 =>

0 commit comments

Comments
 (0)