From 902f65a5663ee03466381a36715f1a94620de13a Mon Sep 17 00:00:00 2001 From: NexVeridian Date: Wed, 29 Jan 2025 11:32:08 -0800 Subject: [PATCH] fix doc tests --- src/controller/mod.rs | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/controller/mod.rs b/src/controller/mod.rs index b7d0756a0..eb0949fb3 100644 --- a/src/controller/mod.rs +++ b/src/controller/mod.rs @@ -6,7 +6,7 @@ //! implementing routes trait from [`crate::app::Hooks`] and adding your //! endpoints to your application //! -//! ```rust +//! ```rust, no_run //! use async_trait::async_trait; //! use loco_rs::{ //! app::{AppContext, Hooks}, @@ -20,6 +20,12 @@ //! }; //! use sea_orm::DatabaseConnection; //! use std::path::Path; +//! #[cfg(any( +//! feature = "openapi_swagger", +//! feature = "openapi_redoc", +//! feature = "openapi_scalar" +//! ))] +//! use loco_rs::auth::openapi::{set_jwt_location_ctx, SecurityAddon}; //! //! /// this code block should be taken from the sea_orm migration model. //! pub struct App; @@ -62,6 +68,28 @@ //! async fn seed(_ctx: &AppContext, base: &Path) -> Result<()> { //! Ok(()) //! } +//! +//! #[cfg(any( +//! feature = "openapi_swagger", +//! feature = "openapi_redoc", +//! feature = "openapi_scalar" +//! ))] +//! fn inital_openapi_spec(ctx: &AppContext) -> utoipa::openapi::OpenApi { +//! set_jwt_location_ctx(ctx); +//! +//! #[derive(OpenApi)] +//! #[openapi( +//! modifiers(&SecurityAddon), +//! info( +//! title = "Loco Demo", +//! description = "This app is a kitchensink for various capabilities and examples of the [Loco](https://loco.rs) project." +//! ) +//! )] +//! struct ApiDoc; +//! set_jwt_location_ctx(ctx); +//! +//! ApiDoc::openapi() +//! } //! } //! ```