update for typify (#13)

This commit is contained in:
Adam Leventhal 2021-11-02 11:16:55 -07:00 committed by GitHub
parent 7934be90b9
commit 05dcf08091
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 59 additions and 61 deletions

77
Cargo.lock generated
View File

@ -37,9 +37,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]] [[package]]
name = "bumpalo" name = "bumpalo"
version = "3.7.1" version = "3.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9df67f7bf9ef8498769f994239c45613ef0c5899415fb58e9add412d2c1a538" checksum = "8f1e260c3a9040a7c19a12468758f4c16f31a81a1fe087482be9570ec864bb6c"
[[package]] [[package]]
name = "bytes" name = "bytes"
@ -115,9 +115,9 @@ checksum = "ee2626afccd7561a06cf1367e2950c4718ea04565e20fb5029b6c7d8ad09abcf"
[[package]] [[package]]
name = "encoding_rs" name = "encoding_rs"
version = "0.8.28" version = "0.8.29"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "80df024fbc5ac80f87dfef0d9f5209a252f2a497f7f42944cff24d8253cac065" checksum = "a74ea89a0a1b98f6332de42c95baff457ada66d1cb4030f9ff151b2041a1c746"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
] ]
@ -252,9 +252,9 @@ dependencies = [
[[package]] [[package]]
name = "h2" name = "h2"
version = "0.3.6" version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c06815895acec637cd6ed6e9662c935b866d20a106f8361892893a7d9234964" checksum = "7fd819562fcebdac5afc5c113c3ec36f902840b70fd4fc458799c8ce4607ae55"
dependencies = [ dependencies = [
"bytes", "bytes",
"fnv", "fnv",
@ -297,9 +297,9 @@ dependencies = [
[[package]] [[package]]
name = "http-body" name = "http-body"
version = "0.4.3" version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "399c583b2979440c60be0821a6199eca73bc3c8dcd9d070d75ac726e2c6186e5" checksum = "1ff4f84919677303da5f147645dbea6b1881f368d03ac84e1dc09031ebd7b2c6"
dependencies = [ dependencies = [
"bytes", "bytes",
"http", "http",
@ -320,9 +320,9 @@ checksum = "6456b8a6c8f33fee7d958fcd1b60d55b11940a79e63ae87013e6d22e26034440"
[[package]] [[package]]
name = "hyper" name = "hyper"
version = "0.14.13" version = "0.14.14"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "15d1cfb9e4f68655fa04c01f59edb405b6074a0f7118ea881e5026e4a1cd8593" checksum = "2b91bb1f221b6ea1f1e4371216b70f40748774c2fb5971b450c07773fb92d26b"
dependencies = [ dependencies = [
"bytes", "bytes",
"futures-channel", "futures-channel",
@ -406,9 +406,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.103" version = "0.2.106"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd8f7255a17a627354f321ef0055d63b898c6fb27eff628af4d1b66b7331edf6" checksum = "a60553f9a9e039a333b4e9b20573b9e9b9c0bb3a11e201ccc48ef4283456d673"
[[package]] [[package]]
name = "linked-hash-map" name = "linked-hash-map"
@ -445,9 +445,9 @@ checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d"
[[package]] [[package]]
name = "mio" name = "mio"
version = "0.7.13" version = "0.7.14"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c2bdb6314ec10835cd3293dd268473a835c02b7b352e788be788b3c6ca6bb16" checksum = "8067b404fe97c70829f082dec8bcf4f71225d7eaea1d8645349cb76fa06205cc"
dependencies = [ dependencies = [
"libc", "libc",
"log", "log",
@ -537,9 +537,9 @@ dependencies = [
[[package]] [[package]]
name = "openssl" name = "openssl"
version = "0.10.36" version = "0.10.38"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d9facdb76fec0b73c406f125d44d86fdad818d66fef0531eec9233ca425ff4a" checksum = "0c7ae222234c30df141154f159066c5093ff73b63204dcda7121eb082fc56a95"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"cfg-if", "cfg-if",
@ -557,9 +557,9 @@ checksum = "28988d872ab76095a6e6ac88d99b54fd267702734fd7ffe610ca27f533ddb95a"
[[package]] [[package]]
name = "openssl-sys" name = "openssl-sys"
version = "0.9.67" version = "0.9.70"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69df2d8dfc6ce3aaf44b40dec6f487d5a886516cf6879c49e98e0710f310a058" checksum = "c6517987b3f8226b5da3661dad65ff7f300cc59fb5ea8333ca191fc65fde3edf"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"cc", "cc",
@ -597,15 +597,15 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
[[package]] [[package]]
name = "pkg-config" name = "pkg-config"
version = "0.3.20" version = "0.3.22"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c9b1041b4387893b91ee6746cddfc28516aff326a3519fb2adf820932c5e6cb" checksum = "12295df4f294471248581bc09bef3c38a5e46f1e36d6a37353621a0c6c357e1f"
[[package]] [[package]]
name = "ppv-lite86" name = "ppv-lite86"
version = "0.2.14" version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3ca011bd0129ff4ae15cd04c4eef202cadf6c51c21e47aba319b4e0501db741" checksum = "ed0cfbc8191465bed66e1718596ee0b0b35d5ee1f41c5df2189d0fe8bde535ba"
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
@ -974,9 +974,9 @@ dependencies = [
[[package]] [[package]]
name = "syn" name = "syn"
version = "1.0.80" version = "1.0.81"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d010a1623fbd906d51d650a9916aaefc05ffa0e4053ff7fe601167f3e715d194" checksum = "f2afee18b8beb5a596ecb4a2dce128c719b4ba399d34126b9e4396e3f9860966"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -1019,12 +1019,11 @@ dependencies = [
[[package]] [[package]]
name = "time" name = "time"
version = "0.1.44" version = "0.1.43"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438"
dependencies = [ dependencies = [
"libc", "libc",
"wasi",
"winapi", "winapi",
] ]
@ -1045,9 +1044,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
[[package]] [[package]]
name = "tokio" name = "tokio"
version = "1.12.0" version = "1.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2c2416fdedca8443ae44b4527de1ea633af61d8f7169ffa6e72c5b53d24efcc" checksum = "588b2d10a336da58d877567cd8fb8a14b463e2104910f8132cd054b4b96e29ee"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"bytes", "bytes",
@ -1070,9 +1069,9 @@ dependencies = [
[[package]] [[package]]
name = "tokio-util" name = "tokio-util"
version = "0.6.8" version = "0.6.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08d3725d3efa29485e87311c5b699de63cde14b00ed4d256b8318aa30ca452cd" checksum = "9e99e1983e5d376cd8eb4b66604d2e99e79f5bd988c3055891dcd8c9e2604cc0"
dependencies = [ dependencies = [
"bytes", "bytes",
"futures-core", "futures-core",
@ -1129,8 +1128,8 @@ checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642"
[[package]] [[package]]
name = "typify" name = "typify"
version = "0.0.1" version = "0.0.2"
source = "git+https://github.com/oxidecomputer/typify#6de8074425c1c0090a85efc6115dfa4605d123e6" source = "git+https://github.com/oxidecomputer/typify#70755a9c18e91d0f4c591219a8f655ae6ccb1154"
dependencies = [ dependencies = [
"typify-impl", "typify-impl",
"typify-macro", "typify-macro",
@ -1138,8 +1137,8 @@ dependencies = [
[[package]] [[package]]
name = "typify-impl" name = "typify-impl"
version = "0.0.1" version = "0.0.2"
source = "git+https://github.com/oxidecomputer/typify#6de8074425c1c0090a85efc6115dfa4605d123e6" source = "git+https://github.com/oxidecomputer/typify#70755a9c18e91d0f4c591219a8f655ae6ccb1154"
dependencies = [ dependencies = [
"convert_case", "convert_case",
"proc-macro2", "proc-macro2",
@ -1152,8 +1151,8 @@ dependencies = [
[[package]] [[package]]
name = "typify-macro" name = "typify-macro"
version = "0.0.1" version = "0.0.2"
source = "git+https://github.com/oxidecomputer/typify#6de8074425c1c0090a85efc6115dfa4605d123e6" source = "git+https://github.com/oxidecomputer/typify#70755a9c18e91d0f4c591219a8f655ae6ccb1154"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -1247,9 +1246,9 @@ dependencies = [
[[package]] [[package]]
name = "wasi" name = "wasi"
version = "0.10.0+wasi-snapshot-preview1" version = "0.10.2+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
[[package]] [[package]]
name = "wasm-bindgen" name = "wasm-bindgen"

View File

@ -14,3 +14,6 @@ default-members = [
"progenitor-impl", "progenitor-impl",
"progenitor-macro", "progenitor-macro",
] ]
#[patch."https://github.com/oxidecomputer/typify"]
#typify = { path = "../typify/typify" }

View File

@ -100,12 +100,7 @@ impl Generator {
let mut types = self let mut types = self
.type_space .type_space
.iter_types() .iter_types()
.map(|type_entry| { .map(|t| (t.name(), t.definition()))
(
type_entry.type_name(&self.type_space),
type_entry.output(&self.type_space),
)
})
.collect::<Vec<_>>(); .collect::<Vec<_>>();
types.sort_by(|(a_name, _), (b_name, _)| a_name.cmp(b_name)); types.sort_by(|(a_name, _), (b_name, _)| a_name.cmp(b_name));
let types = types.into_iter().map(|(_, def)| def); let types = types.into_iter().map(|(_, def)| def);
@ -228,8 +223,8 @@ impl Generator {
); );
let typ = self let typ = self
.type_space .type_space
.add_type_details_with_name(&schema, Some(name))? .add_type_with_name(&schema, Some(name))?
.parameter; .parameter_ident();
Ok((ParamType::Path, nam, typ)) Ok((ParamType::Path, nam, typ))
} }
@ -260,8 +255,8 @@ impl Generator {
let typ = self let typ = self
.type_space .type_space
.add_type_details_with_name(&schema, Some(name))? .add_type_with_name(&schema, Some(name))?
.parameter; .parameter_ident();
query.push((nam.to_string(), !parameter_data.required)); query.push((nam.to_string(), !parameter_data.required));
Ok((ParamType::Query, nam, typ)) Ok((ParamType::Query, nam, typ))
@ -293,8 +288,8 @@ impl Generator {
); );
let typ = self let typ = self
.type_space .type_space
.add_type_details_with_name(&schema, Some(name))? .add_type_with_name(&schema, Some(name))?
.parameter; .parameter_ident();
(Some(typ), Some(quote! { .json(body) })) (Some(typ), Some(quote! { .json(body) }))
} else { } else {
todo!("media type encoding, no schema: {:#?}", mt); todo!("media type encoding, no schema: {:#?}", mt);
@ -375,11 +370,11 @@ impl Generator {
) )
); );
self.type_space self.type_space
.add_type_details_with_name( .add_type_with_name(
&schema, &schema,
Some(name), Some(name),
)? )?
.ident .ident()
} else { } else {
todo!( todo!(
"media type encoding, no schema: {:#?}", "media type encoding, no schema: {:#?}",
@ -515,20 +510,21 @@ impl Generator {
pub fn dependencies(&self) -> Vec<String> { pub fn dependencies(&self) -> Vec<String> {
let mut deps = vec![ let mut deps = vec![
"anyhow = \"1.0.44\"", "anyhow = \"1.0\"",
"percent-encoding = \"2.1.0\"", "percent-encoding = \"2.1\"",
"serde = { version = \"1.0.130\", features = [\"derive\"] }", "serde = { version = \"1.0\", features = [\"derive\"] }",
"reqwest = { version = \"0.11.5\", features = [\"json\", \"stream\"] }", "reqwest = { version = \"0.11\", features = [\"json\", \"stream\"] }",
]; ];
if self.type_space.uses_uuid() { if self.type_space.uses_uuid() {
deps.push( deps.push(
"uuid = { version = \"0.8.2\", features = [\"serde\", \"v4\"] }", "uuid = { version = \"0.8\", features = [\"serde\", \"v4\"] }",
) )
} }
if self.type_space.uses_chrono() { if self.type_space.uses_chrono() {
deps.push( deps.push("chrono = { version = \"0.4\", features = [\"serde\"] }")
"chrono = { version = \"0.4.19\", features = [\"serde\"] }", }
) if self.type_space.uses_serde_json() {
deps.push("serde_json = \"1.0\"")
} }
deps.sort_unstable(); deps.sort_unstable();
deps.iter().map(ToString::to_string).collect() deps.iter().map(ToString::to_string).collect()