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

Feature request: Write and edit API endpoint descriptions #8438

Closed
ivanagas opened this issue May 8, 2024 · 2 comments · Fixed by #8581
Closed

Feature request: Write and edit API endpoint descriptions #8438

ivanagas opened this issue May 8, 2024 · 2 comments · Fixed by #8581

Comments

@ivanagas
Copy link
Contributor

ivanagas commented May 8, 2024

I want to add a description to an endpoint (AKA a set of operations) like Stripe does here: https://docs.stripe.com/api/charges

CleanShot 2024-05-08 at 16 16 33@2x

The current way to add descriptions to API endpoints is to use a doc string on the viewset class. I tried to do this, but it turns out this doesn't really work:

  1. Adding a doc string to a viewset class adds it as a description to all the operations rather than a description to the path.
  2. The way the endpoint description is generated is by getting the description from the first operation
  3. Adding extend_schema() to an operation (like we do in query) overwrites the operation description set by the viewset docstring.
  4. drf-spectacular (the way we generate the API schema) doesn't support generating path descriptions. The closest seems to be extend_view_schema() but this seems to just add new operations rather a description. To make it do something else would require a bunch of custom processing code.
  5. Adding links to posthog.com in the posthog repo code looks ugly

I'm not sure what the best way to do this is, I'm happy to try to figure it out if you point me in the right direction. I think it should be editable in the posthog.com repo.

@smallbrownbike
Copy link
Collaborator

What do you think about this?

Basically, add an MDX file (named after the endpoint ID's name) to the corresponding folder its page would belong to. Then, the description in the MDX file will only appear under the specified endpoint. This is like our MDX setup, except the file name will determine which endpoint the MDX contents appear on.

So, for adding a description to the "list annotations" endpoint, you'd create a new file - contents/docs/api/annotations/annotations_list.mdx

Then, whatever you add to that file will appear under that endpoint only (see screenshot below). Since you can also add React components, we can start making new endpoint-specific components to recommend guides or reference other helpful info, too!

Screenshot 2024-05-29 at 11 16 24 PM

@ivanagas
Copy link
Contributor Author

Yes, this would be perfect

@ivanagas ivanagas linked a pull request May 31, 2024 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants