Zaid-Ajaj / Hawaii

dotnet CLI tool to generate type-safe F# and Fable clients from OpenAPI/Swagger or OData services
MIT License
140 stars 15 forks source link

feature request: create methods with optional parameters #18

Closed travis-leith closed 3 years ago

travis-leith commented 3 years ago

Instead of

type MyType =
    {
        A:int option
        B:int option
    }
    static member Create () : MyType =
        { A = None; B = None}

How about

static member Create(?a: int, ?b:int) = {A = a; B = b}

That way I can create with only the values that I need, very easily.

Zaid-Ajaj commented 3 years ago

Hi @travis-leith, I can probably add that as a configuration option but I don't get why the the current approach doesn't work for you.

You can easily create the type and apply the values in one go

let value = { MyType.Create() with A = Some 42; B = Some 21 }
travis-leith commented 3 years ago

I suppose the only benefit is slightly more compact code. Thinking about it again, not even sure why I discounted the current approach in the first place :confused: Perhaps consider this a low priority or, feel free to close this issue with no hurt feelings on my side :relaxed:

Zaid-Ajaj commented 3 years ago

I would like to keep configuration options to a minimum and not overcomplicate the codebase so if the current approach is not problematic or annoying, we keep it for the time being 😄

I'll close this issue for now, if there is anything else that I can help with, just let me know