Add object name in jsonsample environment

This commit is contained in:
Pierre Hubert 2023-03-01 14:38:48 +01:00
parent 536125a4f4
commit d6d0b10537
3 changed files with 6 additions and 3 deletions

2
Cargo.lock generated
View File

@ -458,7 +458,7 @@ checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66"
[[package]]
name = "openapi-parser"
version = "0.6.0"
version = "0.6.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.6.0"
version = "0.6.1"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -208,7 +208,10 @@ fn tex_export(tree: &TreeNode) -> String {
// JSON export
out.push_str(&format!("\\newsavebox{{{box_name}}}\n"));
out.push_str(&format!("\\begin{{lrbox}}{{{box_name}}}\n"));
out.push_str("\\begin{jsonsample}\n");
out.push_str(&format!(
"\\begin{{jsonsample}}{{{}}}\n",
tex_escape_str(&tree.name)
));
out.push_str("\\begin{lstlisting}[language=json]\n");
let json_doc = serde_json::to_string_pretty(&tree.example_value(1)).unwrap();
let replace_key = serde_json::to_string(REF_OBJECT).unwrap();