Releases: pdevito3/craftsman
Releases · pdevito3/craftsman
v0.8.2
v0.8.1
v0.8.0
Release Notes
🚀 Additions and Updates
- New
add:micro
command that scaffolds a new microservice template as well as an ocelot gateway - New
port
property on thenew:api
template to let you customize and api or microservice port on localhost - Added
https
default on local - Added additional startup middleware
UseHsts
for non dev environmentsUseHttpsRedirection
with notes on even more secure options
- New
AuthorizationSettings
object and authorization based properties on the environments for thenew:api
andnew:micro
commands - Added new
GetEntity
andDeleteEntity
integration tests with and without auth - Added 401/403 response types to swagger comments when using auth
- Added auth to swagger setup
- note that secret is currently stored in appsettings
- Auth added to integration tests when required
🐛 Pest Control
- The
CurrentStartIndex
calculation in thePagedList
class was broken and now has a new calculation. - Added null conditional operator (
?.
) to certain tests before.Data
to make them fail more gracefully- Get{entity.Plural}_ReturnsSuccessCodeAndResourceWithAccurateFields()
- Put{entity.Name}ReturnsBodyAndFieldsWereSuccessfullyUpdated
- Cleaned up
WebApplicationFactory
to remove deprecated services. - Removed
[Collection(""Sequential"")]
from repo tests
v0.7.0
Release Notes
🚀 Additions and Updates
- Removed the dependency on the foundation api template!
🐛 Pest Control
- Fixed
UseEnvironment
in WebAppFactory to useDevelopment
- Fixed integration tests to use the new
Response
wrapper - Updated pagination tests to have proper keys due to default sort order possibly breaking these tests
v0.6.1
v0.6.0
Release Notes
This release requires an update of your foundation template to v0.4.0 You can upgrade by running this command:
dotnet new Foundation.Api --update-apply
🚀 Additions and Updates
- Added table name and schema properties to entity
- Added column name attribute to entity properties
- Added Serilog by default in all new projects. This includes Console and Seq logging by default in
Development
. For non-Development environments, you'll need to add whatever logging you're interested in to their respective app-settings projects. There are just too many options to create a whole API on top of Serilog. for upgrade instructions see below. - Updated swagger implementation from nswag. for upgrade instructions see below.
- Added Consumes and Produces headers to the controller endpoints
- Added an option to manage additional swagger settings to your API endpoints. This will be turned off by default for now as dealing the with xml docs path is potentially burdensome, but will add a lot of valuable details for users consuming your API. If you are looking to add additional XML details, this is highly recommended.
- Added a custom Response Wrapper to the GET and POST endpoints
🐛 Pest Control
- Fixed launch settings to have null environment variable for Startup (Production). If you'd like to change this, be sure to update the appsetting lookup in
Program.cs
- Fixed POST endpoint that was lacking a
[FromBody]
marker BasePaginationParameters
will now haveMaxPageSize
andDefaultPageSize
set asinternal
properties so they don't show up in swagger. These can be overridden in the distinct entity classes like so:internal override int MaxPageSize { get; } = 30;
- Fixed controllers to be able to handle a name and plural with the same value (e.g. Buffalo)
Upgrade Walkthrough
NSwag Migration
-
Add the below packages to your webapi project and remove the
Nswag
package:<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="5.0.1" /> <PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
-
In Webapi
ServiceExtensions
replaceusing NSwag
withusing Microsoft.OpenApi.Models;
and update the swagger region to something like the below with the appropriate info for your project:#region Swagger Region - Do Not Delete public static void AddSwaggerExtension(this IServiceCollection services) { services.AddSwaggerGen(config => { config.SwaggerDoc( "v1", new OpenApiInfo { Version = "v1", Title = "", Description = "", Contact = new OpenApiContact { Name = "", Email = "", Url = new Uri(""), }, }); }); } #endregion
-
In Webapi
AppExtensions
, update the swagger region to the below:#region Swagger Region - Do Not Delete public static void UseSwaggerExtension(this IApplicationBuilder app) { app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", ""); }); } #endregion
-
Adding Serilog
-
If you have an existing project and want to add this to your project, you'll need do this manually :
-
Add the following packages to webapi:
-
Update your
Program
to the following:
namespace WebApi { using Autofac.Extensions.DependencyInjection; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; using Serilog; using System; using System.IO; using System.Reflection; public class Program { public static void Main(string[] args) { var myEnv = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"); var appSettings = myEnv == null ? $"appsettings.json" : $"appsettings.{myEnv}.json"; //Read Configuration from appSettings var config = new ConfigurationBuilder() .AddJsonFile(appSettings) .Build(); //Initialize Logger Log.Logger = new LoggerConfiguration() .ReadFrom.Configuration(config) .CreateLogger(); try { Log.Information("Starting application"); CreateHostBuilder(args) .Build() .Run(); } catch (Exception e) { Log.Error(e, "The application failed to start correctly"); throw; } finally { Log.Information("Shutting down application"); Log.CloseAndFlush(); } } public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .UseSerilog() .UseServiceProviderFactory(new AutofacServiceProviderFactory()) .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup(typeof(Startup).GetTypeInfo().Assembly.FullName) .UseContentRoot(Directory.GetCurrentDirectory()) .UseKestrel(); }); } }
- Update your
appsettings.Development
to:
{ "AllowedHosts": "*", "UseInMemoryDatabase": true, "Serilog": { "Using": [], "MinimumLevel": { "Default": "Information", "Override": { "Microsoft": "Warning", "System": "Warning" } }, "Enrich": [ "FromLogContext", "WithMachineName", "WithProcessId", "WithThreadId" ], "WriteTo": [ { "Name": "Console" }, { "Name": "Seq", "Args": { "serverUrl": "http://localhost:5341" } } ] }, }
-
v0.5.0
v0.4.2
v0.4.1
v0.4.0
Release Notes
🚀 Additions and Updates
- Default
Startup.cs
class can now be configured using the reservedStartup
keyword
🐛 Pest Control
- Fixed
craftsman add:property -h
help text - The appsettings connection string will now escape backslash
- Foreign key using statement will now be dynamic on DTOs