Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rancorm/castor
mitmproxy add-on that captures JSON schemas
https://github.com/rancorm/castor
http json json-schema mitmproxy
Last synced: 6 days ago
JSON representation
mitmproxy add-on that captures JSON schemas
- Host: GitHub
- URL: https://github.com/rancorm/castor
- Owner: rancorm
- License: gpl-3.0
- Created: 2024-02-13T03:32:36.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-02-18T12:26:36.000Z (9 months ago)
- Last Synced: 2024-10-10T11:21:37.642Z (27 days ago)
- Topics: http, json, json-schema, mitmproxy
- Language: Python
- Homepage:
- Size: 89.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Castor
Image is sourced from [pngimg](https://pngimg.com/image/31353).
mitmproxy add-on that captures JSON schemas.
## Start here
Clone this repository.
```sh
git clone https://github.com/rancorm/castor.git
cd castor
```Make Python virtual environment, install dependencies, and run.
```sh
python -m venv .venv
pip install -r requirements.txt
```Run `mitmproxy` terminal UI, `mitmdump` or `mitmweb` with the add-on script `castor.py`.
```sh
mitmproxy -s ./castor.py
```Run with web server UI.
```sh
mitmweb -s ./castor.py
```On the Flow > Response tab, change **View** to `json-schema`, or
set the `CASTOR_AUTO_RENDER` to `1` to auto render JSON resquest and responses
to JSON schemas.Dump to the console with `mitmdump`.
```sh
mitmdump -s ./castor.py
```## Output
Example output from `mitmdump` generated JSON schema.
```json
{
"type": "object",
"properties": {
"Code": {
"type": "int"
},
"CalendarModelEventID": {
"type": "str",
"pattern": "uri"
},
"Refresh": {
"type": "int"
},
"More": {
"type": "int"
}
}
}
```## Options
Disable checks of content type, set `CASTOR_CHECKS` to `0`. To disable the
auto rendering of JSON to JSON schema, set `CASTOR_AUTO_RENDER` to `1`.## Saving to disk
To save generated schema to disk, set `CASTOR_OUTPUT` to the path for saving.
```sh
export CASTOR_OUTPUT=/mnt/data
```This can perticularly be useful with persisent storage volumes inside containers.