Simplify the instructions in the readme

This commit is contained in:
Era Dorta 2026-05-04 14:59:48 +01:00
parent 1f222d7261
commit a168cf5547

View File

@ -4,52 +4,61 @@ These files are generated using the [swaggo/swag](https://github.com/swaggo/swag
There are two steps, first generating the docs and then running the web server.
## Generating the docs
## With docker compose (recommended)
Regenerate the files with your local source code changes.
1. Build the docs
```bash
docker compose build
```
2. Serve the docs
```bash
docker compose up
```
3. Go to http://127.0.0.1:8080/swagger/index.html to view the docs
* If you get a Network error, replace the IP for the docker internal IP in the error, e.g: http://172.18.0.2:8080/swagger/index.html
## Locally
Install [go](https://go.dev/).
### Generating the docs
1. Set the current working dir to `src`
```bash
cd src
```
1. Run swag to generate the docs
* Option 1, via docker
* Option 1, via go
```bash
docker run --rm -v $(pwd):/code ghcr.io/swaggo/swag:latest init --requiredByDefault --outputTypes "go,json"
go run github.com/swaggo/swag/cmd/swag@v1.16.6 init --requiredByDefault --outputTypes "go,json"
```
* Option 2, install swag and run the command line tool
* Option 2, directly with swag
```bash
swag init --requiredByDefault --outputTypes "go,json"
```
* Option 3, swag via docker
```bash
docker run --rm -v $(pwd):/code ghcr.io/swaggo/swag:latest init --requiredByDefault --outputTypes "go,json"
```
1. Set the current working dir to `src/docs`
```bash
cd docs
```
1. Run the script to add the receive V1 schemas
1. Run the script to add the receive V1 schemas from https://github.com/AsamK/signal-cli#json-schemas-for-the-json-rpc-mode
```bash
go run add_v1_receive_schemas.go
go run add_v1_receive_schemas.go ./path-to-signal-cli-json-schema-folder
```
## Run the web server
### Run the web server
Run the web server to visualize the generated docs.
1. Navigate to the `src` folder
```bash
cd src
```
1. Run the main script
* Option 1, via docker, run the command at the root of the repository
```bash
docker compose up
```
* Option 2, install go and run the command line tool
```bash
cd src
```
```bash
go run main.go
```
## Navigate to the docs
The docs are served at: http://127.0.0.1:8080/swagger/index.html
When serving with docker, if you get a Network error, replace the IP for the docker internal IP in the error, e.g: http://172.18.0.2:8080/swagger/index.html
```bash
go run main.go
```
1. Go to http://127.0.0.1:8080/swagger/index.html