Skip to content

Commit 73ff328

Browse files
authored
Merge branch 'support/v1' into fix/port-590
Signed-off-by: GitHub <[email protected]>
2 parents 4c8eafa + 481ad4b commit 73ff328

17 files changed

+488
-554
lines changed

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

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ protected override void Initialize(ODataContext context, ODataPath path)
2323
{
2424
base.Initialize(context, path);
2525

26-
_updateRestrictions = Context.Model.GetRecord<UpdateRestrictionsType>(TargetPath, CapabilitiesConstants.UpdateRestrictions);
27-
var complexPropertyUpdateRestrictions = Context.Model.GetRecord<UpdateRestrictionsType>(ComplexPropertySegment.Property, CapabilitiesConstants.UpdateRestrictions);
28-
_updateRestrictions?.MergePropertiesIfNull(complexPropertyUpdateRestrictions);
26+
_updateRestrictions = Context.Model.GetRecord<UpdateRestrictionsType>(TargetPath, CapabilitiesConstants.UpdateRestrictions);
27+
var complexPropertyUpdateRestrictions = Context.Model.GetRecord<UpdateRestrictionsType>(ComplexPropertySegment.Property, CapabilitiesConstants.UpdateRestrictions);
28+
_updateRestrictions?.MergePropertiesIfNull(complexPropertyUpdateRestrictions);
2929
_updateRestrictions ??= complexPropertyUpdateRestrictions;
3030
}
3131

@@ -40,7 +40,8 @@ protected override void SetBasicInfo(OpenApiOperation operation)
4040
// OperationId
4141
if (Context.Settings.EnableOperationId)
4242
{
43-
operation.OperationId = EdmModelHelper.GenerateComplexPropertyPathOperationId(Path, "Update");
43+
string prefix = OperationType == OperationType.Patch ? "Update" : "Set";
44+
operation.OperationId = EdmModelHelper.GenerateComplexPropertyPathOperationId(Path, prefix);
4445
}
4546
}
4647

@@ -101,37 +102,37 @@ protected override void AppendCustomParameters(OpenApiOperation operation)
101102

102103
private OpenApiSchema GetOpenApiSchema()
103104
{
104-
var schema = new OpenApiSchema
105-
{
106-
UnresolvedReference = true,
107-
Reference = new OpenApiReference
108-
{
109-
Type = ReferenceType.Schema,
110-
Id = ComplexPropertySegment.ComplexType.FullName()
111-
}
112-
};
113-
114-
if (ComplexPropertySegment.Property.Type.IsCollection())
115-
{
105+
var schema = new OpenApiSchema
106+
{
107+
UnresolvedReference = true,
108+
Reference = new OpenApiReference
109+
{
110+
Type = ReferenceType.Schema,
111+
Id = ComplexPropertySegment.ComplexType.FullName()
112+
}
113+
};
114+
115+
if (ComplexPropertySegment.Property.Type.IsCollection())
116+
{
116117
return new OpenApiSchema
117118
{
118119
Type = Constants.ObjectType,
119-
Properties = new Dictionary<string, OpenApiSchema>
120-
{
121-
{
120+
Properties = new Dictionary<string, OpenApiSchema>
121+
{
122+
{
122123
"value",
123124
new OpenApiSchema
124125
{
125126
Type = "array",
126127
Items = schema
127-
}
128-
}
128+
}
129+
}
129130
}
130-
};
131-
}
132-
else
133-
{
134-
return schema;
131+
};
132+
}
133+
else
134+
{
135+
return schema;
135136
}
136137
}
137138
}

0 commit comments

Comments
 (0)