Skip to content

Commit 10a39ab

Browse files
committed
fix: draft porting to newer proxy implementation design
1 parent 8850118 commit 10a39ab

40 files changed

Lines changed: 366 additions & 343 deletions

src/Microsoft.OpenApi.OData.Reader/Common/EdmModelHelper.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using Microsoft.OData.Edm.Csdl;
1111
using Microsoft.OData.Edm.Vocabularies;
1212
using Microsoft.OpenApi.Models;
13+
using Microsoft.OpenApi.Models.Interfaces;
1314
using Microsoft.OpenApi.Models.References;
1415
using Microsoft.OpenApi.OData.Edm;
1516
using Microsoft.OpenApi.OData.Vocabulary.Capabilities;
@@ -37,15 +38,15 @@ internal static OpenApiSchema GetDerivedTypesReferenceSchema(IEdmStructuredType
3738

3839
OpenApiSchema schema = new()
3940
{
40-
OneOf = new List<OpenApiSchema>()
41+
OneOf = new List<IOpenApiSchema>()
4142
};
4243

43-
OpenApiSchema baseTypeSchema = new OpenApiSchemaReference(schemaElement.FullName(), document);
44+
var baseTypeSchema = new OpenApiSchemaReference(schemaElement.FullName(), document);
4445
schema.OneOf.Add(baseTypeSchema);
4546

4647
foreach (IEdmSchemaElement derivedType in derivedTypes)
4748
{
48-
OpenApiSchema derivedTypeSchema = new OpenApiSchemaReference(derivedType.FullName(), document);
49+
var derivedTypeSchema = new OpenApiSchemaReference(derivedType.FullName(), document);
4950
schema.OneOf.Add(derivedTypeSchema);
5051
};
5152

src/Microsoft.OpenApi.OData.Reader/Common/OpenApiOperationExtensions.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// ------------------------------------------------------------
55

66
using Microsoft.OpenApi.Models;
7+
using Microsoft.OpenApi.Models.Interfaces;
78
using Microsoft.OpenApi.OData.Generator;
89
using System.Collections.Generic;
910

@@ -23,7 +24,7 @@ internal static class OpenApiOperationExtensions
2324
/// <param name="addNoContent">Optional: Whether to add a 204 no content response.</param>
2425
/// <param name="schema">Optional: The OpenAPI schema of the response.</param>
2526
/// <param name="document">The OpenAPI document to lookup references.</param>
26-
public static void AddErrorResponses(this OpenApiOperation operation, OpenApiConvertSettings settings, OpenApiDocument document, bool addNoContent = false, OpenApiSchema schema = null)
27+
public static void AddErrorResponses(this OpenApiOperation operation, OpenApiConvertSettings settings, OpenApiDocument document, bool addNoContent = false, IOpenApiSchema schema = null)
2728
{
2829
Utils.CheckArgumentNull(operation, nameof(operation));
2930
Utils.CheckArgumentNull(settings, nameof(settings));

src/Microsoft.OpenApi.OData.Reader/Common/Utils.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using Microsoft.OpenApi.Any;
1313
using Microsoft.OpenApi.Interfaces;
1414
using Microsoft.OpenApi.Models;
15+
using Microsoft.OpenApi.Models.Interfaces;
1516
using Microsoft.OpenApi.OData.Edm;
1617
using Microsoft.OpenApi.OData.Vocabulary;
1718

@@ -307,7 +308,7 @@ private static IEdmEntityType EntityTypeFromOperationSegment(this ODataSegment s
307308
/// <param name="pathItem">The value to be added.</param>
308309
/// <returns>true when the key and/or value are successfully added/updated to the dictionary;
309310
/// false when the dictionary already contains the specified key, and nothing gets added.</returns>
310-
internal static bool TryAddPath(this IDictionary<string, OpenApiPathItem> pathItems,
311+
internal static bool TryAddPath(this IDictionary<string, IOpenApiPathItem> pathItems,
311312
ODataContext context,
312313
ODataPath path,
313314
OpenApiPathItem pathItem)

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

Lines changed: 70 additions & 103 deletions
Large diffs are not rendered by default.

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using Microsoft.OpenApi.OData.Edm;
1313
using Microsoft.OpenApi.MicrosoftExtensions;
1414
using Microsoft.OpenApi.Models.References;
15+
using Microsoft.OpenApi.Models.Interfaces;
1516

1617
namespace Microsoft.OpenApi.OData.Generator
1718
{
@@ -33,12 +34,12 @@ internal static class OpenApiErrorSchemaGenerator
3334
/// <param name="context">The OData to Open API context.</param>
3435
/// <param name="document">The Open API document to lookup references.</param>
3536
/// <returns>The string/schema dictionary.</returns>
36-
public static IDictionary<string, OpenApiSchema> CreateODataErrorSchemas(this ODataContext context, OpenApiDocument document)
37+
public static IDictionary<string, IOpenApiSchema> CreateODataErrorSchemas(this ODataContext context, OpenApiDocument document)
3738
{
3839
Utils.CheckArgumentNull(context, nameof(context));
3940
var rootNamespaceName = context.GetErrorNamespaceName();
4041

41-
return new Dictionary<string, OpenApiSchema>()
42+
return new Dictionary<string, IOpenApiSchema>()
4243
{
4344
{ $"{rootNamespaceName}{ODataErrorClassName}", CreateErrorSchema(rootNamespaceName, document) },
4445
{ $"{rootNamespaceName}{MainErrorClassName}", CreateErrorMainSchema(rootNamespaceName, document) },
@@ -75,7 +76,7 @@ public static OpenApiSchema CreateErrorSchema(string rootNamespaceName, OpenApiD
7576
{
7677
"error"
7778
},
78-
Properties = new Dictionary<string, OpenApiSchema>
79+
Properties = new Dictionary<string, IOpenApiSchema>
7980
{
8081
{
8182
"error",
@@ -92,7 +93,7 @@ public static OpenApiSchema CreateErrorSchema(string rootNamespaceName, OpenApiD
9293
/// <param name="context">The OData to Open API context.</param>
9394
/// <param name="document">The Open API document to lookup references.</param>
9495
/// <returns>The inner error schema definition.</returns>
95-
public static OpenApiSchema CreateInnerErrorSchema(ODataContext context, OpenApiDocument document)
96+
public static IOpenApiSchema CreateInnerErrorSchema(ODataContext context, OpenApiDocument document)
9697
{
9798
Utils.CheckArgumentNull(context, nameof(context));
9899

@@ -126,7 +127,7 @@ public static OpenApiSchema CreateErrorMainSchema(string rootNamespaceName, Open
126127
{
127128
"code", "message"
128129
},
129-
Properties = new Dictionary<string, OpenApiSchema>
130+
Properties = new Dictionary<string, IOpenApiSchema>
130131
{
131132
{
132133
"code", new OpenApiSchema { Type = JsonSchemaType.String, Nullable = false }
@@ -167,7 +168,7 @@ public static OpenApiSchema CreateErrorDetailSchema()
167168
{
168169
"code", "message"
169170
},
170-
Properties = new Dictionary<string, OpenApiSchema>
171+
Properties = new Dictionary<string, IOpenApiSchema>
171172
{
172173
{
173174
"code", new OpenApiSchema { Type = JsonSchemaType.String, Nullable = false, }

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using Microsoft.OpenApi.Models;
1010
using Microsoft.OpenApi.OData.Edm;
1111
using System.Linq;
12+
using Microsoft.OpenApi.Models.Interfaces;
1213

1314
namespace Microsoft.OpenApi.OData.Generator
1415
{
@@ -28,9 +29,9 @@ internal static class OpenApiLinkGenerator
2829
/// <param name="parameters">"Optional: The list of parameters of the incoming operation.</param>
2930
/// <param name="navPropOperationId">Optional: The operation id of the source of the NavigationProperty object.</param>
3031
/// <returns>The created dictionary of <see cref="OpenApiLink"/> object.</returns>
31-
public static IDictionary<string, OpenApiLink> CreateLinks(this ODataContext context,
32+
public static IDictionary<string, IOpenApiLink> CreateLinks(this ODataContext context,
3233
IEdmEntityType entityType, string entityName, string entityKind, ODataPath path,
33-
IList<OpenApiParameter> parameters = null, string navPropOperationId = null)
34+
IList<IOpenApiParameter> parameters = null, string navPropOperationId = null)
3435
{
3536
Utils.CheckArgumentNull(context, nameof(context));
3637
Utils.CheckArgumentNull(entityType, nameof(entityType));
@@ -53,7 +54,7 @@ public static IDictionary<string, OpenApiLink> CreateLinks(this ODataContext con
5354
}
5455
}
5556

56-
Dictionary<string, OpenApiLink> links = new();
57+
Dictionary<string, IOpenApiLink> links = new();
5758
bool lastSegmentIsColNavProp = (path.LastSegment as ODataNavigationPropertySegment)?.NavigationProperty.TargetMultiplicity() == EdmMultiplicity.Many;
5859

5960
// Valid only for non collection-valued navigation properties

0 commit comments

Comments
 (0)