An open API service indexing awesome lists of open source software.

https://github.com/ignatandrei/appsettingseditor

app settings editor - powered by Roslyn
https://github.com/ignatandrei/appsettingseditor

appsettings appsettings-json appsettingsjson asp-net-core aspnet-core aspnetcore code-generation code-generator code-generators csharp csharp-sourcegenerator dotnet dotnet-core dotnetcore generator roslyn

Last synced: 6 months ago
JSON representation

app settings editor - powered by Roslyn

Awesome Lists containing this project

README

          

# appSettingsEditor
app settings editor - powered by Roslyn

## What it does

Autogenerates controller API for appsettings.json

Optional, it has also an endpoint for a HTML GUI editor

This is how swagger looks :

And you can browse to /settingsUI to have this editor ( powered by https://github.com/json-editor/json-editor )


## How to use

Add 2 NUGET references:

appSettingEditorAPI
appSettingsEditor

For your convenience, please add to the csproj :


```xml





PreserveNewest

true
$(BaseIntermediateOutputPath)Generated

```

If you want to see a GUI for settings ( /settingsUI) , please do

```csharp
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers(); // add next line
endpoints.MapSettingsView (Configuration);
});
```

If you want to handle security, add

```csharp
public partial class appsettingsController : ControllerBase
{
//partial void BeforeGet(appsettings data)
//{

//}
//partial void BeforeSave(appsettings data, appsettings original)
//{

//}

}
```

## Known problems and solving

### I have a versioning API .

Add this to Startup.cs ,
```csharp
public void ConfigureServices(IServiceCollection services)
services.AddApiVersioning(
it =>
{
it.AssumeDefaultVersionWhenUnspecified = true;
it.DefaultApiVersion = new ApiVersion(1,0);
}
);
```

### I have another file name app_custom_settings.json, not appsettings.json

Make the modifications below:
In the csproj
```xml





PreserveNewest



true
$(BaseIntermediateOutputPath)Generated

```

In the startup.cs
```csharp
appSettingsEditor.Extensions.MapSettingsView(endpoints, Configuration,"app_custom_setting.json","/api/app_custom_setting");
```

### I have multiple appsettings.json

This is not supported yet for the GUI. Please make an issue and describe your problem