Zaid-Ajaj / Fable.Remoting

Type-safe communication layer (RPC-style) for F# featuring Fable and .NET Apps
https://zaid-ajaj.github.io/Fable.Remoting/
MIT License
272 stars 54 forks source link

Adding documentation for functions with multiple parameters? #241

Open Numpsy opened 3 years ago

Numpsy commented 3 years ago

Hi,

Say that I have this example from the documentation:

type IMusicStore = {
    createAlbum : string -> string -> DateTime -> Async<Option<Album>>
}

I tried plugging in documentation entries for that, and got:

image

Should that work, or am I doing something silly?

Thanks

Zaid-Ajaj commented 3 years ago

Not sure why it won't compile 🤔 I'll check it out. generally if you have many args, using a record as input with named fields will be much better since you can see what is what more clearly

Numpsy commented 3 years ago

Yes, I have that approach working seperately (with a pattern of TRequest -> Async), I just wasn't sure if this approach was supposed to work or not

Thanks

Zaid-Ajaj commented 3 years ago

Hi @Numpsy is this issue still valid? can you please give it another go with latest packages?

Numpsy commented 3 years ago

I'll give it a try later.

Numpsy commented 3 years ago

Hi, It still looks the same to me using Fable.Remoting.AspNetCore 2.22.0 (this is using the AspNetCore bits directly, so no Giraffe etc, for the record.)

vKito commented 2 years ago

I'm also experiencing this issue. I also can't see any examples in the documentation UI.

Zaid-Ajaj commented 2 years ago

Hi @vKito the issue still stands I believe. As a temp workaround you can either use a record with named fields or a tuple

kerams commented 2 years ago

Isn't the problem simply the fact that there's support only for 1 and 2 parameter functions? I guess it's not possible to generalize this with an expression taking functions with arbitrary arity?

vKito commented 2 years ago

Yup, I refactored my endpoint to accept a single value instead. Works this way thanks. At the same time I feel the need to point out a gotcha with the examples:

This is more a general quoted expression gotcha but I thought I would point it out for anyone needing help. If you pass in values that get computed at runtime, e.g. GUIDs, then the docs UI won't show any examples, but everything still compiles fine.

docs.route <@ fun api -> api.AddProductToCart @>
|> docs.example <@ fun api -> api.AddProductToCart(Guid.NewGuid(), Guid.NewGuid() @>  // example Guids for cart id and product id

The woraround to this is to simply create the GUID outside the quoted expression

let cartId = Guid.NewGuid()
let productId = Guid.NewGuid()
docs.example <@ fun api -> api.AddProductToCart(cartId, productId) @>