-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
256 additions
and
56 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "codegenr" | ||
version = "0.0.4" | ||
version = "0.0.5" | ||
edition = "2021" | ||
authors = ["Jérôme Rx & contributors <[email protected]>"] | ||
description = "Fast json/yaml/openapi code generator based on handlebars templating." | ||
|
@@ -35,6 +35,7 @@ structopt = { version = "0.3", optional = true } | |
anyhow = { version = "1.0", optional = true } | ||
toml = { version = "0.8", optional = true } | ||
|
||
|
||
# ======================================================================================== | ||
# Common dependencies | ||
# ======================================================================================== | ||
|
@@ -45,17 +46,19 @@ thiserror = "1.0" | |
# File loading & path manipulations | ||
url = "2.4" | ||
path-dedot = "3.1" | ||
reqwest = { version = "0.11", features = ["blocking"] } | ||
reqwest = { version = "0.12", features = ["blocking"] } | ||
walkdir = "2" | ||
glob = "0.3" | ||
# Json / Yaml / OpenApi / Graphql manipulation | ||
|
||
# file formats manipulation | ||
serde_json = { version = "1.0", features = ["preserve_order"] } | ||
serde_yaml = "0.8" # 0.9 failing with deserializing from YAML containing more than one document is not supported on most files | ||
serde = "1.0" | ||
graphql-parser = "0.4" | ||
quick-xml = { version = "0.31", features = ["serialize"] } | ||
quickxml_to_serde = "0.5" | ||
quickxml_to_serde = "0.6" | ||
minidom = "0.12" | ||
csv = "1.2" | ||
|
||
# Templating | ||
handlebars = { version = "4.4", features = ["script_helper"] } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Username, Identifier,First name,Last name | ||
booker12,9012,Rachel,Booker | ||
grey07,2070,Laura,Grey | ||
johnson81,4081,Craig,Johnson | ||
jenkins46,9346,Mary,Jenkins | ||
smith79,5079,Jamie,Smith | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use super::DocumentLoader; | ||
use serde_json::Value; | ||
|
||
pub struct CsvLoader {} | ||
impl DocumentLoader for CsvLoader { | ||
type Error = csv::Error; | ||
fn json_from_str(content: &str) -> Result<Value, Self::Error> { | ||
let mut rdr = csv::Reader::from_reader(content.as_bytes()); | ||
let lines = rdr | ||
.records() | ||
.map(|result| { | ||
let record = result?; | ||
Ok(Value::Object( | ||
record | ||
.into_iter() | ||
.enumerate() | ||
.map(|(i, field)| (format!("field_{i}"), Value::String(field.into()))) | ||
.collect(), | ||
)) | ||
}) | ||
.collect::<Result<Vec<_>, Self::Error>>()?; | ||
Ok(Value::Array(lines)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters