-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
models: align with the semver versioning strategy and introduce model…
… wrappers since the models are tied to the version of the api, api versioning itself will be dynamic and based on the model version the original model will be serialized with the json serializer to its utf8 bytes representation of the model. the model wrapper has the model version as a readonly property based on a constant "currentversion" with this approach to versioning, there's no such thing as controller duplication to deal with specific versions of the api and models at all. automapper will be tweaked to map between the models and its entity equivalent by adding or removing properties and setting defaults all the responsibility will be placed on automapper and its mapper profiles to deal with versioning using the model version in the model wrapper extension methods will also be created to map to and from the serialized model at the level of the api and also pass in a generic type that will be used to determine which model to deserialize to before automapper. example being BrandModel or TyreModel for the tyres model wrapper when i came across api versioning, everyone duplicates the controllers and i won't tolerate that because it's too much of technical debt. this is the best approach to this problem that i could come up with and i can safely say that this is my very own solution to this problem also, initially i was thinking of adding the version to the api routes but with this, it introduces another problem. ocelot would have to be modified which is pain. so to avoid that, a header will be sent with the request using the version from the models-library constant "currentversion" which nicely ties in with the version of the api to use. any clients would not need to change any code in order to work with the apis
- Loading branch information
1 parent
4c43efc
commit 12f290f
Showing
25 changed files
with
76 additions
and
24 deletions.
There are no files selected for viewing
8 changes: 4 additions & 4 deletions
8
src/Frontends/MvcSolution/SeelansTyres.Frontends.Mvc/GlobalUsings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
global using SeelansTyres.Models.AddressModels.V1; | ||
global using SeelansTyres.Models.IdentityModels.V1; | ||
global using SeelansTyres.Models.OrderModels.V1; | ||
global using SeelansTyres.Models.TyresModels.V1; | ||
global using SeelansTyres.Models.AddressModels.V1_0_0; | ||
global using SeelansTyres.Models.IdentityModels.V1_0_0; | ||
global using SeelansTyres.Models.OrderModels.V1_0_0; | ||
global using SeelansTyres.Models.TyresModels.V1_0_0; |
2 changes: 1 addition & 1 deletion
2
src/Frontends/MvcSolution/SeelansTyres.Frontends.Mvc/Templates/Receipt.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/Services/AddressServiceSolution/SeelansTyres.Models.AddressModels/AddressModelWrapper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace SeelansTyres.Models.AddressModels; | ||
|
||
public class AddressModelWrapper | ||
{ | ||
public byte[] SerializedAddressModel { get; set; } = Array.Empty<byte>(); | ||
public static string ModelVersion => Constants.CurrentVersion; | ||
} |
6 changes: 6 additions & 0 deletions
6
src/Services/AddressServiceSolution/SeelansTyres.Models.AddressModels/Constants.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace SeelansTyres.Models.AddressModels; | ||
|
||
public static class Constants | ||
{ | ||
public static string CurrentVersion => "v1.0.0"; | ||
} |
2 changes: 1 addition & 1 deletion
2
...s.Models.AddressModels/V1/AddressModel.cs → ...dels.AddressModels/V1_0_0/AddressModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/Services/AddressServiceSolution/SeelansTyres.Services.AddressService/GlobalUsings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
global using SeelansTyres.Models.AddressModels.V1; | ||
global using SeelansTyres.Models.AddressModels.V1_0_0; |
6 changes: 6 additions & 0 deletions
6
src/Services/IdentityServiceSolution/SeelansTyres.Models.IdentityModels/Constants.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace SeelansTyres.Models.IdentityModels; | ||
|
||
public static class Constants | ||
{ | ||
public static string CurrentVersion => "v1.0.0"; | ||
} |
7 changes: 7 additions & 0 deletions
7
...rvices/IdentityServiceSolution/SeelansTyres.Models.IdentityModels/IdentityModelWrapper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace SeelansTyres.Models.IdentityModels; | ||
|
||
public class IdentityModelWrapper | ||
{ | ||
public byte[] SerializedIdentityModel { get; set; } = Array.Empty<byte>(); | ||
public static string ModelVersion => Constants.CurrentVersion; | ||
} |
2 changes: 1 addition & 1 deletion
2
...Models.IdentityModels/V1/CustomerModel.cs → ...ls.IdentityModels/V1_0_0/CustomerModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...Models.IdentityModels/V1/PasswordModel.cs → ...ls.IdentityModels/V1_0_0/PasswordModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...Models.IdentityModels/V1/RegisterModel.cs → ...ls.IdentityModels/V1_0_0/RegisterModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...s.IdentityModels/V1/UpdateAccountModel.cs → ...entityModels/V1_0_0/UpdateAccountModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/Services/IdentityServiceSolution/SeelansTyres.Services.IdentityService/GlobalUsings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
global using SeelansTyres.Models.IdentityModels.V1; | ||
global using SeelansTyres.Models.IdentityModels.V1_0_0; |
6 changes: 6 additions & 0 deletions
6
src/Services/OrderServiceSolution/SeelansTyres.Models.OrderModels/Constants.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace SeelansTyres.Models.OrderModels; | ||
|
||
public static class Constants | ||
{ | ||
public static string CurrentVersion => "v1.0.0"; | ||
} |
7 changes: 7 additions & 0 deletions
7
src/Services/OrderServiceSolution/SeelansTyres.Models.OrderModels/OrderModelWrapper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace SeelansTyres.Models.OrderModels; | ||
|
||
public class OrderModelWrapper | ||
{ | ||
public byte[] SerializedOrderModel { get; set; } = Array.Empty<byte>(); | ||
public static string ModelVersion => Constants.CurrentVersion; | ||
} |
2 changes: 1 addition & 1 deletion
2
...s.Models.OrderModels/V1/OrderItemModel.cs → ...dels.OrderModels/V1_0_0/OrderItemModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...Tyres.Models.OrderModels/V1/OrderModel.cs → ...s.Models.OrderModels/V1_0_0/OrderModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/Services/OrderServiceSolution/SeelansTyres.Services.OrderService/GlobalUsings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
global using SeelansTyres.Models.OrderModels.V1; | ||
global using SeelansTyres.Models.OrderModels.V1_0_0; |
4 changes: 2 additions & 2 deletions
4
src/Services/OrderServiceSolution/SeelansTyres.Workers.OrderWorker/GlobalUsings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
global using SeelansTyres.Models.IdentityModels.V1; | ||
global using SeelansTyres.Models.TyresModels.V1; | ||
global using SeelansTyres.Models.IdentityModels.V1_0_0; | ||
global using SeelansTyres.Models.TyresModels.V1_0_0; |
6 changes: 6 additions & 0 deletions
6
src/Services/TyresServiceSolution/SeelansTyres.Models.TyresModels/Constants.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace SeelansTyres.Models.TyresModels; | ||
|
||
public static class Constants | ||
{ | ||
public static string CurrentVersion => "v1.0.0"; | ||
} |
7 changes: 7 additions & 0 deletions
7
src/Services/TyresServiceSolution/SeelansTyres.Models.TyresModels/TyresModelWrapper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace SeelansTyres.Models.TyresModels; | ||
|
||
public class TyresModelWrapper | ||
{ | ||
public byte[] SerializedTyresModel { get; set; } = Array.Empty<byte>(); | ||
public static string ModelVersion => Constants.CurrentVersion; | ||
} |
2 changes: 1 addition & 1 deletion
2
...Tyres.Models.TyresModels/V1/BrandModel.cs → ...s.Models.TyresModels/V1_0_0/BrandModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...sTyres.Models.TyresModels/V1/TyreModel.cs → ...es.Models.TyresModels/V1_0_0/TyreModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/Services/TyresServiceSolution/SeelansTyres.Services.TyresService/GlobalUsings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
global using SeelansTyres.Models.TyresModels.V1; | ||
global using SeelansTyres.Models.TyresModels.V1_0_0; |