fix: seems like definition lookups weren't working

Co-authored-by: Lucas Rosa <x@rvcas.dev>
This commit is contained in:
microproofs 2023-05-31 00:18:05 -04:00
parent c710d488d6
commit a6807f0bfb
1 changed files with 5 additions and 1 deletions

View File

@ -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 {