Skip to content

pfeodrippe/pitoco

Repository files navigation

pitoco

Pitoco

Create Malli (API) schemas from captured HTTP requests and responses or from recording inputs and outputs of instrumented functions, e.g. during a test run. You can also diff the API schemas (for example to explore how the REST API changed between versions) and the instrumentation-based process includes the schemas in the functions' docstrings, which might help in familiarizing with an unknown code base.

Malli has a way to generate schemas, but it was too slow in comparison with spec-provider.

Installation

Use it directly from github for now (lein and deps should be able to do it).

Usage

See the test file and rich comments (comment) in the core for usage.

We have a web app which uses Pitoco so you can visualize your schemas easily, but you can use Pitoco as a library.

You can start the server at http://localhost:8081 by loading the pitoco.server namespace. Now start the shadow-cljs server and access http://localhost:8000.

Generating API schemas from captured HTTP requests and responses

The first use case of Pitoco is generating Malli schemas for REST APIs based on captured HTTP requests and responses (using either HAR archives from your browser or .pcap files from tcpdump).

See a quick video at https://youtu.be/iMcUTygFrfk.

Generating function schemas from recorded inputs and outputs of instrumented vars

The second use case of Pitoco is to instrument selected vars, record their inputs and outputs, and generate Malli schemas from those, including them in the vars' docstrings.

See the pitoco.instrumentation namespace.

Also you can watch https://youtu.be/MloJSCl38d0.

There is a [VSCode Extension](https://marketplace.visualstudio.com/items?itemName=feodrippe.pitoco-extension&ssr=false#overview) where you can visualize the inferred schemas (+ examples) using VSCode in the web (e.g. during PRs so you can have augmented context when needed).

Developer setup

Clone the repo and enter in the repo

git clone https://github.com/pfeodrippe/pitoco
cd pitoco

Enter in the web_app directory, install npm deps and start the frontend.

cd web_dev
npm install
npm start

The npm start command should spawn both shadow-cljs and tailwindcss.

Then in another terminal, you can enter in the web_dev folder again and start the backend.

cd pitoco/web_dev
clj -e "(require,'pitoco.server)"

After a while, the frontend will be available at localhost:8000. You can connect on it via browser.

The backend will be available at localhost:8081. You can check if it is running with curl

curl http://localhost:8081/chsk
# {"type":"exception","class":"clojure.lang.ExceptionInfo"}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages