extra derives are accidentally ignored (#105)

This commit is contained in:
Adam Leventhal 2022-07-02 22:28:06 -07:00 committed by GitHub
parent 1a3d4e600d
commit 6796e0c1ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 224 additions and 191 deletions

30
Cargo.lock generated
View File

@ -992,7 +992,7 @@ dependencies = [
"proc-macro2",
"quote",
"regex",
"rustfmt-wrapper 0.2.0",
"rustfmt-wrapper",
"schemars",
"serde",
"serde_json",
@ -1123,17 +1123,6 @@ dependencies = [
"winapi",
]
[[package]]
name = "rustfmt-wrapper"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7733577fb5b13c8b256232e7ca84aa424f915efae6ec980082d60a03f99da3f8"
dependencies = [
"tempfile",
"thiserror",
"toolchain_find",
]
[[package]]
name = "rustfmt-wrapper"
version = "0.2.0"
@ -1726,9 +1715,8 @@ checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642"
[[package]]
name = "typify"
version = "0.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "505f18fc847efc93b45a763f36f8099d3415dbfc6c0d6c3857a3012e20db92c7"
version = "0.0.10-dev"
source = "git+https://github.com/oxidecomputer/typify#48a1b6de2fe9af0230ee1080d8edcf741a8ccc5b"
dependencies = [
"typify-impl",
"typify-macro",
@ -1736,15 +1724,14 @@ dependencies = [
[[package]]
name = "typify-impl"
version = "0.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b572369a55be8402a5a7e24c721e8d895dbd58bf3d9dccb4b3619fcb926e7bde"
version = "0.0.10-dev"
source = "git+https://github.com/oxidecomputer/typify#48a1b6de2fe9af0230ee1080d8edcf741a8ccc5b"
dependencies = [
"heck",
"log",
"proc-macro2",
"quote",
"rustfmt-wrapper 0.1.0",
"rustfmt-wrapper",
"schemars",
"serde_json",
"syn",
@ -1754,9 +1741,8 @@ dependencies = [
[[package]]
name = "typify-macro"
version = "0.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a615bfbbcf929b1733898d2afe00c83dbf8756f8028aa42c156c3c2713b0f03b"
version = "0.0.10-dev"
source = "git+https://github.com/oxidecomputer/typify#48a1b6de2fe9af0230ee1080d8edcf741a8ccc5b"
dependencies = [
"proc-macro2",
"quote",

View File

@ -14,3 +14,7 @@ members = [
#[patch.crates-io]
#typify = { path = "../typify/typify" }
#rustfmt-wrapper = { path = "../rustfmt-wrapper" }
# Latest typify (this can be deleted when typify is updated)
[patch.crates-io]
typify = { git = "https://github.com/oxidecomputer/typify" }

View File

@ -20,7 +20,7 @@ serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
syn = { version = "1.0", features = ["parsing"] }
thiserror = "1.0"
typify = "0.0.9"
typify = "0.0.10-dev"
unicode-ident = "1.0.0"
[dev-dependencies]

View File

@ -131,6 +131,10 @@ impl Generator {
self.type_space.set_type_mod("types");
self.type_space.add_ref_types(schemas)?;
self.settings
.extra_derives
.iter()
.for_each(|derive| self.type_space.add_derive(derive.clone()));
let raw_methods = spec
.paths

View File

@ -3,7 +3,7 @@ use progenitor_client::encode_path;
pub use progenitor_client::{ByteStream, Error, ResponseValue};
pub mod types {
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone, JsonSchema)]
pub struct Task {
pub id: String,
pub name: String,
@ -12,7 +12,7 @@ pub mod types {
pub state: String,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone, JsonSchema)]
pub struct TaskEvent {
pub payload: String,
pub seq: u32,
@ -20,14 +20,14 @@ pub mod types {
pub time: chrono::DateTime<chrono::offset::Utc>,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone, JsonSchema)]
pub struct TaskOutput {
pub id: String,
pub path: String,
pub size: u64,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone, JsonSchema)]
pub struct TaskSubmit {
pub name: String,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
@ -35,35 +35,35 @@ pub mod types {
pub script: String,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone, JsonSchema)]
pub struct TaskSubmitResult {
pub id: String,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone, JsonSchema)]
pub struct UploadedChunk {
pub id: String,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone, JsonSchema)]
pub struct UserCreate {
pub name: String,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone, JsonSchema)]
pub struct UserCreateResult {
pub id: String,
pub name: String,
pub token: String,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone, JsonSchema)]
pub struct WhoamiResult {
pub id: String,
pub name: String,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone, JsonSchema)]
pub struct Worker {
pub deleted: bool,
pub id: String,
@ -75,58 +75,58 @@ pub mod types {
pub tasks: Vec<WorkerTask>,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone, JsonSchema)]
pub struct WorkerAddOutput {
pub chunks: Vec<String>,
pub path: String,
pub size: i64,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone, JsonSchema)]
pub struct WorkerAppendTask {
pub payload: String,
pub stream: String,
pub time: chrono::DateTime<chrono::offset::Utc>,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone, JsonSchema)]
pub struct WorkerBootstrap {
pub bootstrap: String,
pub token: String,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone, JsonSchema)]
pub struct WorkerBootstrapResult {
pub id: String,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone, JsonSchema)]
pub struct WorkerCompleteTask {
pub failed: bool,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone, JsonSchema)]
pub struct WorkerPingResult {
pub poweroff: bool,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub task: Option<WorkerPingTask>,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone, JsonSchema)]
pub struct WorkerPingTask {
pub id: String,
pub output_rules: Vec<String>,
pub script: String,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone, JsonSchema)]
pub struct WorkerTask {
pub id: String,
pub name: String,
pub owner: String,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone, JsonSchema)]
pub struct WorkersResult {
pub workers: Vec<Worker>,
}

