Skip to main content

reinhardt_rest/metadata/
options.rs

1//! Metadata configuration options
2
3use std::collections::HashMap;
4
5/// Field information from serializer introspection
6#[derive(Debug, Clone)]
7pub struct SerializerFieldInfo {
8	/// Field name
9	pub name: String,
10	/// Rust type name
11	pub type_name: String,
12	/// Whether the field is optional (`Option<T>`)
13	pub is_optional: bool,
14	/// Whether the field is read-only
15	pub is_read_only: bool,
16	/// Whether the field is write-only
17	pub is_write_only: bool,
18}
19
20/// Options for configuring metadata
21#[non_exhaustive]
22#[derive(Debug, Clone)]
23pub struct MetadataOptions {
24	/// The display name of the API view.
25	pub name: String,
26	/// A description of what the API view does.
27	pub description: String,
28	/// HTTP methods allowed on this view.
29	pub allowed_methods: Vec<String>,
30	/// Content types this view can render.
31	pub renders: Vec<String>,
32	/// Content types this view can parse from requests.
33	pub parses: Vec<String>,
34	/// Serializer field information for generating action metadata
35	pub serializer_fields: Option<HashMap<String, SerializerFieldInfo>>,
36}
37
38impl Default for MetadataOptions {
39	fn default() -> Self {
40		Self {
41			name: "API View".to_string(),
42			description: "API endpoint".to_string(),
43			allowed_methods: vec!["GET".to_string()],
44			renders: vec!["application/json".to_string()],
45			parses: vec!["application/json".to_string()],
46			serializer_fields: None,
47		}
48	}
49}