Skip to content

Commit b659e7a

Browse files
committed
Add README.md
1 parent 7143fbc commit b659e7a

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,29 @@ pub async fn get_user(id: u32) -> Json<User> {
234234
- `HEAD`
235235
- `OPTIONS`
236236

237+
### Generating OpenAPI JSON
238+
239+
To generate an `openapi.json` file, create a `build.rs` file in your project root and add the following code:
240+
241+
```rust
242+
use vespera::vespera_openapi;
243+
244+
fn main() {
245+
// Generate OpenAPI JSON using vespera
246+
let json = vespera_openapi!();
247+
std::fs::write("openapi.json", json).unwrap();
248+
}
249+
```
250+
251+
You also need to add a `[build-dependencies]` section to your `Cargo.toml`:
252+
253+
```toml
254+
[build-dependencies]
255+
vespera = { path = "../../crates/vespera" }
256+
```
257+
258+
The `openapi.json` file will be automatically generated in the project root when you build.
259+
237260
### File Structure and Route Mapping
238261

239262
File structure is automatically converted to URL paths:

crates/vespera_macro/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,4 +251,3 @@ pub fn vespera_openapi(input: TokenStream) -> TokenStream {
251251

252252
expanded.into()
253253
}
254-

0 commit comments

Comments
 (0)