This message was deleted.
# ask-for-help
s
This message was deleted.
c
1. you can use any IODescriptors’
from_sample
method to provide an example input! This way it shows up on the swagger UI nicely
2. Yes! simply add a docstring to your API function, e.g.:
Copy code
@svc.api(..)
def predict(..):
  """
  Description for the predict endpoint goes here..
  """
We are also considering allow advanced users to customize the generated API docs via a extra_fields json blob, does that sound like what you’re looking for?
s
1. I believe that if you use
from_sample
in your IO descriptor, it should display that in the UI. 2.
Copy code
svc.api(..., doc="documentation")
should do the trick!
Oh shoot, I totally missed that Chaoyu had already responded.
j
Thank you both, @Chaoyu and @sauyon! I had been using .from_sample() when my io descriptors were DataFrames. I’ve switched to JSON with Pydantic because of the cleanliness and ease of specifying nullables, requireds, defaults, and validators. But I did see there was a JSON .from_sample(). Do you happen to know if I can use .from_sample() for the example data but then defer to the Pydantic models for everything else?
We are also considering allow advanced users to customize the generated API docs via a extra_fields json blob, does that sound like what you’re looking for?
@Chaoyu yes, that does sound like what i’m looking for as a nice-to-have
👍 1
c
@Jack Norman yes, you can do something like this:
Copy code
input=JSON.from_sample({'sample': [1,2,3]}, pydantic_model=MyModel)
🤩 1
j
That’s great! Thank you!
I’ll keep a lookout for the extra_fields json blob in future versions, but this will be helpful in the meantime. Thanks again. 🍱