File tree Expand file tree Collapse file tree 3 files changed +10
-2
lines changed Expand file tree Collapse file tree 3 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -33,7 +33,9 @@ impl MediaType {
33
33
pub fn schema ( & self , spec : & Spec ) -> Result < ObjectSchema , Error > {
34
34
self . schema
35
35
. as_ref ( )
36
- . unwrap ( )
36
+ . ok_or ( Error :: Ref ( super :: RefError :: NoReference (
37
+ super :: RefType :: Schema ,
38
+ ) ) ) ?
37
39
. resolve ( spec)
38
40
. map_err ( Error :: Ref )
39
41
}
Original file line number Diff line number Diff line change @@ -132,7 +132,9 @@ impl Operation {
132
132
pub fn request_body ( & self , spec : & Spec ) -> Result < RequestBody , Error > {
133
133
self . request_body
134
134
. as_ref ( )
135
- . unwrap ( )
135
+ . ok_or ( Error :: Ref ( super :: RefError :: NoReference (
136
+ super :: RefType :: RequestBody ,
137
+ ) ) ) ?
136
138
. resolve ( spec)
137
139
. map_err ( Error :: Ref )
138
140
}
Original file line number Diff line number Diff line change @@ -54,6 +54,10 @@ pub enum RefError {
54
54
/// Reference path points outside the given spec file.
55
55
#[ display( "Unresolvable path: {}" , _0) ]
56
56
Unresolvable ( #[ error( not( source) ) ] String ) , // TODO: use some kind of path structure
57
+
58
+ /// `Option<ObjectOrReference<_>>` evaluated to be `None`.
59
+ #[ display( "Cannot attempt to resolve this reference because Option<ObjectOrReference<{}>> evaluated to None" , _0) ]
60
+ NoReference ( #[ error( not( source) ) ] RefType ) ,
57
61
}
58
62
59
63
/// Component type of a reference.
You can’t perform that action at this time.
0 commit comments