You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
4. Run `cargo run --example generate_openapi_spec` to verify the spec generates correctly. Follow instructions below.
70
77
71
78
### Generating the OpenAPI Spec Locally
79
+
If you don't want to compile the Sync server on your machine to view the API docs, follow these instructions:
72
80
73
81
#### Use `make api-prev`
74
82
We created a handy Makefile command called `make api-prev` that automatically generates the specification file, runs Swagger in Docker and opens your browser to `localhost:8080`. See the steps below to understand this process. Note this attempts to be platform agnostic, but might require some adaptation depending on your operating system.
75
83
76
-
You can generate the OpenAPI specification without running the server:
84
+
Commands to generate the OpenAPI specification without running the server:
77
85
78
86
```bash
79
87
# Generate the spec to stdout
@@ -83,29 +91,22 @@ cargo run --example generate_openapi_spec
83
91
cargo run --example generate_openapi_spec > openapi.json
84
92
```
85
93
86
-
### Viewing the Spec Locally (Without Running the Server)
87
-
88
-
If you don't want to compile the server on your machine, you can still view the API documentation:
89
-
90
-
1.**Use Docker** (simplest):
94
+
Other options:
95
+
1.**Use Docker** (simplest - used in `make api-prev`):
91
96
This option requires you to have run `cargo run --example generate_openapi_spec > openapi.json`.
97
+
92
98
```bash
93
99
docker run -p 8080:8080 -e SWAGGER_JSON=/openapi.json -v $(pwd)/openapi.json:/openapi.json swaggerapi/swagger-ui
94
100
```
95
101
Then open http://localhost:8080
96
102
97
-
2.**Generate the spec on a compatible machine** (or use CI):
98
-
```bash
99
-
cargo run --example generate_openapi_spec > openapi.json
100
-
```
101
-
102
-
3.**Use online Swagger Editor**:
103
+
2.**Use online Swagger Editor**:
103
104
- Go to https://editor.swagger.io/
104
105
- Copy the contents of `openapi.json`
105
106
- Paste into the editor
106
107
- View the interactive documentation
107
108
108
-
4.**Use VS Code extension**:
109
+
3.**Use VS Code extension**:
109
110
- Install "OpenAPI (Swagger) Editor" extension
110
111
- Open `openapi.json` in VS Code
111
112
- Click "Preview Swagger" to view interactive docs
0 commit comments