Skip to content

Allow custom Dtos for endpoints #75

@renamed

Description

@renamed

Suppose I have this class

`
public class Food : Record
{

    public string Name { get; set; }
    public decimal Portion { get; set; }
    public decimal Calories { get; set; }
    public decimal Carbohydrates { get; set; }
    public decimal Lipids { get; set; }
    public decimal Proteins { get; set; }
    public decimal Fiber { get; set; }
    
    public Guid SourceId { get; set; }
    public Source Source { get; set; }

    public Classification Classification { get; set; }
    public NewClassification NewClassification { get; set; }

    public ICollection<FoodRecipes> FoodRecipes { get; set; }

}
`

When using InstantAPIs, the following swagger body model is created

{ "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "registration": "2023-09-04T02:26:10.760Z", "update": "2023-09-04T02:26:10.760Z", "deletion": "2023-09-04T02:26:10.760Z", "name": "string", "portion": 0, "calories": 0, "carbohydrates": 0, "lipids": 0, "proteins": 0, "fiber": 0, "sourceId": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "source": { "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "registration": "2023-09-04T02:26:10.760Z", "update": "2023-09-04T02:26:10.760Z", "deletion": "2023-09-04T02:26:10.760Z", "name": "string" }, "classification": 0, "newClassification": 0, "foodRecipes": [ { "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "registration": "2023-09-04T02:26:10.760Z", "update": "2023-09-04T02:26:10.760Z", "deletion": "2023-09-04T02:26:10.760Z", "recipeId": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "recipe": { "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "registration": "2023-09-04T02:26:10.760Z", "update": "2023-09-04T02:26:10.760Z", "deletion": "2023-09-04T02:26:10.760Z", "name": "string", "foodRecipes": [ "string" ] }, "foodId": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "food": "string" } ] }

I wish there would be a way to provide custom DTOs and maybe using AutoMapper to transforming to entity class, like

app.MapInstantAPIs<EuNutroContext>(config => { config.ExcludeTable(db => db.AnyTable); config.UseCustomDto(db => db.Food, typeof(AddFoodDto), ApiMethodsToGenerate.Insert); // like this });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions