Compare commits

...

3 Commits

Author SHA1 Message Date
88472ba02f Add useful environments 2023-02-06 10:14:50 +01:00
87f942e440 Bump version 2023-02-06 10:04:09 +01:00
07a955e654 Fix issue with numbers 2023-02-06 10:03:51 +01:00
3 changed files with 23 additions and 3 deletions

2
Cargo.lock generated
View File

@@ -224,7 +224,7 @@ checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66"
[[package]]
name = "openapi-parser"
version = "0.3.0"
version = "0.4.1"
dependencies = [
"clap",
"env_logger",

View File

@@ -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

View File

@@ -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 {