File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
239262File structure is automatically converted to URL paths:
Original file line number Diff line number Diff line change @@ -251,4 +251,3 @@ pub fn vespera_openapi(input: TokenStream) -> TokenStream {
251251
252252 expanded. into ( )
253253}
254-
You can’t perform that action at this time.
0 commit comments