scorpio 0.6.4 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +6 -1
  3. data/CHANGELOG.md +10 -2
  4. data/LICENSE.md +2 -4
  5. data/README.md +81 -67
  6. data/documents/{github.com/OAI/OpenAPI-Specification/blob/oas3-schema/schemas/v3.0 → spec.openapis.org/oas/3.0}/schema.yaml +164 -628
  7. data/documents/spec.openapis.org/oas/3.1/dialect/base.schema.yaml +22 -0
  8. data/documents/spec.openapis.org/oas/3.1/meta/base.schema.yaml +71 -0
  9. data/documents/spec.openapis.org/oas/3.1/schema-base.yaml +21 -0
  10. data/documents/spec.openapis.org/oas/3.1/schema.yaml +980 -0
  11. data/documents/swagger.io/v2/schema.json +1 -1
  12. data/documents/www.googleapis.com/discovery/v1/apis/discovery/v1/rest.yml +44 -4
  13. data/lib/scorpio/google_api_document.rb +121 -193
  14. data/lib/scorpio/openapi/document.rb +63 -31
  15. data/lib/scorpio/openapi/operation.rb +114 -96
  16. data/lib/scorpio/openapi/operations_scope.rb +35 -19
  17. data/lib/scorpio/openapi/reference.rb +88 -23
  18. data/lib/scorpio/openapi/schema_elements/type_nullable.rb +38 -0
  19. data/lib/scorpio/openapi/schema_elements.rb +7 -0
  20. data/lib/scorpio/openapi/server.rb +34 -0
  21. data/lib/scorpio/openapi/tag.rb +19 -3
  22. data/lib/scorpio/openapi/v2/dialect.rb +66 -0
  23. data/lib/scorpio/openapi/v2.rb +124 -0
  24. data/lib/scorpio/openapi/v3_0/dialect.rb +76 -0
  25. data/lib/scorpio/openapi/v3_0.rb +130 -0
  26. data/lib/scorpio/openapi/v3_1.rb +243 -0
  27. data/lib/scorpio/openapi.rb +23 -203
  28. data/lib/scorpio/request.rb +67 -61
  29. data/lib/scorpio/resource_base.rb +57 -49
  30. data/lib/scorpio/response.rb +28 -10
  31. data/lib/scorpio/ur.rb +7 -3
  32. data/lib/scorpio/version.rb +1 -1
  33. data/lib/scorpio.rb +12 -6
  34. data/pages/Request_Configuration.md +69 -0
  35. data/pages/Security.md +50 -0
  36. data/scorpio.gemspec +6 -5
  37. metadata +28 -15
  38. data/documents/www.googleapis.com/discovery/v1/apis/discovery/v1/rest +0 -684
  39. data/lib/scorpio/openapi/v3/server.rb +0 -44
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ad4505d3bd4e9dc299b95b21ce5305e7864200fb0481be3f2600f75c3476f73d
4
- data.tar.gz: 613abb854fffaf49a45f8c9e19a0f150f0fef9b7500e50cf20dc2a6f58023347
3
+ metadata.gz: 1f812bf2fd5370f04a99f7f4acfa20e731f91209a27bbec923b647620dba75e7
4
+ data.tar.gz: 4ba616f4cb7e42f5ac4ac82b04ec6f2c6ecb9ac7777e3efc275a620180ec0f37
5
5
  SHA512:
