Skip to main content

dre_core/config/
report.rs

1//! The shape of a report YAML file under `reports/` (one fragment of a report: a report may be
2//! split over several files, merged by name).
3//!
4//! Values the loader checks itself, to say what's wrong in DRE's words, are [`Loose`]. Outputs and
5//! Sets are read where they're used.
6
7use schemars::JsonSchema;
8use serde::Deserialize;
9use serde::de::IgnoredAny;
10
11use super::de::{Located, Loose, Map, Maybe, OneOf, UnknownKeys};
12
13type JsonMap = serde_json::Map<String, serde_json::Value>;
14
15/// One `queries:` item: a query's name, or a query with settings.
16pub type QueryItem = Located<Loose<OneOf<String, QueryEntry>>>;
17
18/// A report: SQL queries plus an output, in a YAML file under `reports/`.
19#[derive(Default, Deserialize, JsonSchema)]
20#[schemars(title = "DRE report", deny_unknown_fields)]
21pub struct ReportFile {
22    /// The report's name. Default: the name of the folder the YAML file is in. Report names are unique across the project.
23    #[schemars(length(min = 1))]
24    pub name: Option<Located<Loose<String>>>,
25    /// What this report answers, including its business definitions and units.
26    pub description: Option<Located<Loose<String>>>,
27    /// Metadata for external tools. DRE checks its shape, not the meaning of its keys.
28    pub meta: Option<Located<Loose<JsonMap>>>,
29    /// Tags to select the report with, `-s tag:<tag>`.
30    pub tags: Option<Located<Loose<Vec<String>>>>,
31    /// The `.sql` files whose results make the report's tabs, in the order they run, on one database session.
32    #[serde(default)]
33    #[schemars(schema_with = "queries")]
34    pub queries: Option<Located<Loose<Vec<QueryItem>>>>,
35    /// One output, or a list of outputs formatted from the same run of the queries (file outputs are delivered before messages). A list replaces the inherited output; a map changes it.
36    #[serde(default)]
37    #[schemars(schema_with = "output_or_list")]
38    pub output: Option<IgnoredAny>,
39    /// The connection (in `profiles.yml`) the queries run on, unless a query's own `profile:` or a source's says otherwise. Default: the folder's `+profile`, then `default_profile`. Can't be combined with `sets`. May use Jinja with `var()`, `env_var()`, `run.*` and `target.name`.
40    pub profile: Option<Located<Loose<String>>>,
41    /// The Sets the report can run as, by name (declared in `sets.yml`) or declared here.
42    pub sets: Option<Located<Loose<Vec<SetItem>>>>,
43    /// The Set a plain `dre run` uses. Must be one of `sets`.
44    pub default_set: Option<Located<Loose<String>>>,
45    /// Variables, read in SQL and YAML with `var('name')`. Values can be strings, numbers, booleans, lists or maps.
46    pub vars: Option<Located<Loose<JsonMap>>>,
47    /// Optional declarations for variables: type, default, allowed values, description, required, and for strings a pattern and max_length.
48    /// Kept separate from `vars` so a map-valued variable remains a plain value.
49    pub var_schema: Option<Located<Loose<crate::variables::Definitions>>>,
50    /// The timezone `run.date` and `run.now` use, an IANA name such as `Australia/Sydney`. Default: UTC.
51    pub timezone: Option<Located<Loose<String>>>,
52    /// The locale this report's number filters format for (`de-DE`). Default: the folder's `+locale`, then the project's `locale`, then `en`.
53    pub locale: Option<Located<Loose<String>>>,
54    /// The plugin packages this project uses. DRE installs them on demand into `dre_deps/` and pins them in `dre.lock`. May be written in any project YAML file; `dependencies.yml` is the usual place.
55    #[serde(default)]
56    #[schemars(schema_with = "super::dependencies::plugins")]
57    pub plugins: Option<IgnoredAny>,
58    /// dbt-style source declarations (see the sources schema). May be written in any project YAML file.
59    #[serde(default)]
60    #[schemars(schema_with = "super::project::sources_ref")]
61    pub sources: Option<IgnoredAny>,
62    /// Removed: schedules live in schedules.yml. Read only to say so.
63    #[schemars(skip)]
64    pub schedule: Option<Located<IgnoredAny>>,
65    #[serde(rename = "$unknown", default)]
66    #[schemars(skip)]
67    pub unknown: UnknownKeys,
68}
69
70/// A query with settings, instead of just its name.
71#[derive(Deserialize, JsonSchema)]
72#[schemars(rename = "queryEntry", deny_unknown_fields)]
73pub struct QueryEntry {
74    /// The name of a `.sql` file under `reports/`, without folder or extension.
75    #[schemars(required)]
76    pub query: Option<Loose<String>>,
77    /// The connection this query runs on, over the report's, Set's, folder's and project's. Must agree with the `profile` of any source it uses. May use Jinja with `var()`, `env_var()`, `run.*` and `target.name`.
78    pub profile: Option<Loose<String>>,
79    /// `false` runs the file only for what it does (temp tables, `SET`s) and discards any result, so it gets no tab.
80    #[schemars(extend("default" = true))]
81    pub tab: Option<Loose<bool>>,
82    /// The tab (sheet) name. Default: the file's name. Not allowed with `tab: false`.
83    pub tab_name: Option<Loose<String>>,
84    /// Where the data starts on the sheet (xlsx only). Default: `A1`.
85    #[schemars(regex(pattern = "^[A-Za-z]{1,3}[0-9]+$"))]
86    pub anchor: Option<Loose<String>>,
87    /// Whether to write the column names as the first row (xlsx only). Default: the output's `header`.
88    pub header: Option<Loose<bool>>,
89    /// Per-column settings for this tab, by column name (xlsx only).
90    #[serde(default)]
91    #[schemars(schema_with = "columns")]
92    pub columns: Option<serde_json::Value>,
93    /// When this query returns no rows: `continue` keeps its empty tab or section, `skip` leaves its tab (or per-query file) out, `fail` fails the run. Wins over the output's `on_empty`. Default: the output decides once every query is empty.
94    pub on_empty: Option<Loose<crate::no_data::OnEmpty>>,
95    /// Size this tab's columns from their content (xlsx only), over the output's `autofit`. Default: the output's, which is on.
96    pub autofit: Option<Loose<bool>>,
97    /// How this tab looks (xlsx only), over the output's `style`: `font`, `header`, `totals`, `banded_rows`, `borders`, and cell keys (`bold`, `fill`, ...) for every data cell. See the xlsx plugin page.
98    #[serde(default)]
99    #[schemars(schema_with = "sheet_style")]
100    pub style: Option<serde_json::Value>,
101    #[serde(rename = "$unknown", default)]
102    #[schemars(skip)]
103    pub unknown: UnknownKeys,
104}
105
106fn sheet_style(_: &mut schemars::SchemaGenerator) -> schemars::Schema {
107    schemars::json_schema!({
108        "type": "object",
109        "description": "How an xlsx tab looks. Cell keys apply to every data cell; `header` and `totals` take cell keys for those rows.",
110        "properties": {
111            "header": {"type": "object", "description": "Cell keys for the header row (default: bold)."},
112            "totals": {"type": "object", "description": "Cell keys for the totals row (default: bold, a thin top border)."},
113            "banded_rows": {"oneOf": [{"type": "string", "pattern": "^#?[0-9A-Fa-f]{6}$"}, {"const": false}], "description": "The fill of every other data row, `\"#RRGGBB\"`, or `false`."},
114            "borders": {"enum": ["none", "thin", "medium"], "description": "A border around every cell of the table."},
115            "bold": {"type": "boolean", "description": "Bold text in every data cell."},
116            "italic": {"type": "boolean", "description": "Italic text in every data cell."},
117            "underline": {"type": "boolean", "description": "Underlined text in every data cell."},
118            "font": {"type": "object", "description": "The font: `{name: Calibri, size: 11}`.", "properties": {"name": {"type": "string", "description": "The font's name."}, "size": {"type": "number", "description": "The size in points."}}, "additionalProperties": false},
119            "font_color": {"type": "string", "pattern": "^#?[0-9A-Fa-f]{6}$", "description": "The text colour, `\"#RRGGBB\"`."},
120            "fill": {"type": "string", "pattern": "^#?[0-9A-Fa-f]{6}$", "description": "The background colour, `\"#RRGGBB\"`."},
121            "align": {"enum": ["left", "center", "right"], "description": "Horizontal alignment."},
122            "border": {"enum": ["none", "thin", "medium"], "description": "A border around each data cell."}
123        },
124        "additionalProperties": false
125    })
126}
127
128fn columns(_: &mut schemars::SchemaGenerator) -> schemars::Schema {
129    schemars::json_schema!({
130        "type": "object",
131        "additionalProperties": {
132            "type": "object",
133            "description": "Settings for one column of an xlsx tab.",
134            "properties": {
135                "format": {"type": "string", "description": "The Excel number format of the column, e.g. `#,##0.00` or `dd/mm/yyyy`. See the xlsx column formats in the plugins reference."},
136                "formula": {"type": "string", "description": "An Excel formula for each row of this column; `{name}` stands for that column's cell on the same row, e.g. `=ROUND({qty}*{unit_price},2)`. The SQL selects a placeholder column where the formula goes."},
137                "total": {"type": "string", "description": "Puts a total under the column: one of `sum`, `count`, `average`, `min`, `max`, or a formula such as `=SUM({net:*})`."},
138                "style": {"type": "object", "description": "How the column's data cells look: `bold`, `italic`, `underline`, `font` (`{name, size}`), `font_color`, `fill` (`\"#RRGGBB\"`), `align` (`left`, `center`, `right`), `border` (`none`, `thin`, `medium`). Over the tab's and output's `style`."},
139                "width": {"oneOf": [{"const": "auto"}, {"type": "number", "exclusiveMinimum": 0, "maximum": 255}], "description": "The column's width: `auto` (sized from its content, at most 60 characters) or a number of characters. Over the tab's and output's `autofit`."}
140            },
141            "additionalProperties": false
142        },
143        "propertyNames": {"minLength": 1}
144    })
145}
146
147/// One `sets:` item: a Set's name (declared in `sets.yml`), or a Set declared here.
148pub type SetItem = Located<Loose<OneOf<String, SetEntry>>>;
149
150/// A Set declared in the report: a named variant of it.
151#[derive(Deserialize, JsonSchema)]
152#[schemars(rename = "setEntry", deny_unknown_fields)]
153pub struct SetEntry {
154    /// The Set's name. A report can also name Sets declared in `sets.yml`.
155    #[schemars(required)]
156    pub name: Option<Loose<String>>,
157    /// The connection this Set runs on. May use Jinja with `var()`, `env_var()`, `run.*` and `target.name`.
158    pub profile: Option<Located<Loose<String>>>,
159    /// Variables, read in SQL and YAML with `var('name')`. Values can be strings, numbers, booleans, lists or maps.
160    #[serde(default)]
161    #[schemars(schema_with = "any_map")]
162    pub vars: Option<Loose<JsonMap>>,
163    /// Queries to leave out of this Set, by name.
164    pub exclude: Option<Located<Loose<Vec<String>>>>,
165    /// Replaces the report's queries for this Set.
166    #[serde(default)]
167    #[schemars(schema_with = "set_queries")]
168    pub queries: Option<Located<Loose<Vec<SetQueryItem>>>>,
169    /// Renames tabs for this Set: query name to tab name.
170    #[serde(default)]
171    #[schemars(schema_with = "tab_names")]
172    pub tab_names: Option<Loose<JsonMap>>,
173    /// Output settings for this Set: a map changes the inherited output (with several, the one its `name:` names); a list replaces them all.
174    #[serde(default)]
175    #[schemars(schema_with = "output_or_list")]
176    pub output: Option<serde_json::Value>,
177    /// The locale for this Set's number filters (`fr-FR`), above the report's.
178    pub locale: Option<Loose<String>>,
179    /// Removed: schedules live in schedules.yml. Read only to say so.
180    #[schemars(skip)]
181    pub schedule: Option<IgnoredAny>,
182    #[serde(rename = "$unknown", default)]
183    #[schemars(skip)]
184    pub unknown: UnknownKeys,
185}
186
187/// One item of a Set's `queries:`: a query's name, or a query with settings.
188pub type SetQueryItem = Loose<OneOf<String, SetQuery>>;
189
190/// A query of a Set with its own settings.
191#[derive(Deserialize)]
192pub struct SetQuery {
193    pub query: Option<Loose<String>>,
194    pub tab: Option<Loose<bool>>,
195    pub tab_name: Option<Loose<String>>,
196    pub on_empty: Option<Loose<crate::no_data::OnEmpty>>,
197}
198
199fn any_map(_: &mut schemars::SchemaGenerator) -> schemars::Schema {
200    schemars::json_schema!({"type": "object", "additionalProperties": true})
201}
202
203fn tab_names(_: &mut schemars::SchemaGenerator) -> schemars::Schema {
204    schemars::json_schema!({"type": "object", "additionalProperties": {"type": "string"}})
205}
206
207fn output_or_list(g: &mut schemars::SchemaGenerator) -> schemars::Schema {
208    let output = g.subschema_for::<Output>();
209    schemars::json_schema!({
210        "oneOf": [output, {"type": "array", "minItems": 1, "items": output}]
211    })
212}
213
214fn set_queries(_: &mut schemars::SchemaGenerator) -> schemars::Schema {
215    schemars::json_schema!({
216        "type": "array",
217        "items": {
218            "description": "A query of this Set, by name, or with its own settings.",
219            "oneOf": [
220                {"type": "string"},
221                {
222                    "type": "object",
223                    "description": "A query with settings.",
224                    "properties": {
225                        "query": {"type": "string", "description": "The query's name."},
226                        "tab": {"type": "boolean", "description": "Whether the query makes a tab."},
227                        "tab_name": {"type": "string", "description": "The tab name."},
228                        "on_empty": {"enum": ["continue", "skip", "fail"], "description": "When this query returns no rows: keep its empty tab, leave it out, or fail the run."}
229                    },
230                    "required": ["query"],
231                    "additionalProperties": true
232                }
233            ]
234        }
235    })
236}
237
238/// How a report's result is written and where it goes. Besides the keys below, each format takes its own options (for example `delimiter` for `delimited`, `columns` for `fixed_width`, `text` for `message`); they are documented with the formats.
239// Outputs are layered (the built-in default, `default_output`, each folder's `+output`, the
240// report's and a Set's `output`) and read once merged.
241#[derive(Deserialize, JsonSchema)]
242#[schemars(rename = "output", extend("additionalProperties" = true))]
243pub struct Output {
244    /// Names the output so other outputs and Set overrides can refer to it (`outputs.<name>` in a message, `attach:`). Also the default file name (`<name>.<ext>`). Unique within the report.
245    #[schemars(regex(pattern = "^[A-Za-z_][A-Za-z0-9_]*$"))]
246    pub name: Option<Loose<String>>,
247    /// The output format: `message` (built in: a short headline rendered from the results), or `csv`, `delimited`, `fixed_width`, `parquet` or `xlsx` (each a plugin). Default: `csv`, or the project's `default_output`.
248    pub format: Option<Loose<String>>,
249    /// Which of the report's queries this output formats. Default: all of them. Each query runs once, whatever the number of outputs.
250    #[schemars(length(min = 1))]
251    pub queries: Option<Loose<Vec<String>>>,
252    /// A Jinja expression over the results (`results.<query>.value < 0`); when it's false, the output is skipped and recorded as `skipped`.
253    #[serde(default)]
254    #[schemars(schema_with = "string_or_bool")]
255    pub when: Option<Loose<OneOf<String, bool>>>,
256    /// Where to deliver the file: one destination, or a list to deliver to several in one run. Default: the file stays in the target path.
257    #[serde(default)]
258    #[schemars(schema_with = "destination_or_list")]
259    pub destination: Option<Loose<OneOf<Destination, Vec<Loose<Destination>>>>>,
260    pub template: Option<Loose<Template>>,
261    /// One copy of the output per row of a driver query (`{query: members, key: member_id}`), each with its own slice of the results and the driver row as `each.*`; `false` turns an inherited one off. See docs/per-row-outputs.md.
262    #[serde(default)]
263    #[schemars(schema_with = "for_each_or_false")]
264    pub for_each: Option<Loose<OneOf<ForEach, bool>>>,
265    /// A per-row output's file name, with Jinja (`"{{ each.member_id }}_statement.pdf"`). Default: the row's key and the format's extension, under a folder named after the output.
266    pub file_name: Option<Loose<String>>,
267    /// When every query of the output returns no rows: `continue` (default) writes and delivers it empty, with a warning; `skip` writes and delivers nothing; `fail` fails the run. A query's own `on_empty` wins. See "When there's no data" in docs/building-reports.md.
268    pub on_empty: Option<Loose<crate::no_data::OnEmpty>>,
269    /// File extension for text formats (e.g. `aba`), instead of the format's own. `""` or `false` means none. Not for xlsx.
270    #[serde(default)]
271    #[schemars(schema_with = "extension")]
272    pub extension: Maybe<Loose<Option<OneOf<String, bool>>>>,
273    /// The format's own options.
274    #[serde(rename = "$unknown", default)]
275    #[schemars(skip)]
276    pub options: Map<serde_json::Value>,
277}
278
279/// Where a file is delivered: the name of a destination profile in `profiles.yml`, an optional `path`, and the options of that destination's plugin (e.g. `to`, `subject` and `body` for email). The built-in profile `local` copies the file to a local path.
280#[derive(Deserialize, JsonSchema)]
281#[schemars(rename = "destination", extend("additionalProperties" = true))]
282pub struct Destination {
283    /// The destination profile in `profiles.yml` (under `destinations:`) to deliver with. `local` is built in. It uses its entry for the run (`--target`, `DRE_TARGET`, else the profile's own `target:`, else `dev`); a missing entry is an error, and an entry `{deliver: false}` delivers nowhere. May use Jinja with `var()`, `env_var()`, `run.*` and `target.name`.
284    #[schemars(required)]
285    pub profile: Option<Loose<String>>,
286    /// Where to put the file: a path, or a URL such as `s3://bucket/key`, depending on the destination. Rendered with Jinja, so it can use `var()`, `run.*`, macros and `destination.*` (this destination's settings).
287    pub path: Option<Loose<String>>,
288    /// On a message output's entry, for a destination that takes messages and files (`slack`, `email`): other outputs of the report whose files go with the message.
289    #[serde(default)]
290    #[schemars(schema_with = "attach")]
291    pub attach: Option<Loose<OneOf<String, Vec<String>>>>,
292    /// Hold this delivery: the output is rendered and every other destination delivered, and this one waits for `dre release`. `dre run --hold` holds every destination.
293    pub hold: Option<Loose<bool>>,
294    /// At most this many deliveries to this destination per second, minute or hour (`100/minute`, `5/second`, `20000/hour`), spaced evenly: `60/minute` sends one a second. For `dre run` and `dre release`; `--rate` overrides it.
295    #[schemars(regex(pattern = "^\\s*[0-9_]+\\s*/\\s*[A-Za-z]+\\s*$"))]
296    pub rate: Option<Loose<String>>,
297    /// With `rate`: how many deliveries may go back to back while keeping the same average. Default: 1 (evenly spaced).
298    #[schemars(range(min = 1))]
299    pub burst: Option<Loose<u64>>,
300    /// The destination plugin's options.
301    #[serde(rename = "$unknown", default)]
302    #[schemars(skip)]
303    pub options: Map<serde_json::Value>,
304}
305
306/// One copy of the output per row of a driver query (a per-row output): each copy gets only its row's slice of the results, and the driver row as `each.<column>` in every template of the output. `false` turns an inherited `for_each` off.
307#[derive(Deserialize, JsonSchema)]
308#[schemars(rename = "for_each", deny_unknown_fields)]
309pub struct ForEach {
310    /// The driver: a query of the report, one row per copy of the output. It isn't a tab or section of the output itself.
311    #[schemars(required)]
312    pub query: Option<Loose<String>>,
313    /// The column (or list of columns) that identifies a row, in the driver and in every query of the output. Use an opaque id, never an email or a name: keys appear in file names and logs.
314    #[schemars(required)]
315    #[serde(default)]
316    #[schemars(schema_with = "string_or_strings")]
317    pub key: Option<Loose<OneOf<String, Vec<String>>>>,
318    /// How many rows render and deliver at once. Default: 4. `--row-concurrency` and `DRE_ROW_CONCURRENCY` override it.
319    #[schemars(range(min = 1))]
320    pub concurrency: Option<Loose<u64>>,
321    /// `continue` (default): a failed row is recorded and the others carry on; the run ends failed. `fail`: render every row first, and deliver only if all rendered.
322    pub on_row_error: Option<Loose<crate::project::RowErrors>>,
323    /// Rows of a query whose key isn't in the driver: `warn` (default) or `fail`.
324    pub on_orphan_rows: Option<Loose<crate::project::OrphanRows>>,
325    /// The most rows across the output's queries before anything renders. Default: 5,000,000.
326    #[schemars(range(min = 1))]
327    pub max_population_rows: Option<Loose<u64>>,
328    /// Keep the run's query results in its run folder, for `--retry-failed`. Default: true.
329    pub keep_results: Option<Loose<bool>>,
330    /// Mask destination values rendered from `each.*` (addresses, paths) in the console, logs and results. Default: the project's `mask_row_values`, true.
331    pub mask_row_values: Option<Loose<bool>>,
332}
333
334fn string_or_strings(_: &mut schemars::SchemaGenerator) -> schemars::Schema {
335    schemars::json_schema!({
336        "oneOf": [
337            {"type": "string"},
338            {"type": "array", "items": {"type": "string"}, "minItems": 1}
339        ]
340    })
341}
342
343fn for_each_or_false(g: &mut schemars::SchemaGenerator) -> schemars::Schema {
344    let f = g.subschema_for::<ForEach>();
345    schemars::json_schema!({"oneOf": [f, {"const": false}]})
346}
347
348/// The template an xlsx output fills (a branded workbook, instead of a new one), or an html or pdf output renders (a Jinja HTML + CSS file; see the document plugin).
349#[derive(Deserialize, JsonSchema)]
350#[schemars(rename = "template", deny_unknown_fields)]
351pub struct Template {
352    /// The template file (`.xlsx` for xlsx, `.html` for html and pdf): a bare file name, found next to the report's YAML, then in each parent folder, then anywhere in the project (it must be unique); or a path with `/`, relative to the project root.
353    #[schemars(required)]
354    pub file: Option<Loose<String>>,
355    /// xlsx only: where each query's data goes in the template. Default: none, so the template is copied as it is.
356    pub bindings: Option<Loose<Vec<Loose<TemplateBinding>>>>,
357}
358
359/// One block of data in an xlsx template: a table of a query's result, or a single cell.
360#[derive(Deserialize, JsonSchema)]
361#[schemars(deny_unknown_fields, inline)]
362pub struct TemplateBinding {
363    /// The template sheet to write into.
364    #[schemars(required)]
365    pub sheet: Option<Loose<String>>,
366    /// The query whose result goes here. Must be one of the Binding's queries.
367    pub query: Option<Loose<String>>,
368    /// Which result set of the query to use, counting from 1. Default: the last.
369    #[schemars(range(min = 1))]
370    pub result_index: Option<Loose<u64>>,
371    /// The top-left cell of a table block. A table block needs a `query`.
372    #[schemars(regex(pattern = "^[A-Za-z]{1,3}[0-9]+$"))]
373    pub anchor: Option<Loose<String>>,
374    /// Whether to write the column names above the data in a table block.
375    pub header: Option<Loose<bool>>,
376    /// The columns of the query to write in a table block, in order. Default: all.
377    pub columns: Option<Loose<Vec<String>>>,
378    /// Makes this a single-cell binding: the cell to write. Needs exactly one of `value`, or `query` with `column`.
379    #[schemars(regex(pattern = "^[A-Za-z]{1,3}[0-9]+$"))]
380    pub cell: Option<Loose<String>>,
381    /// A fixed value (rendered with Jinja) for a single-cell binding.
382    pub value: Option<Loose<String>>,
383    /// The column of the query's first row to write into a single-cell binding.
384    pub column: Option<Loose<String>>,
385    #[serde(rename = "$unknown", default)]
386    #[schemars(skip)]
387    pub unknown: UnknownKeys,
388}
389
390fn string_or_bool(_: &mut schemars::SchemaGenerator) -> schemars::Schema {
391    schemars::json_schema!({"type": ["string", "boolean"]})
392}
393
394fn extension(_: &mut schemars::SchemaGenerator) -> schemars::Schema {
395    // `null` is a value here (no extension), not schemars' "optional".
396    schemars::json_schema!({"type": ["string", "boolean", "null"], "x-dre-null": true})
397}
398
399fn destination_or_list(g: &mut schemars::SchemaGenerator) -> schemars::Schema {
400    let destination = g.subschema_for::<Destination>();
401    schemars::json_schema!({
402        "oneOf": [destination, {"type": "array", "minItems": 1, "items": destination}]
403    })
404}
405
406fn attach(_: &mut schemars::SchemaGenerator) -> schemars::Schema {
407    schemars::json_schema!({
408        "oneOf": [
409            {"type": "string"},
410            {"type": "array", "items": {"type": "string"}, "minItems": 1}
411        ]
412    })
413}
414
415fn queries(g: &mut schemars::SchemaGenerator) -> schemars::Schema {
416    let entry = g.subschema_for::<QueryEntry>();
417    schemars::json_schema!({
418        "type": "array",
419        "items": {
420            "oneOf": [
421                {"type": "string", "description": "The name of a `.sql` file under `reports/`, without extension."},
422                entry
423            ]
424        }
425    })
426}