Skip to content

Releases: pdevito3/craftsman

v0.8.2

26 Feb 04:08
Compare
Choose a tag to compare

Release Notes

🐛 Pest Control

  • Fixed issue where xml comments would throw an error on non windows machines (#16)

v0.8.1

23 Feb 03:02
Compare
Choose a tag to compare

Release Notes

🐛 Pest Control

  • fixed bug when creating an api with auth settings

v0.8.0

23 Feb 02:24
Compare
Choose a tag to compare

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 the new: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 environments
    • UseHttpsRedirection with notes on even more secure options
  • New AuthorizationSettings object and authorization based properties on the environments for the new:api and new:micro commands
  • Added new GetEntity and DeleteEntity 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 the PagedList 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

12 Jan 05:09
Compare
Choose a tag to compare

Release Notes

🚀 Additions and Updates

  • Removed the dependency on the foundation api template!

🐛 Pest Control

  • Fixed UseEnvironment in WebAppFactory to use Development
  • 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

07 Jan 04:44
Compare
Choose a tag to compare

Release Notes

🐛 Pest Control

  • XML comment info is now properly added to WebApi.csproj and the Swagger config
  • Extra line will no longer be added when no swagger contact url is provided
  • Repository now sets default sort order for proper sql compatibility in lists (issue #9)

v0.6.0

22 Dec 23:38
Compare
Choose a tag to compare

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 have MaxPageSize and DefaultPageSize set as internal 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 replace using NSwag with using 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

14 Dec 22:28
Compare
Choose a tag to compare

Release Notes

🚀 Additions and Updates

  • Added add:entities alias for the add:entity command
  • Can now add Guid or other non-integer primary key

🐛 Pest Control

  • Fixed bug where postgres library was getting added every time

v0.4.2

11 Dec 03:58
Compare
Choose a tag to compare

Release Notes

🐛 Pest Control

  • Seeder was not getting added to StartupDevelopment when using add:entity command

v0.4.1

10 Dec 12:44
Compare
Choose a tag to compare

Release Notes

🐛 Pest Control

  • Async method in controller POST wasn't awaited

v0.4.0

06 Dec 20:44
Compare
Choose a tag to compare

Release Notes

🚀 Additions and Updates

  • Default Startup.cs class can now be configured using the reserved Startup 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