Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Microsoft.OpenApi.OData.Reader/Common/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ internal static class Constants
/// </summary>
public static string xMsDiscriminatorValue = "x-ms-discriminator-value";

/// <summary>
/// extension for navigation property
/// </summary>
public static string xMsNavigationProperty = "x-ms-navigationProperty";

/// <summary>
/// Name used for the OpenAPI referenced schema for OData Count operations responses.
/// </summary>
Expand Down
6 changes: 3 additions & 3 deletions src/Microsoft.OpenApi.OData.Reader/Common/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ internal static bool TryAdd<TKey, TValue>(this IDictionary<TKey, TValue> diction
/// values will be added to.</param>
/// <param name="context">The OData context.</param>
/// <param name="element">The target element.</param>
internal static void AddCustomAtributesToExtensions(this IDictionary<string, IOpenApiExtension> extensions, ODataContext context, IEdmElement element)
internal static void AddCustomAttributesToExtensions(this IDictionary<string, IOpenApiExtension> extensions, ODataContext context, IEdmElement element)
{
if (extensions == null ||
context == null ||
Expand All @@ -175,7 +175,7 @@ internal static void AddCustomAtributesToExtensions(this IDictionary<string, IOp
return;
}

Dictionary<string, string> atrributesValueMap = GetCustomXMLAtrributesValueMapping(context.Model, element, context.Settings.CustomXMLAttributesMapping);
Dictionary<string, string> atrributesValueMap = GetCustomXMLAttributesValueMapping(context.Model, element, context.Settings.CustomXMLAttributesMapping);

if (atrributesValueMap?.Any() ?? false)
{
Expand All @@ -194,7 +194,7 @@ internal static void AddCustomAtributesToExtensions(this IDictionary<string, IOp
/// <param name="element">The target element.</param>
/// <param name="customXMLAttributesMapping">The dictionary mapping of attribute names and extension names.</param>
/// <returns>A dictionary of extension names mapped to the custom attribute values.</returns>
private static Dictionary<string, string> GetCustomXMLAtrributesValueMapping(IEdmModel model, IEdmElement element, Dictionary<string, string> customXMLAttributesMapping)
private static Dictionary<string, string> GetCustomXMLAttributesValueMapping(IEdmModel model, IEdmElement element, Dictionary<string, string> customXMLAttributesMapping)
{
Dictionary<string, string> atrributesValueMap = new();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ public static IDictionary<string, OpenApiSchema> CreateStructuredTypePropertiesS
{
OpenApiSchema propertySchema = context.CreatePropertySchema(property);
propertySchema.Description = context.Model.GetDescriptionAnnotation(property);
propertySchema.Extensions.AddCustomAtributesToExtensions(context, property);
propertySchema.Extensions.AddCustomAttributesToExtensions(context, property);
properties.Add(property.Name, propertySchema);
}

Expand All @@ -398,7 +398,8 @@ public static IDictionary<string, OpenApiSchema> CreateStructuredTypePropertiesS
{
OpenApiSchema propertySchema = context.CreateEdmTypeSchema(property.Type);
propertySchema.Description = context.Model.GetDescriptionAnnotation(property);
propertySchema.Extensions.AddCustomAtributesToExtensions(context, property);
propertySchema.Extensions.AddCustomAttributesToExtensions(context, property);
propertySchema.Extensions.Add(Constants.xMsNavigationProperty, new OpenApiBoolean(true));
properties.Add(property.Name, propertySchema);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,6 @@ protected override void Initialize(ODataContext context, ODataPath path)
/// <inheritdoc/>
protected override void SetExtensions(OpenApiPathItem item)
{
item.Extensions.AddCustomAtributesToExtensions(Context, ComplexProperty);
item.Extensions.AddCustomAttributesToExtensions(Context, ComplexProperty);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ protected override void SetOperations(OpenApiPathItem item)
protected override void SetExtensions(OpenApiPathItem pathItem)
{
base.SetExtensions(pathItem);
pathItem.Extensions.AddCustomAtributesToExtensions(Context, EntitySet.EntityType());
pathItem.Extensions.AddCustomAttributesToExtensions(Context, EntitySet.EntityType());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected override void SetBasicInfo(OpenApiPathItem pathItem)
protected override void SetExtensions(OpenApiPathItem pathItem)
{
base.SetExtensions(pathItem);
pathItem.Extensions.AddCustomAtributesToExtensions(Context, EntitySet);
pathItem.Extensions.AddCustomAttributesToExtensions(Context, EntitySet);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ protected override void SetExtensions(OpenApiPathItem item)
}

base.SetExtensions(item);
item.Extensions.AddCustomAtributesToExtensions(Context, NavigationProperty);
item.Extensions.AddCustomAttributesToExtensions(Context, NavigationProperty);
}
/// <inheritdoc/>
protected override void SetBasicInfo(OpenApiPathItem pathItem)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ protected override void SetBasicInfo(OpenApiPathItem pathItem)
protected override void SetExtensions(OpenApiPathItem pathItem)
{
base.SetExtensions(pathItem);
pathItem.Extensions.AddCustomAtributesToExtensions(Context, StructuredType);
pathItem.Extensions.AddCustomAttributesToExtensions(Context, StructuredType);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ protected override void SetBasicInfo(OpenApiPathItem pathItem)
protected override void SetExtensions(OpenApiPathItem item)
{
base.SetExtensions(item);
item.Extensions.AddCustomAtributesToExtensions(Context, EdmOperationImport);
item.Extensions.AddCustomAttributesToExtensions(Context, EdmOperationImport);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ protected override void SetExtensions(OpenApiPathItem item)
}

base.SetExtensions(item);
item.Extensions.AddCustomAtributesToExtensions(Context, EdmOperation);
item.Extensions.AddCustomAttributesToExtensions(Context, EdmOperation);
}

/// <inheritdoc/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ protected override void SetBasicInfo(OpenApiPathItem pathItem)
protected override void SetExtensions(OpenApiPathItem pathItem)
{
base.SetExtensions(pathItem);
pathItem.Extensions.AddCustomAtributesToExtensions(Context, Singleton);
pathItem.Extensions.AddCustomAttributesToExtensions(Context, Singleton);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,8 @@ public void CreateStructuredTypePropertiesSchemaWithCustomAttributeReturnsCorrec
""nullable"": true
}
],
""x-ms-isHidden"": ""true""
""x-ms-isHidden"": ""true"",
""x-ms-navigationProperty"": true
},
""regionalAndLanguageSettings"": {
""anyOf"": [
Expand All @@ -316,7 +317,8 @@ public void CreateStructuredTypePropertiesSchemaWithCustomAttributeReturnsCorrec
""type"": ""object"",
""nullable"": true
}
]
],
""x-ms-navigationProperty"": true
},
""shiftPreferences"": {
""anyOf"": [
Expand All @@ -327,7 +329,8 @@ public void CreateStructuredTypePropertiesSchemaWithCustomAttributeReturnsCorrec
""type"": ""object"",
""nullable"": true
}
]
],
""x-ms-navigationProperty"": true
}
}
}
Expand Down Expand Up @@ -524,7 +527,8 @@ public void CreateEntityTypeWithoutBaseSchemaReturnCorrectSchema()
""type"": ""array"",
""items"": {
""$ref"": ""#/components/schemas/NS.Creature""
}
},
""x-ms-navigationProperty"": true
}
},
""description"": ""Entity type 'Zoo' description."",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3940,7 +3940,8 @@
"type": "array",
"items": {
"$ref": "#/definitions/Siterra.Documents.App.DTO.RevisionDto"
}
},
"x-ms-navigationProperty": true
}
},
"example": {
Expand Down Expand Up @@ -4046,7 +4047,8 @@
"type": "array",
"items": {
"$ref": "#/definitions/Siterra.Documents.App.DTO.DocumentDto"
}
},
"x-ms-navigationProperty": true
}
},
"example": {
Expand Down Expand Up @@ -4483,13 +4485,15 @@
"type": "array",
"items": {
"$ref": "#/definitions/Siterra.Documents.BusinessLogic.Entities.Document.Document"
}
},
"x-ms-navigationProperty": true
},
"Revisions": {
"type": "array",
"items": {
"$ref": "#/definitions/Siterra.Documents.BusinessLogic.Entities.Revision.Revision"
}
},
"x-ms-navigationProperty": true
}
},
"example": {
Expand Down Expand Up @@ -4915,19 +4919,22 @@
"type": "array",
"items": {
"$ref": "#/definitions/Siterra.Documents.BusinessLogic.Entities.Document.Document"
}
},
"x-ms-navigationProperty": true
},
"LibraryChildren": {
"type": "array",
"items": {
"$ref": "#/definitions/Siterra.Documents.BusinessLogic.Entities.Library.Library"
}
},
"x-ms-navigationProperty": true
},
"SourceLibraryChildren": {
"type": "array",
"items": {
"$ref": "#/definitions/Siterra.Documents.BusinessLogic.Entities.Library.Library"
}
},
"x-ms-navigationProperty": true
}
},
"example": {
Expand Down Expand Up @@ -5078,13 +5085,15 @@
"type": "array",
"items": {
"$ref": "#/definitions/Siterra.Documents.BusinessLogic.Entities.Library.LibraryType"
}
},
"x-ms-navigationProperty": true
},
"ChildrenLibraryTypes": {
"type": "array",
"items": {
"$ref": "#/definitions/Siterra.Documents.BusinessLogic.Entities.Library.LibraryType"
}
},
"x-ms-navigationProperty": true
}
},
"example": {
Expand Down Expand Up @@ -5213,7 +5222,8 @@
"type": "array",
"items": {
"$ref": "#/definitions/Siterra.Documents.BusinessLogic.Entities.Document.Document"
}
},
"x-ms-navigationProperty": true
}
},
"example": {
Expand Down Expand Up @@ -5344,7 +5354,8 @@
"type": "array",
"items": {
"$ref": "#/definitions/Siterra.Documents.BusinessLogic.Entities.Document.Document"
}
},
"x-ms-navigationProperty": true
}
}
}
Expand Down Expand Up @@ -5378,7 +5389,8 @@
"type": "array",
"items": {
"$ref": "#/definitions/Siterra.Documents.BusinessLogic.Entities.Document.Document"
}
},
"x-ms-navigationProperty": true
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2833,6 +2833,7 @@ definitions:
type: array
items:
$ref: '#/definitions/Siterra.Documents.App.DTO.RevisionDto'
x-ms-navigationProperty: true
example:
Id: integer (identifier)
Name: string
Expand Down Expand Up @@ -2913,6 +2914,7 @@ definitions:
type: array
items:
$ref: '#/definitions/Siterra.Documents.App.DTO.DocumentDto'
x-ms-navigationProperty: true
example:
Id: integer (identifier)
Name: string
Expand Down Expand Up @@ -3256,10 +3258,12 @@ definitions:
type: array
items:
$ref: '#/definitions/Siterra.Documents.BusinessLogic.Entities.Document.Document'
x-ms-navigationProperty: true
Revisions:
type: array
items:
$ref: '#/definitions/Siterra.Documents.BusinessLogic.Entities.Revision.Revision'
x-ms-navigationProperty: true
example:
Id: integer (identifier)
Name: string
Expand Down Expand Up @@ -3599,14 +3603,17 @@ definitions:
type: array
items:
$ref: '#/definitions/Siterra.Documents.BusinessLogic.Entities.Document.Document'
x-ms-navigationProperty: true
LibraryChildren:
type: array
items:
$ref: '#/definitions/Siterra.Documents.BusinessLogic.Entities.Library.Library'
x-ms-navigationProperty: true
SourceLibraryChildren:
type: array
items:
$ref: '#/definitions/Siterra.Documents.BusinessLogic.Entities.Library.Library'
x-ms-navigationProperty: true
example:
Id: integer (identifier)
DomainId: integer
Expand Down Expand Up @@ -3725,10 +3732,12 @@ definitions:
type: array
items:
$ref: '#/definitions/Siterra.Documents.BusinessLogic.Entities.Library.LibraryType'
x-ms-navigationProperty: true
ChildrenLibraryTypes:
type: array
items:
$ref: '#/definitions/Siterra.Documents.BusinessLogic.Entities.Library.LibraryType'
x-ms-navigationProperty: true
example:
Id: integer (identifier)
Name: string
Expand Down Expand Up @@ -3828,6 +3837,7 @@ definitions:
type: array
items:
$ref: '#/definitions/Siterra.Documents.BusinessLogic.Entities.Document.Document'
x-ms-navigationProperty: true
example:
Id: integer (identifier)
Name: string
Expand Down Expand Up @@ -3924,6 +3934,7 @@ definitions:
type: array
items:
$ref: '#/definitions/Siterra.Documents.BusinessLogic.Entities.Document.Document'
x-ms-navigationProperty: true
example:
Id: integer (identifier)
DomainId: integer
Expand All @@ -3945,6 +3956,7 @@ definitions:
type: array
items:
$ref: '#/definitions/Siterra.Documents.BusinessLogic.Entities.Document.Document'
x-ms-navigationProperty: true
example:
Id: integer (identifier)
DomainId: integer
Expand Down
Loading