Code Monkey home page Code Monkey logo

arcus.templates's People

Contributors

dependabot[bot] avatar fgheysels avatar mcalewaert avatar pim-simons avatar renovate[bot] avatar roeland54 avatar samvanhoutte avatar snyk-bot avatar stijnmoreels avatar sucrose0413 avatar tomkerkhove avatar vtermaat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

arcus.templates's Issues

406 is returned when Accept header is text/plain

406 is returned when the client send the Accept: text/plain

How to fix this?

  • remove the text plain as supported media type for JsonOutputFormatter?
            var jsonOutputFormatter = options.OutputFormatters.OfType<JsonOutputFormatter>().FirstOrDefault();
            if (jsonOutputFormatter != null)
            {
                if (!jsonOutputFormatter.SupportedMediaTypes.Contains(Text.Plain))
                {
                    jsonOutputFormatter.SupportedMediaTypes.Add(Text.Plain);
                }
            }
  • remove the text plain as supported media type for JsonInputFormatter?
            var jsonInputFormatter = options.InputFormatters.OfType<JsonInputFormatter>().FirstOrDefault();
            if (jsonInputFormatter != null)
            {
                if (jsonInputFormatter.SupportedMediaTypes.Contains(Text.Plain))
                {
                    jsonInputFormatter.SupportedMediaTypes.Remove(Text.Plain);
                }
            }
  • understand why the StringOutputFormatter doesn't kick in.
    StringOutputFormatter is added by default and according to the docs it should take care of text/plain
    If not used / if doesn't kick in, better to remove
            var stringFormatter = options.OutputFormatters.OfType<StringOutputFormatter>().FirstOrDefault();
            if (stringFormatter != null) options.OutputFormatters.RemoveType<StringOutputFormatter>();

Remove MyGet package sources in web API template

To use the correlation functionality, we needed the MyGet package because no next release was made for the Arcus.WebApi library.

When that happens, we should remove the MyGet package source and use the offical NuGet release.

Discussion - Include Marvin.StreamExtensions in template

Marvin.StreamExtensions includes basic functionality to interact with streams which I've found myself implementing myself as well.

Might be interesting to include it rather than building our own.

using (var response = await httpClient.SendAsync(request))
{
    using (var stream = await response.Content.ReadAsStreamAsync())
    {
        var person = stream.ReadAndDeserializeFromJson<Person>();
    }
}

Document what version introduces a specific feature

Is your feature request related to a problem? Please describe.
Document what version introduces a specific feature so that people know what to expect.

Describe the solution you'd like

  • Only publish documentation for new features when a new version is released
  • Provide indication in documentation what version introduces the feature

Describe alternatives you've considered
None

Provide `dotnet new` template for Web API

Provide a custom dotnet new template which configures a Web API with minimal requirements.

The template should be calles arcus-webapi.

