jupyter_server icon indicating copy to clipboard operation
jupyter_server copied to clipboard

Add an HTML endpoint for `/api` with interactive docs

Open bollwyvl opened this issue 1 year ago • 3 comments

References

  • https://discourse.jupyter.org/t/how-jupyterhub-identifies-notebooks-or-files-from-url/25471/5

Problem

Finding the docs for the REST API is semi-annoying, and then not particularly interactive.

Proposed Solution

If a user visits e.g. http://127.0.0.1:8888/api in a browser, show them an interactive HTML application (that we don't have to write).

Additional context

This could be achieved by sniffing the accept header on /api in .

The static assets could be provisioned via (likely) some additional npm packages and a small jinja template to inject client settings (e.g. _xsrf).

We ship the OpenAPI Specification for the Jupyter Server REST API. There are a number of static HTML apps that consume OpenAPI specs, and present the spec as human-centric UI, and can also make live requests via JS. Some examples:

  • https://github.com/Redocly/redoc
  • https://github.com/swagger-api/swagger-ui

This could be demonstrated initially with an extension.

A longer term play would be to build this type of content with the modern Jupyter Client framework, such that it would inherit local theme options.

bollwyvl avatar May 02 '24 15:05 bollwyvl

We recently switched to redoc for the JupyterHub API on readthedocs: https://jupyterhub.readthedocs.io/en/latest/reference/rest-api.html I think it looks quite nice! It works in the way you say- the HTML code is pretty minimal, it's javascript that fetches the openapi spec https://jupyterhub.readthedocs.io/en/latest/_static/rest-api.yml and renders it.

manics avatar May 02 '24 16:05 manics

Sure, can take a look at redoc first. They kinda push the veal with their premium product, but if it does the job, and the open source variant isn't too crippled...

bollwyvl avatar May 02 '24 21:05 bollwyvl

#1419 is ready for review: a lot of author doubt in there, and open to ways forward, with a personal bias toward first-party extension and jupyter_server[apidocs] shout-out from this repo (and placeholder content).

bollwyvl avatar May 03 '24 13:05 bollwyvl