Tagada.Swagger 1.3.1

.NET Core 2.0
dotnet add package Tagada.Swagger --version 1.3.1
NuGet\Install-Package Tagada.Swagger -Version 1.3.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Tagada.Swagger" Version="1.3.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Tagada.Swagger --version 1.3.1
#r "nuget: Tagada.Swagger, 1.3.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Tagada.Swagger as a Cake Addin
#addin nuget:?package=Tagada.Swagger&version=1.3.1

// Install Tagada.Swagger as a Cake Tool
#tool nuget:?package=Tagada.Swagger&version=1.3.1

Tagada

For those who dream to make an ASP.NET Core Web API in one line of code

Get started

A simple Hello World

public void ConfigureServices(IServiceCollection services)
{
    services.AddRouting();
}

public void Configure(IApplicationBuilder app)
{
    app.Map("/api")
        .Get("/hello", () => "Hello world!")
        .Use();
}

Add Swagger documentation

public void ConfigureServices(IServiceCollection services)
{
    services.AddRouting();

    services.AddSwaggerGen(c =>
    {
        c.GenerateTagadaSwaggerDoc();
    });
}

public void Configure(IApplicationBuilder app)
{
    app.Map("/api")
        .Get("/hello", () => "Hello world!")
        .AddSwagger()
        .Use();
}

CQRS-ready

public void ConfigureServices(IServiceCollection services)
{
    services.AddRouting();
}

public void Configure(IApplicationBuilder app)
{
    app.Map("/api")
        .Get("/contacts", GetContacts)
        .Get("/contacts/{id}", GetContactById)
        .Post("/contacts", CreateContact)
        .Use();
}
public class GetContactsQuery { }

public class GetContactByIdQuery
{
    public int Id { get; set; }
}

public class CreateContactCommand
{
    public string Name { get; set; }
}

Storing Commands in a single line of code

public void ConfigureServices(IServiceCollection services)
{
    services.AddRouting();
}

public void Configure(IApplicationBuilder app)
{
    app.Map("/api")
        .Get("/contacts", GetContacts)
        .Get("/contacts/{id}", GetContactById)
        .Post("/contacts", CreateContact)
        .AfterEach(routeResult => QueriesOrCommands.Add(routeResult.Input))
        .Use();
}

Writing queries

  • Return result without parameters
.Get("/hello", () => "Hello world!")
  • Return result from query (extracted from parameters)
.Get("/add/{number1}/{number2}", (AddNumbersQuery query) => query.Number1 + query.Number2)
  • Return result from query with a function
.Get("/contacts", GetContacts)
public static Func<GetContactsQuery, IEnumerable<Contact>> GetContacts = _ => Contacts;

Writing commands

  • Command without result
.Post<Command>("/command", Dispatch)
public static void Dispatch(Command command)
{
    Commands.Add(command);
}
  • Command with a result
.Post("/contacts", CreateContact)
public static Func<CreateContactCommand, Contact> CreateContact = command =>
{
    var newContact = new Contact
    {
        Id = Contacts.Count + 1,
        FirstName = command.FirstName,
        LastName = command.LastName
    };

    Contacts.Add(newContact);

    return newContact;
};
Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.3.1 1,370 5/20/2019
1.3.0 1,225 5/19/2019
1.2.1 1,358 12/26/2018
1.2.0 1,335 11/25/2018
1.1.0 1,373 11/25/2018
1.0.0 1,399 9/25/2018
0.2.0-alpha 863 1/4/2018
0.1.0-alpha 785 12/21/2017