Skip to main content

data_for_seo/entity/on_page/
microdata.rs

1use crate::entity::OnPageDataApiCrawlStatus;
2use serde::{Deserialize, Serialize};
3
4/// Structured data (microdata/JSON-LD) validation results for a page.
5/// See <https://docs.dataforseo.com/v3/on_page/microdata/>.
6#[derive(Debug, Default, Serialize, Deserialize, Clone)]
7pub struct OnPageDataApiMicrodata {
8    /// Crawling progress: "in_progress" or "finished".
9    pub crawl_progress: Option<String>,
10    /// Statistics on the crawling session.
11    pub crawl_status: Option<OnPageDataApiCrawlStatus>,
12    /// Aggregated counts of validation issues by severity.
13    pub test_summary: Option<OnPageDataApiTestSummary>,
14    /// Number of items returned in this response.
15    pub items_count: Option<i64>,
16    /// Parsed structured-data items found on the page.
17    pub items: Option<Vec<OnPageDataApiItemJsonLd>>,
18}
19
20/// Counts of structured-data validation issues grouped by severity.
21/// See <https://docs.dataforseo.com/v3/on_page/microdata/>.
22#[derive(Debug, Default, Serialize, Deserialize, Clone)]
23pub struct OnPageDataApiTestSummary {
24    /// Number of fatal-level issues.
25    pub fatal: Option<i64>,
26    /// Number of error-level issues.
27    pub error: Option<i64>,
28    /// Number of warning-level issues.
29    pub warning: Option<i64>,
30    /// Number of info-level notices.
31    pub info: Option<i64>,
32}
33
34/// A single structured-data item parsed from the page.
35/// See <https://docs.dataforseo.com/v3/on_page/microdata/>.
36#[derive(Debug, Default, Serialize, Deserialize, Clone)]
37pub struct OnPageDataApiItemJsonLd {
38    /// Structured-data format of the item, e.g. "json_ld" or "microdata".
39    #[serde(rename = "type")]
40    pub items_type: Option<String>,
41    /// Parsed schema and validation details for the item.
42    pub inspection_info: Option<OnPageDataSchema>,
43}
44
45/// Parsed schema of a structured-data item.
46/// See <https://docs.dataforseo.com/v3/on_page/microdata/>.
47#[derive(Debug, Default, Serialize, Deserialize, Clone)]
48pub struct OnPageDataSchema {
49    /// Schema.org types declared by the item.
50    pub types: Option<Vec<String>>,
51    /// Properties defined on the item.
52    pub fields: Option<Vec<OnPageDataSchemaField>>,
53}
54/// A single property of a structured-data schema.
55/// See <https://docs.dataforseo.com/v3/on_page/microdata/>.
56#[derive(Debug, Default, Serialize, Deserialize, Clone)]
57pub struct OnPageDataSchemaField {
58    /// Name of the property.
59    pub name: Option<String>,
60    /// Schema.org types allowed for the property.
61    pub types: Option<Vec<String>>,
62    /// Value assigned to the property.
63    pub value: Option<String>,
64    /// Validation result recorded for the property.
65    pub test_results: Option<OnPageDataSchemaTestResult>,
66    /// Nested properties of the property.
67    pub fields: Option<Vec<OnPageDataSchemaField>>,
68}
69/// Validation outcome for a structured-data property.
70/// See <https://docs.dataforseo.com/v3/on_page/microdata/>.
71#[derive(Debug, Default, Serialize, Deserialize, Clone)]
72pub struct OnPageDataSchemaTestResult {
73    /// Severity of the result: "fatal", "error", "warning" or "info".
74    pub level: Option<String>,
75    /// Human-readable description of the validation result.
76    pub message: Option<String>,
77}