We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 700ccbd + b999f5a commit deb6b93Copy full SHA for deb6b93
Cargo.toml
@@ -50,6 +50,7 @@ serde_json = "1"
50
syn = "2.0"
51
52
actix-multipart = "0.6"
53
+actix-session = "0.10"
54
garde-actix-web = "0.9"
55
chrono = "0.4.20"
56
garde = { version = "0.20", features = ["derive", "serde"] }
README.md
@@ -174,6 +174,7 @@ For a complete example, see [the sample petstore](https://github.com/netwo-io/ap
174
| `actix` (default) | Enables documenting types from `actix` | |
175
| `lab_query` | Enables documenting `actix_web_lab::extract::Query` | [`actix-web-lab`](https://crates.io/crates/actix-web-lab) |
176
| `garde` | Enables input validation through `garde` | [`garde`](https://crates.io/crates/garde) |
177
+| `actix-session` | Enables documenting types from `actix-session` | [`actix-session`](https://crates.io/crates/actix-session) |
178
| `actix-web-grants` | Enables support for `actix-web-grants` | [`actix-web-grants`](https://crates.io/crates/actix-web-grants) |
179
| `rapidoc` | Enables RapiDoc to expose the generated openapi file | |
180
| `redoc` | Enables Redoc to expose the generated openapi file | |
apistos-core/Cargo.toml
@@ -21,6 +21,7 @@ actix-web = { workspace = true, optional = true }
21
actix-web-lab = { workspace = true, optional = true }
22
actix-web-grants = { workspace = true, optional = true }
23
actix-multipart = { workspace = true, optional = true }
24
+actix-session = { workspace = true, optional = true }
25
garde-actix-web = { workspace = true, optional = true }
26
chrono = { workspace = true, optional = true }
27
rust_decimal = { workspace = true, optional = true }
@@ -54,6 +55,7 @@ garde = ["actix", "dep:garde-actix-web"]
chrono = ["dep:chrono", "schemars/chrono"]
multipart = ["actix", "dep:serde", "dep:actix-multipart"]
57
rust_decimal = ["dep:rust_decimal", "schemars/rust_decimal"]
58
+actix-session = ["actix", "dep:serde", "dep:actix-session"]
59
uuid = ["dep:uuid", "schemars/uuid1"]
60
url = ["dep:url", "schemars/url"]
61
extras = ["chrono", "multipart", "rust_decimal", "uuid", "url"]
apistos-core/src/components/mod.rs
@@ -8,4 +8,6 @@ pub mod json;
8
pub mod multipart;
9
#[cfg(feature = "actix")]
10
pub mod parameters;
11
+#[cfg(feature = "actix-session")]
12
+pub mod session;
13
pub mod simple;
apistos-core/src/components/session.rs
@@ -0,0 +1,40 @@
1
+use crate::ApiComponent;
2
+use apistos_models::paths::{Parameter, ParameterDefinition, ParameterIn, RequestBody};
3
+use apistos_models::reference_or::ReferenceOr;
4
+use schemars::schema::{InstanceType, Schema, SchemaObject, SingleOrVec, StringValidation};
5
+
6
+impl ApiComponent for actix_session::Session {
7
+ fn required() -> bool {
+ true
+ }
+ fn child_schemas() -> Vec<(String, ReferenceOr<Schema>)> {
+ vec![]
14
15
+ fn raw_schema() -> Option<ReferenceOr<Schema>> {
16
+ Some(ReferenceOr::Object(Schema::Object(SchemaObject {
17
+ instance_type: Some(SingleOrVec::Single(Box::new(InstanceType::String))),
18
+ string: Some(Box::new(StringValidation::default())),
19
+ ..Default::default()
20
+ })))
+ fn schema() -> Option<(String, ReferenceOr<Schema>)> {
+ None
+ fn request_body() -> Option<RequestBody> {
28
29
30
31
+ fn parameters() -> Vec<Parameter> {
32
+ vec![Parameter {
33
+ name: "id".to_string(), // from default actix-session's CookieConfiguration
34
+ _in: ParameterIn::Cookie,
35
+ required: Some(true),
36
+ definition: Self::raw_schema().map(ParameterDefinition::Schema),
37
38
+ }]
39
40
+}
0 commit comments