Open API Generation

An open API spec can be generated for your App, JET is used to analyze the code and detects all of the Bonsai.read and Bonsai.write calls, this information is then used to create the spec. This feature is currently still alpha and needs some more work before it’s robust.

open_api = OpenApi(app)
JSON3.write("open-api.json", open_api)

To add a web page for your documentation you can call

openapi!(app)

This will add the endpoints:

  • docs/ - A web page containing documentation for API built using SwaggerUI
  • docs/open-api.json - The open API specifcation

Client Generation

You can generate clients using a number of tools from open-api specs, for example, to generate a typescript client you could run

npx openapi-typescript-codegen --input open-api.json --output client