Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ignatandrei/skinnycontrollersgenerator
https://github.com/ignatandrei/skinnycontrollersgenerator
controller csharp netcore skinny skinny-controllers
Last synced: 5 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/ignatandrei/skinnycontrollersgenerator
- Owner: ignatandrei
- License: mit
- Created: 2023-05-14T06:04:27.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-05-19T19:42:10.000Z (over 1 year ago)
- Last Synced: 2024-05-22T04:33:40.034Z (7 months ago)
- Topics: controller, csharp, netcore, skinny, skinny-controllers
- Language: C#
- Homepage: https://www.nuget.org/packages/SkinnyControllersGenerator
- Size: 50.8 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SkinnyControllersGenerator
SkinnyControllers generates controller action for each field of your controller
How to install SkinnyControllers in a .NET Core 5 WebAPI / MVC application
Step 1:Install https://www.nuget.org/packages/SkinnyControllersGenerator/
Step 2:
Install https://www.nuget.org/packages/SkinnyControllersCommon/
Step 3:
Add a field to your action either via DI, either directly
[ApiController]
[Route("[controller]/[action]")]
public partial class WeatherForecastController : ControllerBase
{private readonly RepositoryWF repository;
public WeatherForecastController(RepositoryWF repository)
{
this.repository = repository;
//or make
//this.repository=new RepositoryWF();
}
Step 4:
Add partial declaration and decorate your controller with
[AutoActions(template = TemplateIndicator.AllPost,FieldsName =new[] { "*" }, ExcludeFields =new[]{"_logger"})]
[ApiController]
[Route("[controller]/[action]")]
public partial class WeatherForecastController : ControllerBaseYou can choose your template from
1. All Post
2. Get - if not arguments, POST else
3. Rest actionYou can add your template in 2 ways:
//if custom template , hte name must end in controller.txt
1. [AutoActions(template = TemplateIndicator.CustomTemplateFile, FieldsName = new[] { "*" } ,CustomTemplateFileName = "Controllers\\CustomTemplate1.controller.txt")]2. For creating new generic templates, please PR to https://github.com/ignatandrei/SkinnyControllersGenerator
That's all!
Usual problems:
1. error CS0260: Missing partial modifier on declaration of type
Answer:
Did you put partial on the controller declaration ?
public partial class
# More Roslyn Source Code Generators
You can find more RSCG with examples at [Roslyn Source Code Generators](https://ignatandrei.github.io/RSCG_Examples/v2/)