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

Adding documentation for functions with multiple parameters? #241

Open
Numpsy opened this issue Apr 28, 2021 · 9 comments
Open

Adding documentation for functions with multiple parameters? #241

Numpsy opened this issue Apr 28, 2021 · 9 comments

Comments

@Numpsy
Copy link

Numpsy commented Apr 28, 2021

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
Copy link
Owner

Zaid-Ajaj commented Apr 28, 2021

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
Copy link
Author

Numpsy commented Apr 28, 2021

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
Copy link
Owner

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

@Numpsy
Copy link
Author

Numpsy commented Jun 3, 2021

I'll give it a try later.

@Numpsy
Copy link
Author

Numpsy commented Jun 14, 2021

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
Copy link

vKito commented Feb 14, 2022

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

@Zaid-Ajaj
Copy link
Owner

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
Copy link
Collaborator

kerams commented Feb 14, 2022

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
Copy link

vKito commented Feb 18, 2022

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

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

4 participants