Skip to content

Updates PUT operation id prefix from Update to Set #601

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 25, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<TargetFrameworks>net8.0</TargetFrameworks>
<PackageId>Microsoft.OpenApi.OData</PackageId>
<SignAssembly>true</SignAssembly>
<Version>2.0.0-preview.6</Version>
<Version>2.0.0-preview.7</Version>
<Description>This package contains the codes you need to convert OData CSDL to Open API Document of Model.</Description>
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
<PackageTags>Microsoft OpenApi OData EDM</PackageTags>
Expand All @@ -32,6 +32,7 @@
- Replaced integer types by number types
- Further fix for generating unique operation ids for paths with composable overloaded functions where all functions in path are overloaded #594
- Further fix for generating unique operation ids for navigation property paths with composable overloaded functions #596
- Updates PUT operation id prefix from Update to Set #600
</PackageReleaseNotes>
<AssemblyName>Microsoft.OpenApi.OData.Reader</AssemblyName>
<AssemblyOriginatorKeyFile>..\..\tool\Microsoft.OpenApi.OData.snk</AssemblyOriginatorKeyFile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ protected override void SetBasicInfo(OpenApiOperation operation)

// OperationId
if (Context.Settings.EnableOperationId)
{
operation.OperationId = EdmModelHelper.GenerateComplexPropertyPathOperationId(Path, Context, "Update");
{
string prefix = OperationType == OperationType.Patch ? "Update" : "Set";
operation.OperationId = EdmModelHelper.GenerateComplexPropertyPathOperationId(Path, Context, prefix);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ protected override void SetBasicInfo(OpenApiOperation operation)
if (Context.Settings.EnableOperationId)
{
string typeName = entityType.Name;
string operationName = $"Update{ Utils.UpperFirstChar(typeName)}";
string prefix = OperationType == OperationType.Patch ? "Update" : "Set";
string operationName = $"{prefix}{ Utils.UpperFirstChar(typeName)}";
if (keySegment.IsAlternateKey)
{
string alternateKeyName = string.Join("", keySegment.Identifier.Split(',').Select(static x => Utils.UpperFirstChar(x)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected override void SetBasicInfo(OpenApiOperation operation)
// OperationId
if (Context.Settings.EnableOperationId)
{
string prefix = "Update";
string prefix = OperationType == OperationType.Patch ? "Update" : "Set";
operation.OperationId = GetOperationId(prefix);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void CreateComplexPropertyPutOperationReturnsCorrectOperationForSingle(bo

if (enableOperationId)
{
Assert.Equal("Customers.UpdateBillingAddress", put.OperationId);
Assert.Equal("Customers.SetBillingAddress", put.OperationId);
}
else
{
Expand Down Expand Up @@ -108,7 +108,7 @@ public void CreateComplexPropertyPutOperationReturnsCorrectOperationForCollectio

if (enableOperationId)
{
Assert.Equal("Customers.UpdateAlternativeAddresses", put.OperationId);
Assert.Equal("Customers.SetAlternativeAddresses", put.OperationId);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void CreateEntityPutOperationReturnsCorrectOperation(bool enableOperation

if (enableOperationId)
{
Assert.Equal("Customers.Customer.UpdateCustomer", putOperation.OperationId);
Assert.Equal("Customers.Customer.SetCustomer", putOperation.OperationId);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void CreateNavigationPutOperationReturnsCorrectOperation(bool enableOpera

if (enableOperationId)
{
Assert.Equal("People.UpdateBestFriend", operation.OperationId);
Assert.Equal("People.SetBestFriend", operation.OperationId);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
"Airlines.Airline"
],
"summary": "Update entity in Airlines",
"operationId": "Airlines.Airline.UpdateAirline",
"operationId": "Airlines.Airline.SetAirline",
"consumes": [
"application/json"
],
Expand Down Expand Up @@ -534,7 +534,7 @@
"Airports.AirportLocation"
],
"summary": "Update property Location value.",
"operationId": "Airports.UpdateLocation",
"operationId": "Airports.SetLocation",
"consumes": [
"application/json"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ paths:
tags:
- Airlines.Airline
summary: Update entity in Airlines
operationId: Airlines.Airline.UpdateAirline
operationId: Airlines.Airline.SetAirline
consumes:
- application/json
parameters:
Expand Down Expand Up @@ -349,7 +349,7 @@ paths:
tags:
- Airports.AirportLocation
summary: Update property Location value.
operationId: Airports.UpdateLocation
operationId: Airports.SetLocation
consumes:
- application/json
parameters:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
"Airlines.Airline"
],
"summary": "Update entity in Airlines",
"operationId": "Airlines.Airline.UpdateAirline",
"operationId": "Airlines.Airline.SetAirline",
"parameters": [
{
"name": "AirlineCode",
Expand Down Expand Up @@ -609,7 +609,7 @@
"Airports.AirportLocation"
],
"summary": "Update property Location value.",
"operationId": "Airports.UpdateLocation",
"operationId": "Airports.SetLocation",
"parameters": [
{
"name": "IcaoCode",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ paths:
tags:
- Airlines.Airline
summary: Update entity in Airlines
operationId: Airlines.Airline.UpdateAirline
operationId: Airlines.Airline.SetAirline
parameters:
- name: AirlineCode
in: path
Expand Down Expand Up @@ -398,7 +398,7 @@ paths:
tags:
- Airports.AirportLocation
summary: Update property Location value.
operationId: Airports.UpdateLocation
operationId: Airports.SetLocation
parameters:
- name: IcaoCode
in: path
Expand Down
Loading