From eb4120a1285b500a2cda8615a36ca5707c17f68e Mon Sep 17 00:00:00 2001 From: Ethan Date: Thu, 11 Feb 2021 16:13:54 -0800 Subject: [PATCH 1/3] update OpenAPI::OperationsScope's usage of jsi_memoize https://github.com/notEthan/jsi/pull/123 --- lib/scorpio/openapi/operations_scope.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/scorpio/openapi/operations_scope.rb b/lib/scorpio/openapi/operations_scope.rb index 2dc49e2..4487d67 100644 --- a/lib/scorpio/openapi/operations_scope.rb +++ b/lib/scorpio/openapi/operations_scope.rb @@ -7,6 +7,7 @@ class OperationsScope # @param openapi_document [Scorpio::OpenAPI::Document] def initialize(openapi_document) + jsi_initialize_memos @openapi_document = openapi_document end attr_reader :openapi_document From b2dfb728db85909bc943912a79d073e7584d8709 Mon Sep 17 00:00:00 2001 From: Ethan Date: Wed, 24 Jun 2020 07:21:58 -0700 Subject: [PATCH 2/3] implement Scorpio::OpenAPI::Reference#deref JSI::Base#deref removed in https://github.com/notEthan/jsi/pull/124/commits/ff220eb9b24659c62e83bd1e17cddbdf0caca42b --- lib/scorpio/openapi/reference.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lib/scorpio/openapi/reference.rb b/lib/scorpio/openapi/reference.rb index 3d0d809..48c3414 100644 --- a/lib/scorpio/openapi/reference.rb +++ b/lib/scorpio/openapi/reference.rb @@ -14,6 +14,28 @@ def [](token, *a, &b) end return super end + + def deref + return unless respond_to?(:to_hash) && self['$ref'].respond_to?(:to_str) + + ref_uri = Addressable::URI.parse(self['$ref']) + ref_uri_nofrag = ref_uri.merge(fragment: nil) + + if !ref_uri_nofrag.empty? || ref_uri.fragment.nil? + raise(NotImplementedError, + "Scorpio currently only supports fragment URIs as OpenAPI references. cannot find reference by uri: #{self['$ref']}" + ) + end + + ptr = JSI::JSON::Pointer.from_fragment(ref_uri.fragment) + deref_jsi = ptr.evaluate(jsi_root_node) + + # TODO type check deref_jsi + + yield deref_jsi + + nil + end end end end From 95705039fe9c2b9b6ec33afd4e8c6c885020795f Mon Sep 17 00:00:00 2001 From: Ethan Date: Thu, 11 Feb 2021 04:37:22 -0800 Subject: [PATCH 3/3] jsi update to current stable --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index ff89abf..8d1885a 100644 --- a/Gemfile +++ b/Gemfile @@ -7,4 +7,4 @@ gem 'byebug' gem 'coveralls_reborn', '~> 0.11' gem 'wwtd' gem 'ur', github: 'notEthan/ur', ref: 'fa495042596eb9cec4ff361bfb764f516174558a' -gem 'jsi', github: 'notEthan/jsi', ref: '9b4bd0f15f2fe8c2135ffa78a9e1af316300da3b' +gem 'jsi', github: 'notEthan/jsi', ref: '27a73cca8384b0386cac14ef41474869d971aac1'