feat(openapi): the OpenAPI document, and the paperwork the crate shipped without
`Cargo.toml` has declared `license = "MIT"` since the first release and the published crate carried no license text, so anyone vendoring the source had the claim without the grant. `LICENSE` is that text. `DCO` is the certificate the README has been requiring a sign-off against without shipping, and `CONTRIBUTING.md` says how — including that GitHub is a mirror of `main` and tags, so a pull request there is carried upstream by a maintainer rather than merged, which would put the two forges out of sync. `CHANGELOG.md` reconstructs 26.7.0 and 26.8.0-beta.0 from their tags. The CLI ships on its own version line, so the header says what that does and does not mean about the core version a scaffold is pinned to, and each entry says when that pin moved. `matcha openapi` prints core's structural OpenAPI 3.1 for the route table — `--title`, `--api-version`, `--out`. It reuses the entry resolution and the generated-script runner that `graph` and `explain` already had, so it is the same `app.ready()` that resolves the graph without booting providers. Structural is the honest word: paths, methods and parameters come from the decorators, and nothing invents a response schema. The loose end from the capability table is closed. `cli.rs` still carried its own copies of the `create` kinds and the `add` capabilities, so adding either meant editing two files that could disagree — a value the parser accepts and the dispatcher rejects. Both now read the list from the module that owns it, and the three `create` piece kinds became rows in a table rather than near-identical match arms, which also retires a `too_many_arguments` allow. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
12 files changed
+542
-47
No files matched your search
@@ -81,6 +81,42 @@ console.log(lines.join('\n'));"#
|
||||
emit(dir, entry_override, out, &body)
|
||||
}
|
||||
|
||||
/// `matcha openapi` — the structural OpenAPI 3.1 document for the route table.
|
||||
///
|
||||
/// Structural is the honest word for it: green-tea derives paths, methods and
|
||||
/// parameters from the decorators, which is everything the graph knows. It does
|
||||
/// not invent response schemas, so what comes out describes the surface rather
|
||||
/// than the payloads.
|
||||
pub fn openapi(
|
||||
dir: &Path,
|
||||
title: Option<&str>,
|
||||
version: Option<&str>,
|
||||
entry_override: Option<&str>,
|
||||
out: Option<&str>,
|
||||
) -> std::io::Result<()> {
|
||||
// `app.openapi()` takes an optional info object; passing nothing lets core
|
||||
// apply its own defaults rather than having the CLI invent a title.
|
||||
let info = match (title, version) {
|
||||
(None, None) => String::new(),
|
||||
(t, v) => {
|
||||
let mut fields = Vec::new();
|
||||
if let Some(t) = t {
|
||||
fields.push(format!("title: {}", js_string(t)));
|
||||
}
|
||||
if let Some(v) = v {
|
||||
fields.push(format!("version: {}", js_string(v)));
|
||||
}
|
||||
format!("{{ {} }}", fields.join(", "))
|
||||
}
|
||||
};
|
||||
emit(
|
||||
dir,
|
||||
entry_override,
|
||||
out,
|
||||
&format!("console.log(JSON.stringify(app.openapi({info}), null, 2));"),
|
||||
)
|
||||
}
|
||||
|
||||
/// Resolves the entry, generates the script around `body`, runs it under the
|
||||
/// detected runtime, and routes its stdout to a file or to ours.
|
||||
fn emit(
|
||||
|
||||
Reference in new issue
Block a user