Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom Dtos for endpoints #75

Open
renamed opened this issue Sep 4, 2023 · 0 comments
Open

Allow custom Dtos for endpoints #75

renamed opened this issue Sep 4, 2023 · 0 comments

Comments

@renamed
Copy link

renamed commented Sep 4, 2023

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 });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant