Compare commits
3 Commits
805b46e164
...
88472ba02f
| Author | SHA1 | Date | |
|---|---|---|---|
| 88472ba02f | |||
| 87f942e440 | |||
| 07a955e654 |
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -224,7 +224,7 @@ checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66"
|
||||
|
||||
[[package]]
|
||||
name = "openapi-parser"
|
||||
version = "0.3.0"
|
||||
version = "0.4.1"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"env_logger",
|
||||
|
||||
@@ -4,7 +4,7 @@ description = "Extract schemas definitions tree from OpenAPI documents"
|
||||
authors = ["Pierre Hubert <pierre.hubert.git@communiquons.org>"]
|
||||
license = "MIT"
|
||||
repository = "https://gitea.communiquons.org/pierre/OpenAPI-Parser"
|
||||
version = "0.4.0"
|
||||
version = "0.4.1"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
22
src/main.rs
22
src/main.rs
@@ -138,10 +138,28 @@ fn tex_export_inner(tree: &ObjectChild, out: &mut String, required: bool) {
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
fn tex_adapt_name(i: &str) -> String {
|
||||
i.replace('0', "zero")
|
||||
.replace('1', "one")
|
||||
.replace('2', "two")
|
||||
.replace('3', "three")
|
||||
.replace('4', "four")
|
||||
.replace('5', "five")
|
||||
.replace('6', "six")
|
||||
.replace('7', "seven")
|
||||
.replace('8', "height")
|
||||
.replace('9', "nine")
|
||||
}
|
||||
|
||||
fn tex_export(tree: &TreeNode) -> String {
|
||||
let mut out = String::new();
|
||||
writeln!(out, "% START OF EXPORT OF SCHEMA {}", tree.name).unwrap();
|
||||
writeln!(out, "\\newcommand{{\\schemadef{}}}{{", tree.name).unwrap();
|
||||
writeln!(
|
||||
out,
|
||||
"\\newcommand{{\\schemadef{}}}{{",
|
||||
tex_adapt_name(&tree.name)
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
match &tree.r#type {
|
||||
NodeType::Object { children, required } => {
|
||||
@@ -156,6 +174,7 @@ fn tex_export(tree: &TreeNode) -> String {
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
out.push_str("\\begin{schemaprops}\n");
|
||||
for child in children {
|
||||
tex_export_inner(
|
||||
child,
|
||||
@@ -166,6 +185,7 @@ fn tex_export(tree: &TreeNode) -> String {
|
||||
.unwrap_or(false),
|
||||
);
|
||||
}
|
||||
out.push_str("\\end{schemaprops}\n");
|
||||
}
|
||||
_ => tex_export_inner(
|
||||
&ObjectChild {
|
||||
|
||||
Reference in New Issue
Block a user