Skip to content

Commit

Permalink
V5.3.0 (#210)
Browse files Browse the repository at this point in the history
* Add FluentValidation support.

* FluentValidation support.
MyEf.Hr pub/sub sample.

* Further doco.

* Sample and doco updates

* Fix #208
Fix #209

* Update the doco.

* Doco and sample tweaks.

* Doco and sample tweaks

* Update README.md

* Update Transactional-Outbox.md

* Update Service-Bus-Publish.md

* Update Service-Bus-Subscribe.md

* Final tweaks

---------

Signed-off-by: Eric Sibly [chullybun]
  • Loading branch information
chullybun authored Apr 24, 2023
1 parent 674ad1a commit 81e1bf9
Show file tree
Hide file tree
Showing 84 changed files with 1,865 additions and 98 deletions.
21 changes: 21 additions & 0 deletions Beef.sln
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{5BA9A863-C
samples\MyEf.Hr\docs\Employee-Search.md = samples\MyEf.Hr\docs\Employee-Search.md
samples\MyEf.Hr\docs\Employee-Terminate.md = samples\MyEf.Hr\docs\Employee-Terminate.md
samples\MyEf.Hr\docs\Employee-Test.md = samples\MyEf.Hr\docs\Employee-Test.md
samples\MyEf.Hr\docs\Event-Driven-Architecture.png = samples\MyEf.Hr\docs\Event-Driven-Architecture.png
samples\MyEf.Hr\docs\Performance-Review.md = samples\MyEf.Hr\docs\Performance-Review.md
samples\MyEf.Hr\docs\Service-Bus-Publish.md = samples\MyEf.Hr\docs\Service-Bus-Publish.md
samples\MyEf.Hr\docs\Service-Bus-Subscribe.md = samples\MyEf.Hr\docs\Service-Bus-Subscribe.md
samples\MyEf.Hr\docs\Transactional-Outbox.md = samples\MyEf.Hr\docs\Transactional-Outbox.md
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{FDBFD331-A9EB-42BF-B501-8398A04955A7}"
Expand Down Expand Up @@ -190,6 +194,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "images", "images", "{6739CF
docs\images\LogoPill.png = docs\images\LogoPill.png
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Security", "Security", "{D9DF805A-DD48-4036-B383-F1BC895C317C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MyEf.Hr.Security.Subscriptions", "samples\MyEf.Hr\MyEf.Hr.Security.Subscriptions\MyEf.Hr.Security.Subscriptions.csproj", "{EB2AD65F-BE16-4334-BFBE-719A88D118D7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MyEf.Hr.Security.Test", "samples\MyEf.Hr\MyEf.Hr.Security.Test\MyEf.Hr.Security.Test.csproj", "{7AE6E1D4-8621-4FC5-8A1F-448FA70DB257}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -320,6 +330,14 @@ Global
{8799923D-ECBA-4FAF-84F0-30E7F9C0E3E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8799923D-ECBA-4FAF-84F0-30E7F9C0E3E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8799923D-ECBA-4FAF-84F0-30E7F9C0E3E8}.Release|Any CPU.Build.0 = Release|Any CPU
{EB2AD65F-BE16-4334-BFBE-719A88D118D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EB2AD65F-BE16-4334-BFBE-719A88D118D7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EB2AD65F-BE16-4334-BFBE-719A88D118D7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EB2AD65F-BE16-4334-BFBE-719A88D118D7}.Release|Any CPU.Build.0 = Release|Any CPU
{7AE6E1D4-8621-4FC5-8A1F-448FA70DB257}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7AE6E1D4-8621-4FC5-8A1F-448FA70DB257}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7AE6E1D4-8621-4FC5-8A1F-448FA70DB257}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7AE6E1D4-8621-4FC5-8A1F-448FA70DB257}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -371,6 +389,9 @@ Global
{4EE60769-8A32-4B61-B54B-3CEE0C11E93F} = {5FC1E59C-A8C9-4CD7-9DAB-344E877BE8EC}
{5BA9A863-C057-46D5-8139-6353ACCCAA0A} = {5FC1E59C-A8C9-4CD7-9DAB-344E877BE8EC}
{6739CF51-CAB1-4DD9-A98B-6E1EDED5BFE1} = {FDBFD331-A9EB-42BF-B501-8398A04955A7}
{D9DF805A-DD48-4036-B383-F1BC895C317C} = {5FC1E59C-A8C9-4CD7-9DAB-344E877BE8EC}
{EB2AD65F-BE16-4334-BFBE-719A88D118D7} = {D9DF805A-DD48-4036-B383-F1BC895C317C}
{7AE6E1D4-8621-4FC5-8A1F-448FA70DB257} = {D9DF805A-DD48-4036-B383-F1BC895C317C}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {42D71086-61E6-4D31-B4B8-BFC8CC471428}
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

Represents the **NuGet** versions.

## v5.3.0
- *Enhancement:* Added new code-generation configuration property `ValidationFramework` that supports either `CoreEx` (default) or `FluentValidation` (uses the `CoreEx.FluentValidation` interop wrapping capabilities) to allow entity validation to be performed using either framework. Supports mix-and-matching where required. The `CoreEx.Validation` framework is still leveraged for `IsMandatory` and `ValidatorCode` logic where specified.
- *[Issue 208](https://github.com/Avanade/Beef/issues/208): `ReferenceDataController.GetNamed` now excluded from Swagger output as results in superfluous types/models.
- *[Issue 209](https://github.com/Avanade/Beef/issues/209):* New `PagingAttribute` added to the `Controller` code-gen where `PagingArgs` is selected to output `PagingArgs` parameters to corresponding Swagger output. Requires `PagingOperationFilter` to be added at start up to function.
- *Fixed:* Upgraded `CoreEx`, `DbEx` and `UnitTestEx` to latest packages to include all related fixes.

## v5.2.1
- *Fixed:* Upgraded `DbEx` to `v2.3.4`; this included fix to assembly management/probing that required minor internal change to enable correctly within `SqlServerMigration` and `MySqlMigration`.

Expand Down
2 changes: 1 addition & 1 deletion Common.targets
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>5.2.1</Version>
<Version>5.3.0</Version>
<LangVersion>preview</LangVersion>
<Authors>Avanade</Authors>
<Company>Avanade</Company>
Expand Down
1 change: 1 addition & 0 deletions docs/Entity-CodeGeneration-Config.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ Provides the _Manager-layer_ configuration.
Property | Description
-|-
`managerCleanUp` | Indicates whether a `Cleaner.Cleanup` is performed for the operation parameters within the Manager-layer.<br/>&dagger; This can be overridden within the `Entity`(s) and `Operation`(s).
`validationFramework` | The `Validation` framework to use for the entity-based validation. Valid options are: `CoreEx`, `FluentValidation`.<br/>&dagger; Defaults to `CoreEx` (literal). This can be overridden within the `Entity`(s), `Operation`(s) and `Parameter`(s).

<br/>

Expand Down
1 change: 1 addition & 0 deletions docs/Entity-Entity-Config.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ Property | Description
**`validator`** | The name of the .NET implementing `Type` or interface `Type` that will perform the validation.<br/>&dagger; Only used for defaulting the `Create` and `Update` operation types (`Operation.Type`) where not specified explicitly.
`identifierGenerator` | Indicates whether the `IIdentifierGenerator` should be used to generate the `Id` property where the operation types (`Operation.Type`) is `Create`.
`managerCleanUp` | Indicates whether a `Cleaner.Cleanup` is performed for the operation parameters within the Manager-layer.<br/>&dagger; This can be overridden within the `CodeGeneration` and `Operation`(s).
`validationFramework` | The `Validation` framework to use for the entity-based validation. Valid options are: `CoreEx`, `FluentValidation`.<br/>&dagger; Defaults to `CodeGeneration.ValidationFramework`. This can be overridden within the `Operation`(s) and `Parameter`(s).

<br/>

Expand Down
1 change: 1 addition & 0 deletions docs/Entity-Operation-Config.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ Property | Description
**`managerCustom`** | Indicates whether the `Manager` logic is a custom implementation; i.e. no auto-`DataSvc` invocation logic is to be generated.
`managerTransaction` | Indicates whether a `System.TransactionScope` should be created and orchestrated at the `Manager`-layer.
**`validator`** | The name of the .NET implementing `Type` or interface `Type` that will perform the validation.<br/>&dagger; Defaults to the `Entity.Validator` where not specified explicitly (where `Operation.Type` options `Create` or `Update`).
`validationFramework` | The `Validation` framework to use for the entity-based validation. Valid options are: `CoreEx`, `FluentValidation`.<br/>&dagger; Defaults to `Entity.ValidationFramework`. This can be overridden within the `Parameter`(s).
`managerOperationType` | The `ExecutionContext.OperationType` (CRUD denotation) defined at the `Manager`-layer. Valid options are: `Create`, `Read`, `Update`, `Delete`, `Unspecified`.<br/>&dagger; The default will be inferred from the `Operation.Type`; however, where the `Operation.Type` is `Custom` it will default to `Unspecified`.
`managerCleanUp` | Indicates whether a `Cleaner.Cleanup` is performed for the operation parameters within the Manager-layer.<br/>&dagger; This can be overridden within the `CodeGeneration` and `Entity`.

Expand Down
2 changes: 1 addition & 1 deletion docs/Entity-Parameter-Config.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ Provides the _Manager-layer_ configuration.
Property | Description
-|-
**`validator`** | The name of the .NET `Type` that will perform the validation.
`iValidator` | The name of the .NET Interface that the `Validator` implements/inherits.<br/>&dagger; Defaults to `IValidatorEx<{Type}>` where the `{Type}` is `Type`.
`validatorCode` | The fluent-style method-chaining C# validator code to append to `IsMandatory` and `Validator` (where specified).
`validationFramework` | The `Validation` framework to use for the entity-based validation. Valid options are: `CoreEx`, `FluentValidation`.<br/>&dagger; Defaults to `Operation.ValidationFramework`.
`isMandatory` | Indicates whether a `ValidationException` should be thrown when the parameter value has its default value (null, zero, etc).
`layerPassing` | The option that determines the layers in which the parameter is passed. Valid options are: `All`, `ToManagerSet`, `ToManagerCollSet`.<br/>&dagger; Defaults to `All`. To further describe, `All` passes the parameter through all layeys, `ToManagerSet` only passes the parameter to the `Manager` layer and overrides the same named property within the corresponding `value` parameter, `ToManagerCollSet` only passes the parameter to the `Manager` layer and overrides the same named property within the corresponding `value` collection parameter. Where using the `PrimaryKey` option to automatically set `Parameters`, and the `Operation.Type` is `Create` or `Update` it will default to `ToManagerSet`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public AccountController(WebApi webApi, IAccountManager manager)
/// <param name="isOwned">Indicates whether Is Owned.</param>
/// <returns>The <see cref="AccountCollection"/></returns>
[HttpGet("")]
[Paging]
[ProducesResponseType(typeof(Common.Entities.AccountCollection), (int)HttpStatusCode.OK)]
[ProducesResponseType((int)HttpStatusCode.NoContent)]
public Task<IActionResult> GetAccounts([FromQuery(Name="product-category")] string? productCategory = default, [FromQuery(Name="open-status")] string? openStatus = default, [FromQuery(Name="is-owned")] bool? isOwned = default)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public Task<IActionResult> TransactionStatusGetAll([FromQuery] IEnumerable<strin
[HttpGet()]
[Route("api/v1/ref")]
[ProducesResponseType(typeof(IEnumerable<CoreEx.RefData.ReferenceDataMultiItem>), (int)HttpStatusCode.OK)]
[ApiExplorerSettings(IgnoreApi = true)]
public Task<IActionResult> GetNamed() => _webApi.GetAsync(Request, p => _orchestrator.GetNamedAsync(p.RequestOptions));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public TransactionController(WebApi webApi, ITransactionManager manager)
/// <param name="text">The Text.</param>
/// <returns>The <see cref="TransactionCollection"/></returns>
[HttpGet("{accountId}/transactions")]
[Paging]
[ProducesResponseType(typeof(Common.Entities.TransactionCollection), (int)HttpStatusCode.OK)]
[ProducesResponseType((int)HttpStatusCode.NoContent)]
public Task<IActionResult> GetTransactions([FromRoute] string? accountId, [FromQuery(Name="oldest-time")] DateTime? fromDate = default, [FromQuery(Name="newest-time")] DateTime? toDate = default, [FromQuery(Name="min-amount")] decimal? minAmount = default, [FromQuery(Name="max-amount")] decimal? maxAmount = default, [FromQuery(Name="text")] string? text = default)
Expand Down
3 changes: 2 additions & 1 deletion samples/Cdr.Banking/Cdr.Banking.Api/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ public void ConfigureServices(IServiceCollection services)
services.AddSwaggerGen(options =>
{
options.SwaggerDoc("v1", new OpenApiInfo { Title = "Cdr.Banking API", Version = "v1" });
options.OperationFilter<CoreEx.WebApis.AcceptsBodyOperationFilter>(); // Needed to support AcceptsBodyAttribue where body parameter not explicitly defined.
options.OperationFilter<AcceptsBodyOperationFilter>(); // Needed to support AcceptsBodyAttribute where body parameter not explicitly defined.
options.OperationFilter<PagingOperationFilter>(); // Needed to support PagingAttribute where PagingArgs parameter not explicitly defined.
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<Folder Include="DataSvc\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="CoreEx.Cosmos" Version="2.6.0" />
<PackageReference Include="CoreEx.Validation" Version="2.6.0" />
<PackageReference Include="CoreEx.Cosmos" Version="2.9.0" />
<PackageReference Include="CoreEx.Validation" Version="2.9.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
<Folder Include="Entities\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="CoreEx" Version="2.6.0" />
<PackageReference Include="CoreEx" Version="2.9.0" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions samples/Cdr.Banking/Cdr.Banking.Test/Cdr.Banking.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="NUnit3TestAdapter" Version="4.3.1">
<PackageReference Include="NUnit3TestAdapter" Version="4.4.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="UnitTestEx.NUnit" Version="2.1.3" />
<PackageReference Include="UnitTestEx.NUnit" Version="2.2.1" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ public Task<IActionResult> Patch(Guid id) =>
/// </summary>
/// <returns>The <see cref="PersonCollection"/></returns>
[HttpGet("all")]
[Paging]
[ProducesResponseType(typeof(Common.Entities.PersonCollection), (int)HttpStatusCode.OK)]
[ProducesResponseType((int)HttpStatusCode.NoContent)]
public Task<IActionResult> GetAll() =>
Expand All @@ -138,6 +139,7 @@ public Task<IActionResult> GetAll2() =>
/// <param name="orderBy">The Order By.</param>
/// <returns>The <see cref="PersonCollection"/></returns>
[HttpGet("")]
[Paging]
[ProducesResponseType(typeof(Common.Entities.PersonCollection), (int)HttpStatusCode.OK)]
[ProducesResponseType((int)HttpStatusCode.NoContent)]
public Task<IActionResult> GetByArgs(string? firstName = default, string? lastName = default, List<string>? genders = default, Common.Entities.OrderBy? orderBy = default)
Expand All @@ -155,6 +157,7 @@ public Task<IActionResult> GetByArgs(string? firstName = default, string? lastNa
/// <param name="orderBy">The Order By.</param>
/// <returns>The <see cref="PersonDetailCollection"/></returns>
[HttpGet("argsdetail")]
[Paging]
[ProducesResponseType(typeof(Common.Entities.PersonDetailCollection), (int)HttpStatusCode.OK)]
[ProducesResponseType((int)HttpStatusCode.NoContent)]
public Task<IActionResult> GetDetailByArgs(string? firstName = default, string? lastName = default, List<string>? genders = default, Common.Entities.OrderBy? orderBy = default)
Expand Down Expand Up @@ -280,6 +283,7 @@ public Task<IActionResult> EventPublishNoSend() =>
/// <param name="orderBy">The Order By.</param>
/// <returns>The <see cref="PersonCollection"/></returns>
[HttpGet("args")]
[Paging]
[ProducesResponseType(typeof(Common.Entities.PersonCollection), (int)HttpStatusCode.OK)]
[ProducesResponseType((int)HttpStatusCode.NoContent)]
public Task<IActionResult> GetByArgsWithEf(string? firstName = default, string? lastName = default, List<string>? genders = default, Common.Entities.OrderBy? orderBy = default)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ public Task<IActionResult> CommunicationTypeGetAll([FromQuery] IEnumerable<strin
[HttpGet()]
[Route("api/v1/demo/ref")]
[ProducesResponseType(typeof(IEnumerable<CoreEx.RefData.ReferenceDataMultiItem>), (int)HttpStatusCode.OK)]
[ApiExplorerSettings(IgnoreApi = true)]
public Task<IActionResult> GetNamed() => _webApi.GetAsync(Request, p => _orchestrator.GetNamedAsync(p.RequestOptions));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public Task<IActionResult> Delete(Guid id) =>
/// <param name="powerSources">The Power Sources (see <see cref="RefDataNamespace.PowerSource"/>).</param>
/// <returns>The <see cref="RobotCollection"/></returns>
[HttpGet("")]
[Paging]
[ProducesResponseType(typeof(Common.Entities.RobotCollection), (int)HttpStatusCode.OK)]
[ProducesResponseType((int)HttpStatusCode.NoContent)]
public Task<IActionResult> GetByArgs([FromQuery(Name="model-no")] string? modelNo = default, [FromQuery(Name="serial-no")] string? serialNo = default, [FromQuery(Name="power-sources")] List<string>? powerSources = default)
Expand Down
8 changes: 6 additions & 2 deletions samples/Demo/Beef.Demo.Api/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using Beef.Demo.Common.Agents;
using CoreEx.Database;
using CoreEx.Events;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
using AzCosmos = Microsoft.Azure.Cosmos;

namespace Beef.Demo.Api
Expand Down Expand Up @@ -41,7 +43,8 @@ public void ConfigureServices(IServiceCollection services)
.AddReferenceDataContentWebApi()
.AddRequestCache()
.AddValidationTextProvider()
.AddValidators<PersonManager>();
.AddValidators<PersonManager>()
.AddFluentValidators<PersonManager>();

// Add the data sources as singletons for dependency injection requirements.
//services.AddBeefDatabaseServices(() => new Database(WebApiStartup.GetConnectionString(_config, "BeefDemo")))
Expand Down Expand Up @@ -131,7 +134,8 @@ public void ConfigureServices(IServiceCollection services)
if (File.Exists(xmlFile))
c.IncludeXmlComments(xmlFile);

c.OperationFilter<AcceptsBodyOperationFilter>(); // Needed to support AcceptsBodyAttribue where body parameter not explicitly defined.
c.OperationFilter<AcceptsBodyOperationFilter>(); // Needed to support AcceptsBodyAttribute where body parameter not explicitly defined.
c.OperationFilter<PagingOperationFilter>(); // Needed to support PagingAttribute where PagingArgs parameter not explicitly defined.
});

//services.AddSwaggerGenNewtonsoftSupport();
Expand Down
15 changes: 8 additions & 7 deletions samples/Demo/Beef.Demo.Business/Beef.Demo.Business.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="CoreEx" Version="2.6.0" />
<PackageReference Include="CoreEx.Cosmos" Version="2.6.0" />
<PackageReference Include="CoreEx.Database" Version="2.6.0" />
<PackageReference Include="CoreEx.Database.SqlServer" Version="2.6.0" />
<PackageReference Include="CoreEx.EntityFrameworkCore" Version="2.6.0" />
<PackageReference Include="CoreEx.Validation" Version="2.6.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.13" />
<PackageReference Include="CoreEx" Version="2.9.0" />
<PackageReference Include="CoreEx.Cosmos" Version="2.9.0" />
<PackageReference Include="CoreEx.Database" Version="2.9.0" />
<PackageReference Include="CoreEx.Database.SqlServer" Version="2.9.0" />
<PackageReference Include="CoreEx.EntityFrameworkCore" Version="2.9.0" />
<PackageReference Include="CoreEx.Validation" Version="2.9.0" />
<PackageReference Include="CoreEx.FluentValidation" Version="2.9.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.16" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit 81e1bf9

Please sign in to comment.