1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
// SPDX-FileCopyrightText: 2025-2026 RAprogramm <andrey.rozanov.vl@gmail.com>
// SPDX-License-Identifier: MIT
//! API configuration parsing for OpenAPI/utoipa integration.
//!
//! This module handles parsing of `#[entity(api(...))]` attributes that control
//! automatic HTTP handler generation with OpenAPI documentation. The API
//! configuration determines what handlers are generated, how they're secured,
//! and how they appear in Swagger UI.
//!
//! # Architecture
//!
//! ```text
//! ┌─────────────────────────────────────────────────────────────────────┐
//! │ API Configuration Parsing │
//! ├─────────────────────────────────────────────────────────────────────┤
//! │ │
//! │ Source Parsing Output │
//! │ │
//! │ #[entity( parse_api_config() ApiConfig │
//! │ api( │ │ │
//! │ tag = "Users", │ ├── tag │
//! │ security = "bearer", │ ├── security │
//! │ handlers(create, get) │ ├── handlers │
//! │ ) │ └── ... │
//! │ )] ▼ │
//! │ HandlerConfig │
//! │ │ │
//! │ ├── create: true │
//! │ ├── get: true │
//! │ └── update/delete/list: false │
//! │ │
//! └─────────────────────────────────────────────────────────────────────┘
//! ```
//!
//! # Configuration Options
//!
//! The `api(...)` attribute supports the following options:
//!
//! ## Core Options
//!
//! | Option | Type | Required | Description |
//! |--------|------|----------|-------------|
//! | `tag` | string | Yes | OpenAPI tag for endpoint grouping |
//! | `tag_description` | string | No | Tag description for docs |
//! | `handlers` | flag/list | No | CRUD handlers to generate |
//!
//! ## URL Configuration
//!
//! | Option | Type | Example | Result |
//! |--------|------|---------|--------|
//! | `path_prefix` | string | `"/api"` | `/api/users` |
//! | `version` | string | `"v1"` | `/api/v1/users` |
//!
//! ## Security Configuration
//!
//! | Option | Type | Values | Description |
//! |--------|------|--------|-------------|
//! | `security` | string | `"bearer"`, `"cookie"`, `"api_key"` | Default auth |
//! | `public` | list | `[Register, Login]` | Commands without auth |
//!
//! ## OpenAPI Info
//!
//! | Option | Description |
//! |--------|-------------|
//! | `title` | API title for OpenAPI spec |
//! | `description` | API description (markdown) |
//! | `api_version` | Semantic version string |
//! | `license` | License name (e.g., "MIT") |
//! | `license_url` | URL to license text |
//! | `contact_name` | API maintainer name |
//! | `contact_email` | Support email address |
//! | `contact_url` | Support website URL |
//!
//! ## Deprecation
//!
//! | Option | Description |
//! |--------|-------------|
//! | `deprecated_in` | Version where API was deprecated |
//!
//! # Handler Configuration
//!
//! The `handlers` option controls CRUD handler generation:
//!
//! ```rust,ignore
//! // Generate all handlers (create, get, update, delete, list)
//! api(tag = "Users", handlers)
//!
//! // Generate specific handlers only
//! api(tag = "Users", handlers(create, get, list))
//!
//! // Disable handlers (commands only)
//! api(tag = "Users", handlers = false)
//! ```
//!
//! # Complete Example
//!
//! ```rust,ignore
//! #[entity(
//! table = "users",
//! api(
//! tag = "Users",
//! tag_description = "User account management endpoints",
//! path_prefix = "/api",
//! version = "v1",
//! security = "bearer",
//! public = [Register, Login],
//! handlers(create, get, update, list),
//! title = "User Service",
//! api_version = "1.0.0",
//! license = "MIT"
//! )
//! )]
//! pub struct User {
//! #[id]
//! pub id: Uuid,
//! #[field(create, update, response)]
//! pub email: String,
//! }
//! ```
//!
//! # Module Structure
//!
//! | Module | Purpose |
//! |--------|---------|
//! | [`config`] | Type definitions for `ApiConfig` and `HandlerConfig` |
//! | [`parser`] | Attribute parsing logic for `api(...)` |
pub use ApiConfig;
pub use parse_api_config;