Features in the template

  • Plug in exception middleware
  • Configure content negotiation to only support application/json
  • Setup Swagger generation
  • Setup Swagger UI (but disable for PROD env)
  • Configure health checks (middleware only)
  • Provide health endpoint (based on info gained via health checks
    • Fully documented according to our guidelines
  • Provide a working Dockerfile
  • Build a default logger

The template should not provide any authentication by default but should provide a comment that warns about this and point to Arcus WebAPI and Shared Access Key.

Requirements

We should provide a CI that performs following steps:

  1. Create project based on template via dotnet new arcus-webapi
  2. Build a Docker container based on Dockerfile
  3. Run Docker container
  4. Get the health of the container

Good reads

dotnet new arcus-webapi creates new project in current directory

When executing the command

dotnet new arcus-webapi --name api.test

the new project is created directly in the current folder. I think it would be better to create the new project in a (new) subfolder of the current folder. So when executing the above command, a subfolder api.test should be created and the project should be created in that folder.

I think this makes it a bit more user-friendly and it is also in line with the webapi template that is provided by MS.

Provide a release pipeline for NuGet.org

Provide a release pipeline for NuGet.org.

Checklist

  • Build the codebase
  • Run test suite
  • Tag the codebase on success
  • Create a GitHub pre-release for a preview releases
  • Create a GitHub release for full releases
  • Push all NuGet packages to NuGet.org

Provide `dotnet new` template for Worker

Provide a custom dotnet new template which configures a Worker with minimal requirements.

The template should be calles arcus-servicebus-queue and arcus-servicebus-topic.

Features in the template

  • TCP Health Probes
  • Register ICachedSecretProvider as dependency
  • Registration of message pump which is using empty message handler
    • By default, use ISecretProvider for getting connection string
  • Empty message handler

Good reads

Provide integration tests for Swagger (UI)

Provide integration tests for Swagger (UI):

  • Spin up in debug, is able to navigate to Swagger UI
  • Spin up in debug, is able to navigate to Swagger docs
  • Spin up in release, is not able to navigate to Swagger UI
  • Spin up in release, is not able to navigate to Swagger docs

Investigate in a configurable `TemplateProject` fixture

Problem

Example: when we create a TemplateProject, the temp project directory gets deleted but this could contain valuable information on why a test may fail.

Proposal

The disposal of this project could be made configurable.

Swagger UI is not working for generated Web API

Swagger UI is not working for generated Web API.

Repro

  1. dotnet new arcus-webapi -n Arcus.Demo.WebAPI
  2. dotnet run .\Arcus.Demo.WebAPI.csproj

Error

Could not find file 'C:\Temp\bin\Debug\netcoreapp2.2\Arcus.Template.WebApi.Open-Api.xml'.

Analysis

The reason for this is that the file in <DocumentationFile> in Arcus.Demo.WebAPI.csproj is replaced successfully but not when calling AddSwaggerGen (title+path) in Startup.cs.

Document correlation headers in OpenAPI specs, when applicable

Is your feature request related to a problem? Please describe.
Document correlation headers in OpenAPI specs, when applicable

Describe the solution you'd like
Use Swashbuckle.AspNetCore.Filters.

We need to:

  • Configure it in AddSwaggerGen via AddHeaderOperationFilter & AddResponseHeadersFilter (see docs)
  • Annotate our health endpoint with SwaggerResponseHeader (see docs)

Describe alternatives you've considered
None

Additional context
This should only happen when exclude-correlation & exclude-openApi are false

Feature - add web API project option for JWT role-based authentication

What feature would you like to have?
In any app, there may come a time where you want to limit access for diff authenticated users.. Right now, we allow all features of any API by a single shared access key or configured certificate.
I think it would be useful to add also a JWT authentication system with roles for authorization for a more fine-grained control?

Alternatives you may have considered?
We could also add the possibility to use different kinds of shared access keys/certificates for different levels of access in the API. Maybe also with roles.

Configure CI build

Configure a CI build that will build & test the changes made in every PR

Show template version when using the `--help` argument

Is your feature request related to a problem? Please describe.
We should provide information about the installed version.

Describe the solution you'd like
Show template version when using the --help argument.

Describe alternatives you've considered
None.

Enhance our integration tests in builds

Enhance our integration tests in builds so that we have one stage which has 2 jobs:

  1. To run the test category for all tests that require the generated image to run as a Docker container
  2. To run the test category for integration tests that requires no infrastructure

Projects created with dotnet new webapi are missing a Docker run profile

When I create a new Arcus webapi project using the dotnet new arcus-webapi command, a new api project is created as expected.

However, since the Api project supports Docker (a dockerfile is created), I would also expect that there's a profile available which allows me to run/test my API from Visual Studio using Docker.

When I create a new Arcus WebApi project, following profiles are available:

image

When I create a new Web Api project via Visual Studio and I enable Docker support these profiles are available:

image

It would be nice if the Docker profile is also available when creating a new project using the arcus-webapi template and that this Docker profile is the default profile.

Align Serilog logging approach with `Arcus.Messaging` approach

What feature do you like?
Currently, we set up the logging in the startup (Program.cs) of the template. We should make this startup-logger minimal and add another logging configuration later in the Startup/ConfigureServices so we can make use of the !ServiceProvider and IConfiguration for more a advanced logging configuration.

Testing - Project option test cases

Now, in the integration tests we test the simple possible way of creating a project from the template (without any options).

It would be reasonable if the integration tests consists of several test cases that each creates a new project with one or more options specified and then takes some actions on that new created project to see if the selected options reflect in a changed behavior.

Ex.: when choosing for a authentication mechanism, testing if we indeed have to configure the correct authentication.

Change enumeration serialization to use string instead of integers

We should change our enumeration serialization to use string instead of integers to make it more user friendly.

Expected Outcome

{"entries":{},"status":"Healthy","totalDuration":"00:00:00.0000023"}

Current Outcome

{"entries":{},"status":2,"totalDuration":"00:00:00.0000023"}

Provide build error for shared access key generation instead of warnings

As of today we log warnings when we generate a project with Shared Access Key auth here:

Given the current state of the API is not valid and should not be released, we should switch this so that it gives build errors rather than warnings so that it's clear to users that they have to change something before they can ship their new API.

What do you think @stijnmoreels ?

Document generated security mechanism in OpenAPI

Is your feature request related to a problem? Please describe.
Document generated security mechanism in OpenAPI when applicable.

Describe the solution you'd like
AddSecurityDefinition should be used when configuring OpenAPI docs for API key authentication.

https://github.com/domaindrivendev/Swashbuckle.AspNetCore#add-security-definitions-and-requirements

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Provide a README

Provide a README that clearly states what the project does.

Checklist

  • What the focus of the project is

  • What features it has

  • How to install it

Provide a release pipeline for MyGet.org

Provide a release pipeline for MyGet.org.

Checklist

  • Configure to run for every PR

  • Use 'Determine NuGet Package Version' task group to determin package version

  • Build the codebase

  • Run test suite

  • Push all NuGet packages to MyGet.org

Define branch policies

Define branch policies on the master branch.

It should:

  • Build every PR with our CI

  • Be approved by 1 person

Add Console Serilog sink

What feature would you like?
Currently, we only write log messages to Application Insights but it could be useful if we write to the console as well during Debug.

Especially during development is this a big plus.

Naming - 'Templates' <> 'Template'

Maybe we should have the same naming across the GitHub repo and the source code.
Doesn't matter to me what; but maybe fix this before releasing.

Configure Netlify for creating preview documentation

Configure Netlify for creating previews of documentation changes.

This allows us to more easily review documentation changes as a reviewer and also lowers the barrier to make documentation changes.

Checklist

  • Create new Netlify site

  • Add Netlify configuration

  • Enforce checks on branches

Documentation bug: configuration flags for new Arcus WebApi Template

Hello all,

I have run this on mac, though doubt that this would be relevant information.
Execution steps to create a new WebApi project:

dotnet new arcus-webapi --name ReproApi - au SharedAccessKey -ia true -lo Serilog

But executing this fails with the following exception, so I think there's a mismatch between the actual code / logic and the docs.

Invalid input switch:
  -au
  SharedAccessKey
  -ia
  true
  -lo
  Serilog
Arcus WebAPI (C#)
Author: Arcus
Options:                                                                                                                
  -A|--Authentication  Choose whether to use an authentication mechanism and which authentication to use                
                           SharedAccessKey    - Adds a shared access key authentication mechanism to the web API project
                           None               - No authentication mechanism is added to the web API project             
                       Default: None   

This is the documentation page:

-au|--authentication (default None)
SharedAccessKey: adds shared access key authentication mechanism to the API project
Certificate: adds client certificate authentication mechanism to the API project
JWT: adds JWT (JSON Web Token) authentication mechanism to the API project
None: no authentication configured on the API project.
-ia|--include-appsettings (default false): includes a appsettings.json file to the web API project.
-ec|--exclude-correlation (default false): excludes the capability to correlate between HTTP requests/responses from the API project.
-eo|--exclude-openApi (default false): exclude the ASP.NET OpenAPI docs generation and UI from API project.
-lo|--logging (default Console)
Console: no extra logging mechanism except for the default console logging will be added to the web API project.
Serilog: adds Serilog as logging mechanism with request logging to the web API project.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.