6
- metadata.gz: 26cd883ee719f0e2683ac53c1be85d9296c90b92e80a799d938cf361c431ca486dd4e6a2db73539d7f133fa162fd104f85f4d9c9ec89b7f74e2187e8218b543b
7
- data.tar.gz: 945afcb210c0b0ea8801393a3586b83045f82bcb94724021e3c69a6320ba32c23ddbeb6652644a6c3ea063830550f97e3001e661251662a8e6d976bc2cfdce62
6
+ metadata.gz: 70bd41fd5637305698660684e25d4cd3e3726aeb12faa17ffcf9ef7d04a0417ba271e01d85b6e2d95bbff08ee83951f6fb0542fbba6eb941a547a67f88aca34a
7
+ data.tar.gz: 7e61e67b208a251d88f838aaaa481498ce2e44797ea955ae3b31f6b3108a42e3c6e67a0e27765deed911d578770cfd9b2131b4b44f8164d40191c395c91e09a6
data/.yardopts CHANGED
@@ -1 +1,6 @@
1
- --main README.md --markup=markdown {lib}/**/*.rb
1
+ --main README.md
2
+ --markup=markdown
3
+ --markup-provider=redcarpet
4
+ --no-private
5
+ --files pages/**/*.md
6
+ lib/**/*.rb
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ # v0.7.0
2
+
3
+ - OpenAPI v3.1 (OpenAPI::V3_1)
4
+ - rename OpenAPI::V3 to OpenAPI::V3_0
5
+ - OpenAPI::Reference resolves $ref across documents
6
+ - Scorpio::Google::RestDescription is an API description document on its own; rm conversion to OpenAPI
7
+ - JSI ~> v0.9
8
+
1
9
  # v0.6.4
2
10
 
3
11
  - JSI ~> v0.8.1
@@ -51,7 +59,7 @@
51
59
  - bugfixes
52
60
 
53
61
  # v0.4.0
54
- - Scorpio::OpenAPI v3 classes updated from OAI/OpenAPI-Specification branch oas3-schema
62
+ - Scorpio::OpenAPI v3.0 classes updated from OAI/OpenAPI-Specification branch oas3-schema
55
63
  - any uniquely-named request parameter will have accessors on Request and can be passed as config to #initialize
56
64
  - Request#each_page_ur for pagination
57
65
  - significantly improved documentation
@@ -61,7 +69,7 @@
61
69
  - miscellaneous minor fixes and improvements
62
70
 
63
71
  # v0.3.0
64
- - OpenAPI v3 support
72
+ - OpenAPI v3.0 support
65
73
  - classes Request/Response, OpenAPI::Operation, OpenAPI::Document handle a request. ResourceBase relies on these.
66
74
  - extract SchemaInstanceBase and friends to gem JSI
67
75
 