View File

@ -3,31 +3,31 @@ use progenitor_client::encode_path;
pub use progenitor_client::{ByteStream, Error, ResponseValue};
pub mod types {
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone, JsonSchema)]
pub struct EnrolBody {
pub host: String,
pub key: String,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone, JsonSchema)]
pub struct GlobalJobsResult {
pub summary: Vec<ReportSummary>,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone, JsonSchema)]
pub struct OutputRecord {
pub msg: String,
pub stream: String,
pub time: chrono::DateTime<chrono::offset::Utc>,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone, JsonSchema)]
pub struct PingResult {
pub host: String,
pub ok: bool,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone, JsonSchema)]
pub struct ReportFinishBody {
pub duration_millis: i32,
pub end_time: chrono::DateTime<chrono::offset::Utc>,
@ -35,7 +35,7 @@ pub mod types {
pub id: ReportId,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone, JsonSchema)]
pub struct ReportId {
pub host: String,
pub job: String,
@ -44,25 +44,25 @@ pub mod types {
pub uuid: String,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone, JsonSchema)]
pub struct ReportOutputBody {
pub id: ReportId,
pub record: OutputRecord,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone, JsonSchema)]
pub struct ReportResult {
pub existed_already: bool,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone, JsonSchema)]
pub struct ReportStartBody {
pub id: ReportId,
pub script: String,
pub start_time: chrono::DateTime<chrono::offset::Utc>,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone, JsonSchema)]
pub struct ReportSummary {
pub age_seconds: i32,
pub duration_seconds: i32,

View File

@ -708,7 +708,7 @@ pub mod types {
///The Instance to which the interface belongs.
pub instance_id: uuid::Uuid,
///The IP address assigned to this interface.
pub ip: String,
pub ip: std::net::IpAddr,
///The MAC address assigned to this interface.
pub mac: MacAddr,
///unique, mutable, user-controlled identifier for each resource
@ -731,7 +731,7 @@ pub mod types {
///The IP address for the interface. One will be auto-assigned if not
/// provided.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub ip: Option<String>,
pub ip: Option<std::net::IpAddr>,
pub name: Name,
///The VPC Subnet in which to create the interface.
pub subnet_name: Name,
@ -986,7 +986,7 @@ pub mod types {
pub enum RouteDestination {
///Route applies to traffic destined for a specific IP address
#[serde(rename = "ip")]
Ip(String),
Ip(std::net::IpAddr),
///Route applies to traffic destined for a specific IP subnet
#[serde(rename = "ip_net")]
IpNet(IpNet),
@ -1005,7 +1005,7 @@ pub mod types {
pub enum RouteTarget {
///Forward traffic to a particular IP address.
#[serde(rename = "ip")]
Ip(String),
Ip(std::net::IpAddr),
///Forward traffic to a VPC
#[serde(rename = "vpc")]
Vpc(Name),
@ -1529,7 +1529,7 @@ pub mod types {
Instance(Name),
///The rule applies to traffic from/to a specific IP address
#[serde(rename = "ip")]
Ip(String),
Ip(std::net::IpAddr),
///The rule applies to traffic from/to a specific IP subnet
#[serde(rename = "ip_net")]
IpNet(IpNet),
@ -1589,7 +1589,7 @@ pub mod types {
Instance(Name),
///The rule applies to a specific IP address
#[serde(rename = "ip")]
Ip(String),
Ip(std::net::IpAddr),
///The rule applies to a specific IP subnet
#[serde(rename = "ip_net")]
IpNet(IpNet),

File diff suppressed because it is too large Load Diff

View File

@ -708,7 +708,7 @@ pub mod types {
///The Instance to which the interface belongs.
pub instance_id: uuid::Uuid,
///The IP address assigned to this interface.
pub ip: String,
pub ip: std::net::IpAddr,
///The MAC address assigned to this interface.
pub mac: MacAddr,
///unique, mutable, user-controlled identifier for each resource
@ -731,7 +731,7 @@ pub mod types {
///The IP address for the interface. One will be auto-assigned if not
/// provided.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub ip: Option<String>,
pub ip: Option<std::net::IpAddr>,
pub name: Name,
///The VPC Subnet in which to create the interface.
pub subnet_name: Name,
@ -986,7 +986,7 @@ pub mod types {
pub enum RouteDestination {
///Route applies to traffic destined for a specific IP address
#[serde(rename = "ip")]
Ip(String),
Ip(std::net::IpAddr),
///Route applies to traffic destined for a specific IP subnet
#[serde(rename = "ip_net")]
IpNet(IpNet),
@ -1005,7 +1005,7 @@ pub mod types {
pub enum RouteTarget {
///Forward traffic to a particular IP address.
#[serde(rename = "ip")]
Ip(String),
Ip(std::net::IpAddr),
///Forward traffic to a VPC
#[serde(rename = "vpc")]
Vpc(Name),
@ -1529,7 +1529,7 @@ pub mod types {
Instance(Name),
///The rule applies to traffic from/to a specific IP address
#[serde(rename = "ip")]
Ip(String),
Ip(std::net::IpAddr),
///The rule applies to traffic from/to a specific IP subnet
#[serde(rename = "ip_net")]
IpNet(IpNet),
@ -1589,7 +1589,7 @@ pub mod types {
Instance(Name),
///The rule applies to a specific IP address
#[serde(rename = "ip")]
Ip(String),
Ip(std::net::IpAddr),
///The rule applies to a specific IP subnet
#[serde(rename = "ip_net")]
IpNet(IpNet),

View File

@ -24,7 +24,8 @@ fn verify_apis(openapi_file: &str) {
let mut generator = Generator::new(
GenerationSettings::default()
.with_interface(InterfaceStyle::Builder)
.with_tag(TagStyle::Merged),
.with_tag(TagStyle::Merged)
.with_derive(quote::quote! {JsonSchema}),
);
let output = generator.generate_text_normalize_comments(&spec).unwrap();
expectorate::assert_contents(