jeanluc162
jeanluc162

Reputation: 493

ASP.NET Core: generating new endpoints at runtime

I'm looking for a solution to generate new API endpoints at runtime using ASP.NET Core 8. I'm open to generating controllers classes on the fly, using Minimal API or whatever other solution there is available.

I've also already looked into ApiFramework, but their documentation seems to very minimal and the .NET version referenced in there is 3.1.

My use case is as follows: I have a databases with two tables

At any time, an additional EntityType with the corresponding fields may be added. Let's say I add an entity type Car with two fields Mileage and Door count. I'd need to add an endpoint /cars that outputs data like this:

[
    {
         "Mileage": "xxx",
         "Door count": "xxx"
    }
]

I know how to generate a Type for this dynamically and how to fill out its values from the database, all that's left is providing a strongly typed endpoint, an I am at a loss on how to do this.

Upvotes: 0

Views: 82

Answers (0)

Related Questions