Skip to content

Commit 8aeaeda

Browse files
committed
add visit_binary
1 parent 4b060ce commit 8aeaeda

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

src/visitor/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ pub trait Visitor: seal::Sealed {
3939

4040
fn visit_datetime(&mut self);
4141

42+
fn visit_binary(&mut self);
43+
4244
fn visit_option(&mut self) -> &mut Self::OptionVisitor;
4345

4446
fn visit_enum<I>(&mut self, name: Option<String>, description: Option<String>, variants: I)

src/visitor/never.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ impl Visitor for Never {
5555
unreachable!()
5656
}
5757

58+
fn visit_binary(&mut self) {
59+
unreachable!()
60+
}
61+
5862
fn visit_option(&mut self) -> &mut Self {
5963
unreachable!()
6064
}

src/visitor/openapi.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ pub enum OpenapiVisitor {
6363
Uuid,
6464
Date,
6565
DateTime,
66+
Binary,
6667

6768
Option(Box<OpenapiVisitor>),
6869
Enum {
@@ -207,6 +208,14 @@ impl OpenapiVisitor {
207208
}))
208209
})),
209210

211+
Self::Binary => Some(OpenapiSchema::new(Schema {
212+
schema_data: Default::default(),
213+
schema_kind: SchemaKind::Type(Type::String(StringType {
214+
format: VariantOrUnknownOrEmpty::Item(StringFormat::Binary),
215+
..Default::default()
216+
}))
217+
})),
218+
210219
Self::Option(opt) => opt
211220
.into_schema()
212221
.map(|mut schema| match schema.schema.schema_data.title.as_deref() {
@@ -340,6 +349,11 @@ impl Visitor for OpenapiVisitor {
340349
*self = Self::DateTime;
341350
}
342351

352+
fn visit_binary(&mut self) {
353+
self.panic_if_non_empty();
354+
*self = Self::Binary;
355+
}
356+
343357
fn visit_option(&mut self) -> &mut Self {
344358
self.panic_if_non_empty();
345359
*self = Self::Option(Box::new(Self::new()));
@@ -615,6 +629,10 @@ impl Visitor for Flatten {
615629
self.panic("a datetime")
616630
}
617631

632+
fn visit_binary(&mut self) {
633+
self.panic("binary")
634+
}
635+
618636
fn visit_option(&mut self) -> &mut Never {
619637
self.panic("an option")
620638
}

0 commit comments

Comments
 (0)