fix: seems like definition lookups weren't working
Co-authored-by: Lucas Rosa <x@rvcas.dev>
This commit is contained in:
@@ -36,7 +36,7 @@ impl<T> Definitions<T> {
|
|||||||
/// Retrieve a definition, if it exists.
|
/// Retrieve a definition, if it exists.
|
||||||
pub fn lookup(&self, reference: &Reference) -> Option<&T> {
|
pub fn lookup(&self, reference: &Reference) -> Option<&T> {
|
||||||
self.inner
|
self.inner
|
||||||
.get(reference.as_key())
|
.get(&reference.to_json_pointer())
|
||||||
.map(|v| v
|
.map(|v| v
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.expect("All registered definitions are 'Some'. 'None' state is only transient during registration")
|
.expect("All registered definitions are 'Some'. 'None' state is only transient during registration")
|
||||||
@@ -111,6 +111,10 @@ impl Reference {
|
|||||||
pub(crate) fn as_json_pointer(&self) -> String {
|
pub(crate) fn as_json_pointer(&self) -> String {
|
||||||
format!("#/definitions/{}", self.as_key().replace('/', "~1"))
|
format!("#/definitions/{}", self.as_key().replace('/', "~1"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn to_json_pointer(&self) -> String {
|
||||||
|
self.as_key().replace("~1", "/")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Display for Reference {
|
impl Display for Reference {
|
||||||
|
|||||||
Reference in New Issue
Block a user