Fable.Remoting icon indicating copy to clipboard operation
Fable.Remoting copied to clipboard

Adding documentation for functions with multiple parameters?

Open Numpsy opened this issue 4 years ago • 9 comments

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

Numpsy avatar Apr 28 '21 10:04 Numpsy

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

Zaid-Ajaj avatar Apr 28 '21 11:04 Zaid-Ajaj

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

Thanks

Numpsy avatar Apr 28 '21 11:04 Numpsy

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

Zaid-Ajaj avatar Jun 03 '21 10:06 Zaid-Ajaj

I'll give it a try later.

Numpsy avatar Jun 03 '21 15:06 Numpsy

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.)

Numpsy avatar Jun 14 '21 10:06 Numpsy

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

vKito avatar Feb 14 '22 13:02 vKito

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

Zaid-Ajaj avatar Feb 14 '22 14:02 Zaid-Ajaj

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?

kerams avatar Feb 14 '22 14:02 kerams

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) @>

vKito avatar Feb 18 '22 08:02 vKito