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

View File

@ -14,3 +14,7 @@ members = [
#[patch.crates-io] #[patch.crates-io]
#typify = { path = "../typify/typify" } #typify = { path = "../typify/typify" }
#rustfmt-wrapper = { path = "../rustfmt-wrapper" } #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" serde_json = "1.0"
syn = { version = "1.0", features = ["parsing"] } syn = { version = "1.0", features = ["parsing"] }
thiserror = "1.0" thiserror = "1.0"
typify = "0.0.9" typify = "0.0.10-dev"
unicode-ident = "1.0.0" unicode-ident = "1.0.0"
[dev-dependencies] [dev-dependencies]

View File

@ -131,6 +131,10 @@ impl Generator {
self.type_space.set_type_mod("types"); self.type_space.set_type_mod("types");
self.type_space.add_ref_types(schemas)?; 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 let raw_methods = spec
.paths .paths

View File

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

View File

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

View File

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

View File

@ -24,7 +24,8 @@ fn verify_apis(openapi_file: &str) {
let mut generator = Generator::new( let mut generator = Generator::new(
GenerationSettings::default() GenerationSettings::default()
.with_interface(InterfaceStyle::Builder) .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(); let output = generator.generate_text_normalize_comments(&spec).unwrap();
expectorate::assert_contents( expectorate::assert_contents(