data/LICENSE.md CHANGED
@@ -1,8 +1,6 @@
1
- Copright © [Ethan](https://github.com/notEthan/)
1
+ Scorpio Copyright © [Ethan](https://github.com/notEthan/), licensed under the terms of the [GNU Affero General Public License version 3](https://www.gnu.org/licenses/agpl-3.0.html).
2
2
 
3
- [<img align="right" src="https://github.com/notEthan/scorpio/raw/master/resources/icons/AGPL-3.0.png">](https://www.gnu.org/licenses/agpl-3.0.html)
4
-
5
- Scorpio is licensed under the terms of the [GNU Affero General Public License version 3](https://www.gnu.org/licenses/agpl-3.0.html).
3
+ [<img align="right" src="https://www.gnu.org/graphics/agplv3-155x51.png">](https://www.gnu.org/licenses/agpl-3.0.html)
6
4
 
7
5
  GNU Affero General Public License
8
6
  =================================
data/README.md CHANGED
@@ -1,26 +1,32 @@
1
1
  # Scorpio
2
2
 
3
- ![Test CI Status](https://github.com/notEthan/scorpio/actions/workflows/test.yml/badge.svg?branch=stable)
3
+ ![Test CI Status](https://github.com/notEthan/scorpio/actions/workflows/test.yml/badge.svg?branch=main)
4
4
  [![Coverage Status](https://coveralls.io/repos/github/notEthan/scorpio/badge.svg)](https://coveralls.io/github/notEthan/scorpio)
5
5
 
6
- Scorpio is a library that helps you, as a client, consume an HTTP service described by an OpenAPI document. You provide the OpenAPI description document, a little bit of configuration, and Scorpio will take that and dynamically generate an interface for you to call the service's operations and interact with its resources as an ORM.
6
+ Scorpio is a library that helps you, as a client, consume a service whose API is described by an OpenAPI description. You provide the OpenAPI description document, a little bit of configuration, and using that Scorpio will dynamically construct interfaces for you to call the service's operations and interact with its resources like an ORM.
7
7
 
8
- Note: The canonical location of this README is on [RubyDoc](http://rubydoc.info/gems/scorpio/). When viewed on [Github](https://github.com/notEthan/scorpio/), it may be inconsistent with the latest released gem, and Yardoc links will not work.
8
+ Note: The canonical location of this README is on [RubyDoc](https://rubydoc.info/gems/scorpio/). When viewed on [Github](https://github.com/notEthan/scorpio/), it may be inconsistent with the latest released gem, and Yardoc links will not work.
9
9
 
10
10
  ## Background
11
11
 
12
- To start with, you need an OpenAPI (formerly known as Swagger) document describing a service you will be consuming. v2 and v3 are both supported.[^1] This document can be written by hand or sometimes generated from other existing sources. The creation of an OpenAPI document describing your service is outside the scope of Scorpio. Here are several resources on OpenAPI:
12
+ ### OpenAPI specification and OpenAPI documents
13
13
 
14
+ To start with, you need an OpenAPI document (an OAD) describing a service you will be consuming. OpenAPI Specification v3.1, v3.0, and v2 (formerly known as Swagger) are supported. An OAD can be written by hand or sometimes generated from other existing sources. The creation of an OpenAPI document describing a given service is outside the scope of Scorpio. Here are several resources on OpenAPI:
15
+
16
+ - [Learn about OpenAPI](https://learn.openapis.org/)
14
17
  - [OpenAPI Specification at Wikipedia](https://en.wikipedia.org/wiki/OpenAPI_Specification)
15
- - [OpenAPI Initiative](https://www.openapis.org/) is the official web site for OpenAPI
16
- - [OpenAPI Specification on GitHub](https://github.com/OAI/OpenAPI-Specification)
17
- - [swagger.io](https://swagger.io/) API tooling
18
+ - OpenAPI Specifications [v3.1](https://spec.openapis.org/oas/v3.1.html), [v3.0](https://spec.openapis.org/oas/v3.0.html), [v2.0](https://spec.openapis.org/oas/v2.0.html)
19
+ - [OpenAPI Specification development on GitHub](https://github.com/OAI/OpenAPI-Specification)
20
+
21
+ ### JSON Schema, JSI
22
+
23
+ [JSON Schema](https://json-schema.org/) is an important part of OpenAPI documents, in which it is used to describe various components of a service's requests and responses.
18
24
 
19
- OpenAPI relies on the definition of schemas using the JSON schema specification, which can be learned about at https://json-schema.org/
25
+ [JSI](https://github.com/notEthan/jsi) is a Ruby library that offers an Object-Oriented representation for JSON data using JSON Schemas.
20
26
 
21
- Once you have the OpenAPI document describing the service you will consume, you can get started implementing the code that will interact with that service.
27
+ Scorpio utilizes JSI to instantiate components of the API described by JSON schemas, in particular JSON request and response bodies.
22
28
 
23
- [^1]: Certain features may be missing, but Scorpio tries to make workarounds easy. Issues and pull requests regarding missing functionality are welcome.
29
+ Scorpio's core is built on JSI. It uses the JSON Schema describing OpenAPI documents (which is published along with the OpenAPI specification) with JSI to instantiate an OAD and to define functionality of the document, operations, and other components.
24
30
 
25
31
  ## Pet Store (using Scorpio::ResourceBase)
26
32
 
@@ -33,38 +39,46 @@ require 'scorpio'
33
39
  # PetStore is a module to contain our pet store related classes.
34
40
  # it is optional - your naming conventions are your own.
35
41
  module PetStore
36
- # Scorpio's recommended structure is to have a base class which inherits from
37
- # Scorpio::ResourceBase to represent the Pet Store and all its resources.
42
+ # Scorpio's recommended structure is to have a base class which
43
+ # inherits from Scorpio::ResourceBase to represent the Pet Store
44
+ # and all its resources.
38
45
  #
39
- # you configure the openapi document and other shared configuration on this class.
46
+ # You configure the OpenAPI document and other shared configuration
47
+ # on this class.
40
48
  class Resource < Scorpio::ResourceBase
41
- # set the openapi document. you'll usually want this to be a file in your local filesystem
42
- # (making network calls at application boot time is usually a bad idea), but for this
43
- # example we will do a quick-and-dirty http get.
44
- require 'json'
45
- self.openapi_document = JSON.parse(Faraday.get('https://petstore.swagger.io/v2/swagger.json').body)
49
+ # Set the OpenAPI document. You'll usually want this to be a file in
50
+ # your local filesystem (making network calls at application boot
51
+ # time is usually a bad idea), but for this example we will do a
52
+ # quick-and-dirty HTTP get.
53
+ self.openapi_document = JSON.parse(Faraday.get('https://petstore.swagger.io/v2/swagger.json').body, freeze: true)
46
54
  end
47
55
 
48
- # a Pet is a resource of the pet store, so inherits from PetStore::Resource
56
+ # a Pet is a resource of the pet store, so inherits from
57
+ # PetStore::Resource
49
58
  class Pet < Resource
50
- # setting the tag name tells Scorpio to associate operations tagged with 'pet' with this
51
- # class and its instances. this lets you call operations such as addPet, updatePet, etc.
59
+ # Setting the tag name tells Scorpio to associate operations tagged
60
+ # with 'pet' with this class and its instances. This lets you call
61
+ # operations such as addPet, updatePet, etc.
52
62
  self.tag_name = 'pet'
53
63
 
54
- # setting the schemas which represent a Pet will let scorpio return results from operation
55
- # calls properly instantiated as Pet instances. for example, calling getPetById will return
56
- # a PetStore::Pet instance since its success response refers to #/definitions/Pet.
64
+ # Setting the schemas which represent a Pet will let Scorpio
65
+ # return results from operation calls properly instantiated as
66
+ # Pet instances. For example, calling getPetById will return a
67
+ # PetStore::Pet instance since its success response refers
68
+ # to #/definitions/Pet.
57
69
  #
58
- # this works for nested structures as well, e.g. findPetsByStatus returns an array of
59
- # #/definitions/Pet and likewise Scorpio will return an array of PetStore::Pet instances.
70
+ # This works for nested structures as well, e.g. findPetsByStatus
71
+ # returns an array of #/definitions/Pet and likewise Scorpio will
72
+ # return an array of PetStore::Pet instances.
60
73
  #
61
- # this also adds accessors for properties of the schema - in this case #id, #name, #tags, etc.
74
+ # This also adds accessors for properties of the schema - in this
75
+ # case #id, #name, #tags, etc.
62
76
  self.represented_schemas = [openapi_document.definitions['Pet']]
63
77
  end
64
78
  end
65
79
  ```
66
80
 
67
- That should be all you need to start calling operations:
81
+ That is all you need to start calling operations:
68
82
 
69
83
  ```ruby
70
84
  # call the operation findPetsByStatus
@@ -73,6 +87,7 @@ sold_pets = PetStore::Pet.findPetsByStatus(status: 'sold')
73
87
  # sold_pets is an array-like collection of PetStore::Pet instances
74
88
 
75
89
  pet = sold_pets.sample
90
+ # => #<PetStore::Pet #{<JSI> "id" => 9, "name" => "Ix", "status" => "sold", ...}>
76
91
 
77
92
  pet.tags.map(&:name)
78
93
  # note that you have accessors on PetStore::Pet like #tags, and also that
@@ -87,9 +102,10 @@ pet == PetStore::Pet.getPetById(petId: pet['id'])
87
102
  # let's name the pet after ourself
88
103
  pet.name = ENV['USER']
89
104
 
90
- # store the result in the pet store. note the updatePet call from the instance - our
91
- # calls so far have been on the class PetStore::Pet, but scorpio defines instance
92
- # methods to call operations where appropriate as well.
105
+ # Store the result in the pet store. Note the updatePet call from the
106
+ # instance - our calls so far have been on the class PetStore::Pet,
107
+ # but Scorpio defines instance methods to call operations where
108
+ # appropriate as well.
93
109
  # updatePet: https://petstore.swagger.io/#/pet/updatePet
94
110
  pet.updatePet
95
111
 
@@ -106,23 +122,25 @@ PetStore::Pet.getPetById(petId: 0)
106
122
 
107
123
  Isn't that cool? You get class methods like getPetById, instance methods like updatePet, attribute accessors like #name and #tags, all dynamically generated from the OpenAPI description. You just make a few classes with a line or two of configuration in each.
108
124
 
109
- ## Pet Store (using Scorpio::OpenAPI classes)
125
+ ## Pet Store (without Scorpio::ResourceBase)
110
126
 
111
- You do not have to define resource classes to use Scorpio to call OpenAPI operations - the classes Scorpio uses to represent concepts from OpenAPI can be called directly. Scorpio uses [JSI](https://github.com/notEthan/jsi) classes to represent OpenAPI schemes such as the Document and its Operations.
127
+ You do not have to define resource classes as above to use Scorpio to interact with a service - ResourceBase is a helpful representation of the service's resources, but operations can be run directly from Scorpio's representation of the OpenAPI document.
112
128
 
113
- We start by instantiating the OpenAPI document. `Scorpio::OpenAPI::Document.from_instance` returns a V2 or V3 OpenAPI Document class instance.
129
+ This representation uses [JSI](https://github.com/notEthan/jsi) with the JSON schema describing OpenAPI documents (for the relevant version of the OpenAPI specification). Scorpio's API client functionality is implemented using these schemas, and the result is that the instantiated OpenAPI document is itself the client to the service it describes.
130
+
131
+ To consume the Pet Store service, we start by instantiating the OpenAPI document. {Scorpio.new_document} returns a JSI instance described by the appropriate OpenAPI document schema.
114
132
 
115
133
  ```ruby
116
134
  require 'scorpio'
117
- pet_store_doc = Scorpio::OpenAPI::Document.from_instance(JSON.parse(Faraday.get('https://petstore.swagger.io/v2/swagger.json').body))
118
- # => #{<Scorpio::OpenAPI::V2::Document fragment="#"> "swagger" => "2.0", ...}
135
+ pet_store_content = JSON.parse(Faraday.get('https://petstore.swagger.io/v2/swagger.json').body, freeze: true)
136
+ pet_store_oad = Scorpio::OpenAPI::Document.from_instance(pet_store_content)
137
+ # => #{<JSI (Scorpio::OpenAPI::V2::Document)> "swagger" => "2.0", ...}
119
138
  ```
120
139
 
121
- The OpenAPI document holds the JSON that represents it, so to get an Operation you go through the document's paths, just as it is represented in the JSON.
140
+ Within `pet_store_oad` we can access an operation under the OAD's `#paths` property - JSI objects have accessors for described properties, or can be subscripted as with the Hash/Array nodes they represent.
122
141
 
123
142
  ```ruby
124
- # the store inventory operation will let us see what statuses there are in the store.
125
- inventory_op = pet_store_doc.paths['/store/inventory']['get']
143
+ inventory_op = pet_store_oad.paths['/store/inventory']['get']
126
144
  # => #{<JSI (Scorpio::OpenAPI::V2::Operation)>
127
145
  # "summary" => "Returns pet inventories by status",
128
146
  # "operationId" => "getInventory",
@@ -130,14 +148,14 @@ inventory_op = pet_store_doc.paths['/store/inventory']['get']
130
148
  # }
131
149
  ```
132
150
 
133
- Alternatively, Scorpio defines a helper `Document#operations` which behaves like an Enumerable of all the Operations in the Document. It can be subscripted with the `operationId`:
151
+ Alternatively, Scorpio defines a helper {Scorpio::OpenAPI::Document#operations} which is an Enumerable of all the Operations in the Document. It can be subscripted with an `operationId`:
134
152
 
135
153
  ```ruby
136
- inventory_op = pet_store_doc.operations['getInventory']
154
+ inventory_op = pet_store_oad.operations['getInventory']
137
155
  # => returns the same inventory_op as above.
138
156
  ```
139
157
 
140
- Now that we have an operation, we can run requests from it. {Scorpio::OpenAPI::Operation#run} performs the operation by running a request. If the response is an error, a {Scorpio::HTTPError} subclass will be raised. On success, it returns the response body entity, instantiated according to the OpenAPI schema for the operation response, if specified. For more detail on how json-schema instances are represented, see the gem [JSI](https://github.com/notEthan/jsi).
158
+ Now that we have an operation, we can run requests from it with {Scorpio::OpenAPI::Operation#run}. On success, it returns the parsed response body, instantiated using the JSON schema for the operation response, if that is specified in the OAD.
141
159
 
142
160
  ```ruby
143
161
  inventory = inventory_op.run
@@ -150,25 +168,29 @@ inventory = inventory_op.run
150
168
  # }
151
169
  ```
152
170
 
153
- let's pick a state and find a pet. we'll go through the rest of the example in the ResourceBase section pretty much like it is up there:
171
+ We'll pick a state, find a pet, and go through the rest of the example in the ResourceBase section pretty much like it is up there:
154
172
 
155
173
  ```ruby
156
174
  # call the operation findPetsByStatus
157
175
  # doc: https://petstore.swagger.io/#/pet/findPetsByStatus
158
- sold_pets = pet_store_doc.operations['findPetsByStatus'].run(status: 'sold')
159
- # sold_pets is an array-like collection of JSI instances
176
+ # we will be mutating one of these, so we pass mutable: true
177
+ sold_pets = pet_store_oad.operations['findPetsByStatus'].run(status: 'sold', mutable: true)
178
+ # sold_pets is an array-like collection of JSI instances.
179
+ # Each item is described by the OAD's Pet schema.
180
+ sold_pets.first.described_by?(pet_store_oad.definitions['Pet']) # => true
160
181
 
161
182
  pet = sold_pets.detect { |pet| pet.tags.any? }
162
183
 
163
184
  pet.tags.map(&:name)
164
- # note that you have accessors on the returned JSI like #tags, and also that
165
- # tags have accessors for properties 'name' and 'id' from the tags schema
166
- # (your tag names will be different depending on what's in the pet store)
185
+ # Note that you have accessors on the returned JSI like #tags, and also
186
+ # that tags have accessors for properties 'name' and 'id' from the tags
187
+ # schema (your tag names will be different depending on what's in the
188
+ # pet store).
167
189
  # => ["aucune"]
168
190
 
169
191
  # compare the pet from findPetsByStatus to one returned from getPetById
170
192
  # doc: https://petstore.swagger.io/#/pet/getPetById
171
- pet_by_id = pet_store_doc.operations['getPetById'].run(petId: pet['id'])
193
+ pet_by_id = pet_store_oad.operations['getPetById'].run(petId: pet['id'])
172
194
 
173
195
  # unlike ResourceBase instances above, JSI instances have stricter
174
196
  # equality and the pets returned from different operations are not
@@ -181,14 +203,14 @@ pet.name = ENV['USER']
181
203
 
182
204
  # store the result in the pet store.
183
205
  # updatePet: https://petstore.swagger.io/#/pet/updatePet
184
- pet_store_doc.operations['updatePet'].run(body_object: pet)
206
+ pet_store_oad.operations['updatePet'].run(body_object: pet)
185
207
 
186
208
  # check that it was saved
187
- pet_store_doc.operations['getPetById'].run(petId: pet['id']).name
209
+ pet_store_oad.operations['getPetById'].run(petId: pet['id']).name
188
210
  # => "ethan" (unless for some reason your name is not Ethan)
189
211
 
190
212
  # here is how errors are handled:
191
- pet_store_doc.operations['getPetById'].run(petId: 0)
213
+ pet_store_oad.operations['getPetById'].run(petId: 0)
192
214
  # raises: Scorpio::HTTPErrors::NotFound404Error
193
215
  # Error calling operation getPetById:
194
216
  # {"code":1,"type":"error","message":"Pet not found"}
@@ -198,7 +220,7 @@ pet_store_doc.operations['getPetById'].run(petId: 0)
198
220
 
199
221
  For another example of an API that a client interacts with using Scorpio::ResourceBase, Scorpio's tests implement the Blog service. This is defined in test/blog.rb. The service uses ActiveRecord models and Sinatra to make a simple RESTful service.
200
222
 
201
- Its API is described in `test/blog.openapi.yml`, defining the Article resource, several operations, and schemas. The client is set up in `test/blog_scorpio_models.rb`. The base class BlogModel defines the base_url and the api description, as well as some other optional setup done for testing. Its operations are tested in `test/scorpio_test.rb`.
223
+ Its API is described in `test/blog.openapi<version>.yml`, defining the Article resource, several operations, and schemas. The client is set up in `test/blog_scorpio_models.rb`. The base class BlogModel defines the base_url and the api description, as well as some other optional setup done for testing. Its operations are tested in `test/scorpio_test.rb`.
202
224
 
203
225
  ## Scorpio::ResourceBase
204
226
 
@@ -222,12 +244,12 @@ When these are set, Scorpio::ResourceBase looks through the API description and
222
244
 
223
245
  ## Scorpio::Ur
224
246
 
225
- If you need a more complete representation of the HTTP request and/or response, Scorpio::OpenAPI::Operation#run_ur or Scorpio::Request#run_ur will return a representation of the request and response defined by the gem [Ur](https://github.com/notEthan/ur). See that link for more detail. Relating to the example above titled "Pet Store (using Scorpio::OpenAPI classes)", this code will return an Ur:
247
+ If you need a more complete representation of the HTTP request and/or response, {Scorpio::OpenAPI::Operation#run_ur} will return a representation of the request and response defined by the gem [Ur](https://github.com/notEthan/ur). See that link for more detail. Relating to the example above titled "Pet Store (without Scorpio::ResourceBase)", this code will return an Ur:
226
248
 
227
249
  ```ruby
228
- inventory_op = Scorpio::OpenAPI::Document.from_instance(JSON.parse(Faraday.get('https://petstore.swagger.io/v2/swagger.json').body)).paths['/store/inventory']['get']
250
+ inventory_op = Scorpio.new_document(JSON.parse(Faraday.get('https://petstore.swagger.io/v2/swagger.json').body, freeze: true)).paths['/store/inventory']['get']
229
251
  inventory_ur = inventory_op.run_ur
230
- # => #{<Scorpio::Ur fragment="#"> ...}
252
+ # => #{<JSI (Ur + Scorpio::Ur)> "bound" => "outbound", "request" => ...}
231
253
  ```
232
254
 
233
255
  ### Scorpio ResourceBase pickle adapter
@@ -236,24 +258,16 @@ Scorpio provides a pickle adapter to use models with [Pickle](https://rubygems.o
236
258
 
237
259
  ### Google API discovery service
238
260
 
239
- An initial implementation of Scorpio::ResourceBase was based on the format defined for Google's API discovery service.
261
+ Scorpio was initially built to work with the API description format defined for Google's API discovery service. Though Scorpio is now primarily built for OpenAPI, Google's format is still supported.
240
262
 
241
263
  For background on the Google discovery service and the API description format it defines, see:
242
264
 
243
265
  - https://developers.google.com/discovery/
244
266
  - https://developers.google.com/discovery/v1/reference/
245
267
 
246
- This format is still supported indirectly, by converting from a Google API document to OpenAPI using `Scorpio::Google::RestDescription#to_openapi_document`. Example conversion looks like:
247
-
248
- ```ruby
249
- class MyModel < Scorpio::ResourceBase
250
- rest_description_doc = YAML.load_file('path/to/doc.yml')
251
- rest_description = Scorpio::Google::RestDescription.new(rest_description_doc)
252
- self.openapi_document = rest_description.to_openapi_document
268
+ Such an API description (called a "rest description" or sometimes "discovery document") is an instance of {Scorpio::Google::RestDescription}. Note that Scorpio being OpenAPI-centric, some interfaces use the idioms or terminology of OpenAPI, e.g. a {Scorpio::Google::RestMethod} uses the interface of {Scorpio::OpenAPI::Operation}. See `examples/google` in Scorpio's repository for example usage.
253
269
 
254
- # ... the remainder of your setup and model code here
255
- end
256
- ```
270
+ Google does provide official [API clients in Ruby](https://github.com/googleapis/google-api-ruby-client). These weigh in at nearly 5 million lines of code across about 500 gems, almost all generated code from the same API documents Scorpio uses. Scorpio's dynamic handling of API documents and their schemas provides comparable functionality.
257
271
 
258
272
  ## Other
259
273