All Projects → ignatandrei → WebAPI2CLI

ignatandrei / WebAPI2CLI

Licence: MIT license
Execute ASP.NET Core WebAPI from Command Line

Programming Languages

C#
18002 projects
powershell
5483 projects
Batchfile
5799 projects

Projects that are alternatives of or similar to WebAPI2CLI

jQuery-datatable-server-side-net-core
A simple Visual Studio solution using jQuery DataTable with Server-Side processing using .NET 5
Stars: ✭ 71 (+153.57%)
Mutual labels:  visual-studio, asp-net-core
Professionalcsharp7
Code samples for the book Professional C# 7 and .NET Core 2.0 (with updates for 2.1), Wrox Press
Stars: ✭ 403 (+1339.29%)
Mutual labels:  visual-studio, asp-net-core
CleanArchitectureDemo
This is a demo project built on .NET Core 3.1 Clean Architecture. Please refer the articles mentioned in the readme to learn more.
Stars: ✭ 33 (+17.86%)
Mutual labels:  visual-studio, asp-net-core
Raypi
一个基于.NET Core 3.1的DDD(领域驱动)的极简风WebApi开发框架。
Stars: ✭ 138 (+392.86%)
Mutual labels:  asp-net-core, webapi
MinimalApi
ASP.NET Core 7.0 - Minimal API Example - Todo API implementation using ASP.NET Core Minimal API, Entity Framework Core, Token authentication, Versioning, Unit Testing, Integration Testing and Open API.
Stars: ✭ 156 (+457.14%)
Mutual labels:  asp-net-core, webapi
Grapefruit.vucore
A front-background project using ASP.NET Core WebApi and Vue.js
Stars: ✭ 210 (+650%)
Mutual labels:  asp-net-core, webapi
AspNet-Core-REST-Service
VS2017/VS2019 project template for ASP.Net Core 3.1/5.0 to create fully functional production ready RESTful services
Stars: ✭ 57 (+103.57%)
Mutual labels:  visual-studio, asp-net-core
AspNet5GeoElasticsearch
ASP.NET Core MVC Geo Elasticsearch Swashbuckle Swagger
Stars: ✭ 38 (+35.71%)
Mutual labels:  asp-net-core, webapi
Opentouryo
”Open棟梁”は、長年の.NETアプリケーション開発実績にて蓄積したノウハウに基づき開発した.NET用アプリケーション フレームワークです。 (”OpenTouryo” , is an application framework for .NET which was developed using the accumulated know-how with a long track record in .NET application development.)
Stars: ✭ 233 (+732.14%)
Mutual labels:  visual-studio, webapi
Angularspawebapi
Angular Single Page Application with an ASP.NET Core Web API that uses token authentication
Stars: ✭ 222 (+692.86%)
Mutual labels:  visual-studio, webapi
User.api
集成网关、身份认证、Token授权、微服务、.netcore等的基于CQRS的微服务开发框架示例
Stars: ✭ 109 (+289.29%)
Mutual labels:  asp-net-core, webapi
ByteScout-SDK-SourceCode
ALL source code samples for ByteScout SDKs and Web API API products.
Stars: ✭ 24 (-14.29%)
Mutual labels:  visual-studio, webapi
Cleanarchitecture.webapi
An implementation of Clean Architecture for ASP.NET Core 3.1 WebAPI. Built with loosely coupled architecture and clean-code practices in mind.
Stars: ✭ 615 (+2096.43%)
Mutual labels:  asp-net-core, webapi
ASPCore.Two-Factor-Authentication
Perform two factor authentication in an ASP.NET core application using Google Authenticator app
Stars: ✭ 29 (+3.57%)
Mutual labels:  visual-studio, asp-net-core
Aspnetcore Webapi Sample
This is a sample ASP.NET Core WebAPI
Stars: ✭ 310 (+1007.14%)
Mutual labels:  asp-net-core, webapi
RDO.Net
Relational Data Objects for .Net
Stars: ✭ 23 (-17.86%)
Mutual labels:  visual-studio, asp-net-core
WebApiJwt
Asp.NET Core 2.0 WebApi JWT Authentication with Identity & MySQL
Stars: ✭ 118 (+321.43%)
Mutual labels:  asp-net-core, webapi
AngularCLI-ASPNET-Core-CustomersService
Example of integrating Angular with ASP.NET Core RESTful Services
Stars: ✭ 61 (+117.86%)
Mutual labels:  asp-net-core, webapi
Equinoxproject
Full ASP.NET Core 5 application with DDD, CQRS and Event Sourcing concepts
Stars: ✭ 5,120 (+18185.71%)
Mutual labels:  visual-studio, asp-net-core
CleanArchitecture
Clean Architecture Solution for .NET 5
Stars: ✭ 18 (-35.71%)
Mutual labels:  asp-net-core, webapi

WebAPI2CLI

Execute ASP.NET Core WebAPI from Command Line . Source at https://github.com/ignatandrei/WebAPI2CLI

GitHub license NuGet MyGet Build Status Azure DevOps tests (branch) Azure DevOps coverage (branch) generateDocs

Why

What if, instead of running the WebAPI ( or just the site ) and waiting for commands from the user, you want also to execute from the command line some controllers actions ?

This project let's you do that by enabling the command line with

< myexe >.exe --CLI_ENABLED=1 --CLI_Commands=" ... "

The command names are in a cli.txt file that can be generated with

< myexe >.exe --CLI_ENABLED=1 --CLI_HELP=1

How to use ( for .NET Core 3.1 )

Step 0 : install into your ASP.NET Core Web

Install the package https://www.nuget.org/packages/ExtensionNetCore3

Modify your ASP.NET Core as below:

public void ConfigureServices(IServiceCollection services)
{
    services.AddCLI();
//your code omitted
}    
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
    app.UseCLI();
//your code omitted
}       

And that is all modifications that you need to do for the source code.

Step 1 - find and save the definition of the commands, i.e. WebAPI endpoints

First, you must generate the definition of the commands. For this, we take the OPEN API (swagger ) approach.

For this, after you compile the project, you will run your .exe program with arguments:

< myexe >.exe --CLI_ENABLED=1 --CLI_HELP=1

( or make this from Visual Studio, Project, Properties, Debug )

This will generate a cli.txt file with all definitions of the WebAPI. ( if your API does not appear, check if you have ApiController defined)

Open your cli.txt file and modify the names of the commands as you wish (also , the arguments )

Copy this cli.txt in your solution and be sure that is copied with the exe ( in Visual Studio right click the file, properties, Build Action = Content, CopyToOutputDirectory = Copy if newer)

Step 2 - run the commands

Ensure that the file is near your exe WebAPI.

Run the exe with the following:

< myexe >.exe --CLI_ENABLED=1 --CLI_Commands="your first command,your second command, and enumerate all commands"

The program will run the commands and output the result.

Optional Step 3 - letting others download the app to use as CLI

Modify the endpoints to add zip

 app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();

                endpoints.MakeZip(app);
            });

and browser to /zip to download the whole application. More details here( including a demo)

https://ignatandrei.github.io/WebAPI2CLI/

Environment Variables: see https://github.com/ignatandrei/Interpreter

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].