scorpio 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7d8f3fb8a266157352a5f4054b732210bbbff161fb11d780828a3fbbdbf6922d
4
- data.tar.gz: 7ba1d3d214decdfa3c8b40df5d3d63377a160b8a6cb937090f8c3b67e47d4f45
3
+ metadata.gz: 1d6cc227b5ff884c520333ce9f3fd11f864dd8c58d1978a593195d98a63d61a1
4
+ data.tar.gz: e514788a47ac0ff2be11ae8fa926b5a5534156aa60e82c9afc71bfb842c419e5
5
5
  SHA512:
6
- metadata.gz: 2ed9a28136c4661fab6bbe9309533e3521df809f8146e3e92eb397baf37f7880a80d7d3491d8d2d5670e06189653c6fac51fff349409af46402be6f29658efff
7
- data.tar.gz: a4cd19c9266a038a93330d42aa1bb407b4d493dad6f7ddd3e1c61e5803c4fa84a65cf3802b7ceeba9d859e9cb5ed20b3124d140ed215d087d338b8e60fae579a
6
+ metadata.gz: 1035f4e7181d230cfc455cdfa2ce71f62d511b859134fae21661261e5793f0b09e03f16c4ce588f27ff9abb2d882013a1b677ea476c41f9b0e425abdb850a63e
7
+ data.tar.gz: 411ed1f50c74cc73f053146ece609452bf84a250d93a1874a33df0c0dc20088df06ee4446e8070be8d75dfad397b8437370794dc20f26763460fefda86490747
@@ -1,3 +1,8 @@
1
+ # v0.3.0
2
+ - OpenAPI v3 support
3
+ - classes Request/Response, OpenAPI::Operation, OpenAPI::Document handle a request. ResourceBase relies on these.
4
+ - extract SchemaInstanceBase and friends to gem JSI
5
+
1
6
  # v0.2.3
2
7
  - fix mutability of SchemaInstanceBase with #[]=; instance is modified in place
3
8
  - add mutability to JSON::Node with #[]=
data/README.md CHANGED
@@ -9,17 +9,19 @@ Note: The canonical location of this README is on [RubyDoc](http://rubydoc.info/
9
9
 
10
10
  ## Background
11
11
 
12
- To start with, you need an OpenAPI v2 (formerly known as Swagger) document describing a service you will be consuming. v3 support is planned. This document can be written by hand or sometimes generated from other existing sources. The creation of an OpenAPI document specifying your service is outside the scope of Scorpio. Here are several resources on OpenAPI:
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 specifying your service is outside the scope of Scorpio. Here are several resources on OpenAPI:
13
13
 
14
14
  - [OpenAPI Specification at Wikipedia](https://en.wikipedia.org/wiki/OpenAPI_Specification)
15
15
  - [OpenAPI Initiative](https://www.openapis.org/) is the official web site for OpenAPI
16
16
  - [OpenAPI Specification on GitHub](https://github.com/OAI/OpenAPI-Specification)
17
17
  - [swagger.io](https://swagger.io/) API tooling
18
18
 
19
- OpenAPI relies on the definition of schemas using the JSON schema specification, which can be learned about at http://json-schema.org/
19
+ OpenAPI relies on the definition of schemas using the JSON schema specification, which can be learned about at https://json-schema.org/
20
20
 
21
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.
22
22
 
23
+ [^1] Certain features may be missing, but Scorpio tries to make workarounds easy. Issues and pull requests regarding missing functionality are welcome.
24
+
23
25
  ## Pet Store
24
26
 
25
27
  Let's dive into some code, shall we? If you have learned about OpenAPI, you likely learned using the example of the Pet Store service. This README will use the same service. Its documentation is at http://petstore.swagger.io/ and its OpenAPI 2 specification is at http://petstore.swagger.io/v2/swagger.json (yaml version: http://petstore.swagger.io/v2/swagger.yaml )
@@ -1,8 +1,8 @@
1
1
  require "scorpio/version"
2
+ require "jsi"
3
+ require "ur"
2
4
  require "pathname"
3
5
  require "pp"
4
- require "api_hammer/ycomb"
5
- require "scorpio/json-schema-fragments"
6
6
 
7
7
  module Scorpio
8
8
  def self.root
@@ -10,8 +10,6 @@ module Scorpio
10
10
  end
11
11
  end
12
12
 
13
- require "scorpio/util"
14
-
15
13
  module Scorpio
16
14
  # generally put in code paths that are not expected to be valid control flow paths.
17
15
  # rather a NotImplementedCorrectlyError. but that's too long.
@@ -29,7 +27,7 @@ module Scorpio
29
27
  @status
30
28
  end
31
29
  end
32
- attr_accessor :faraday_response, :response_object
30
+ attr_accessor :ur, :response_object
33
31
  end
34
32
  # HTTP Error classes' canonical names are like Scorpio::HTTPErrors::BadRequest400Error, but can
35
33
  # be referred to like Scorpio::BadRequest400Error. this is just to avoid clutter in the Scorpio
@@ -82,21 +80,10 @@ module Scorpio
82
80
  include HTTPErrors
83
81
  error_classes_by_status.freeze
84
82
 
85
- autoload :JSON, 'scorpio/json'
86
- autoload :Google, 'scorpio/google_api_document'
87
- autoload :OpenAPI, 'scorpio/openapi'
88
- autoload :Typelike, 'scorpio/typelike_modules'
89
- autoload :Hashlike, 'scorpio/typelike_modules'
90
- autoload :Arraylike, 'scorpio/typelike_modules'
91
- autoload :ResourceBase, 'scorpio/resource_base'
92
- autoload :Schema, 'scorpio/schema'
93
- autoload :SchemaInstanceBase, 'scorpio/schema_instance_base'
94
- autoload :SchemaClasses, 'scorpio/schema_instance_base'
95
- autoload :ObjectJSONCoder, 'scorpio/schema_instance_json_coder'
96
- autoload :StructJSONCoder, 'scorpio/struct_json_coder'
97
- autoload :SchemaInstanceJSONCoder,'scorpio/schema_instance_json_coder'
98
-
99
- def self.class_for_schema(*a, &b)
100
- SchemaClasses.class_for_schema(*a, &b)
101
- end
83
+ autoload :Google, 'scorpio/google_api_document'
84
+ autoload :OpenAPI, 'scorpio/openapi'
85
+ autoload :Ur, 'scorpio/ur'
86
+ autoload :ResourceBase, 'scorpio/resource_base'
87
+ autoload :Request, 'scorpio/request'
88
+ autoload :Response, 'scorpio/response'
102
89
  end
@@ -1,22 +1,19 @@
1
- require 'api_hammer/ycomb'
2
- require 'scorpio/schema_instance_base'
3
-
4
1
  module Scorpio
5
2
  module Google
6
- discovery_rest_description_doc = Scorpio::JSON::Node.new_by_type(::JSON.parse(Scorpio.root.join('documents/www.googleapis.com/discovery/v1/apis/discovery/v1/rest').read), [])
3
+ discovery_rest_description_doc = JSI::JSON::Node.new_by_type(::JSON.parse(Scorpio.root.join('documents/www.googleapis.com/discovery/v1/apis/discovery/v1/rest').read), [])
7
4
 
8
5
  discovery_metaschema = discovery_rest_description_doc['schemas']['JsonSchema']
9
- rest_description_schema = Scorpio.class_for_schema(discovery_metaschema).new(discovery_rest_description_doc['schemas']['RestDescription'])
10
- discovery_rest_description = Scorpio.class_for_schema(rest_description_schema).new(discovery_rest_description_doc)
6
+ rest_description_schema = JSI.class_for_schema(discovery_metaschema).new(discovery_rest_description_doc['schemas']['RestDescription'])
7
+ discovery_rest_description = JSI.class_for_schema(rest_description_schema).new(discovery_rest_description_doc)
11
8
 
12
9
  # naming these is not strictly necessary, but is nice to have.
13
- DirectoryList = Scorpio.class_for_schema(discovery_rest_description['schemas']['DirectoryList'])
14
- JsonSchema = Scorpio.class_for_schema(discovery_rest_description['schemas']['JsonSchema'])
15
- RestDescription = Scorpio.class_for_schema(discovery_rest_description['schemas']['RestDescription'])
16
- RestMethod = Scorpio.class_for_schema(discovery_rest_description['schemas']['RestMethod'])
17
- RestResource = Scorpio.class_for_schema(discovery_rest_description['schemas']['RestResource'])
18
- RestMethodRequest = Scorpio.class_for_schema(discovery_rest_description['schemas']['RestMethod']['properties']['request'])
19
- RestMethodResponse = Scorpio.class_for_schema(discovery_rest_description['schemas']['RestMethod']['properties']['response'])
10
+ DirectoryList = JSI.class_for_schema(discovery_rest_description['schemas']['DirectoryList'])
11
+ JsonSchema = JSI.class_for_schema(discovery_rest_description['schemas']['JsonSchema'])
12
+ RestDescription = JSI.class_for_schema(discovery_rest_description['schemas']['RestDescription'])
13
+ RestMethod = JSI.class_for_schema(discovery_rest_description['schemas']['RestMethod'])
14
+ RestResource = JSI.class_for_schema(discovery_rest_description['schemas']['RestResource'])
15
+ RestMethodRequest = JSI.class_for_schema(discovery_rest_description['schemas']['RestMethod']['properties']['request'])
16
+ RestMethodResponse = JSI.class_for_schema(discovery_rest_description['schemas']['RestMethod']['properties']['response'])
20
17
 
21
18
  # google does a weird thing where it defines a schema with a $ref property where a json-schema is to be used in the document (method request and response fields), instead of just setting the schema to be the json-schema schema. we'll share a module across those schema classes that really represent schemas. is this confusingly meta enough?
22
19
  module SchemaLike
@@ -169,14 +166,14 @@ module Scorpio
169
166
  if ad.schemas
170
167
  openapi['definitions'] = ad.schemas
171
168
  ad.schemas.each do |name, schema|
172
- openapi = ycomb do |rec|
169
+ openapi = JSI::Util.ycomb do |rec|
173
170
  proc do |object|
174
171
  if object.respond_to?(:to_hash)
175
172
  object.merge(object.map do |k, v|
176
173
  if k == '$ref' && (v == schema['id'] || v == "#/schemas/#{name}" || v == name)
177
174
  {k => "#/definitions/#{name}"}
178
175
  else
179
- ycomb do |toopenapirec|
176
+ JSI::Util.ycomb do |toopenapirec|
180
177
  proc do |toopenapiobject|
181
178
  toopenapiobject = toopenapiobject.to_openapi if toopenapiobject.respond_to?(:to_openapi)
182
179
  if toopenapiobject.respond_to?(:to_hash)
@@ -204,7 +201,7 @@ module Scorpio
204
201
  end
205
202
  end
206
203
  # check we haven't got anything that shouldn't go in a openapi document
207
- openapi = ycomb do |rec|
204
+ openapi = JSI::Util.ycomb do |rec|
208
205
  proc do |object|
209
206
  object = object.to_openapi if object.respond_to?(:to_openapi)
210
207
  if object.respond_to?(:to_hash)
@@ -1,168 +1,166 @@
1
- require 'scorpio/schema_instance_base'
2
-
3
1
  module Scorpio
4
2
  module OpenAPI
3
+ autoload :Operation, 'scorpio/openapi/operation'
4
+ autoload :Document, 'scorpio/openapi/document'
5
+ autoload :OperationsScope, 'scorpio/openapi/operations_scope'
6
+
5
7
  module V3
6
- openapi_schema = Scorpio::Schema.new(::JSON.parse(Scorpio.root.join('documents/openapis.org/v3/schema.json').read))
8
+ openapi_schema = JSI::Schema.new(::JSON.parse(Scorpio.root.join('documents/openapis.org/v3/schema.json').read))
7
9
  openapi_class = proc do |*key|
8
- Scorpio.class_for_schema(key.inject(openapi_schema, &:[]))
10
+ JSI.class_for_schema(key.inject(openapi_schema, &:[]))
9
11
  end
10
12
 
11
13
  Document = openapi_class.call()
12
14
 
13
15
  # naming these is not strictly necessary, but is nice to have.
14
- # generated: puts openapi_schema_doc['definitions'].select { |k,v| ['object', nil].include?(v['type']) }.keys.map { |k| "#{k[0].upcase}#{k[1..-1]} = openapi_class.call('definitions', '#{k}')" }
15
- Info = openapi_class.call('definitions', 'info')
16
- Contact = openapi_class.call('definitions', 'contact')
17
- License = openapi_class.call('definitions', 'license')
18
- Server = openapi_class.call('definitions', 'server')
19
- ServerVariable = openapi_class.call('definitions', 'serverVariable')
20
- Components = openapi_class.call('definitions', 'components')
21
- Paths = openapi_class.call('definitions', 'paths')
22
- PathItem = openapi_class.call('definitions', 'pathItem')
23
- Operation = openapi_class.call('definitions', 'operation')
24
- ExternalDocs = openapi_class.call('definitions', 'externalDocs')
25
- Parameter = openapi_class.call('definitions', 'parameter')
26
- RequestBody = openapi_class.call('definitions', 'requestBody')
27
- MediaType = openapi_class.call('definitions', 'mediaType')
28
- Encoding = openapi_class.call('definitions', 'encoding')
29
- Responses = openapi_class.call('definitions', 'responses')
30
- Response = openapi_class.call('definitions', 'response')
31
- Callback = openapi_class.call('definitions', 'callback')
32
- Example = openapi_class.call('definitions', 'example')
33
- Link = openapi_class.call('definitions', 'link')
34
- Header = openapi_class.call('definitions', 'header')
35
- Tag = openapi_class.call('definitions', 'tag')
36
- Examples = openapi_class.call('definitions', 'examples')
37
- Reference = openapi_class.call('definitions', 'reference')
38
- Schema = openapi_class.call('definitions', 'schema')
39
- Discriminator = openapi_class.call('definitions', 'discriminator')
40
- Xml = openapi_class.call('definitions', 'xml')
41
- SecurityScheme = openapi_class.call('definitions', 'securityScheme')
42
- OauthFlows = openapi_class.call('definitions', 'oauthFlows')
43
- OauthFlow = openapi_class.call('definitions', 'oauthFlow')
44
- SecurityRequirement = openapi_class.call('definitions', 'securityRequirement')
45
- AnyOrExpression = openapi_class.call('definitions', 'anyOrExpression')
46
- CallbackOrReference = openapi_class.call('definitions', 'callbackOrReference')
47
- ExampleOrReference = openapi_class.call('definitions', 'exampleOrReference')
48
- HeaderOrReference = openapi_class.call('definitions', 'headerOrReference')
49
- LinkOrReference = openapi_class.call('definitions', 'linkOrReference')
50
- ParameterOrReference = openapi_class.call('definitions', 'parameterOrReference')
51
- RequestBodyOrReference = openapi_class.call('definitions', 'requestBodyOrReference')
52
- ResponseOrReference = openapi_class.call('definitions', 'responseOrReference')
53
- SchemaOrReference = openapi_class.call('definitions', 'schemaOrReference')
54
- SecuritySchemeOrReference = openapi_class.call('definitions', 'securitySchemeOrReference')
55
- AnysOrExpressions = openapi_class.call('definitions', 'anysOrExpressions')
56
- CallbacksOrReferences = openapi_class.call('definitions', 'callbacksOrReferences')
57
- Encodings = openapi_class.call('definitions', 'encodings')
58
- ExamplesOrReferences = openapi_class.call('definitions', 'examplesOrReferences')
59
- HeadersOrReferences = openapi_class.call('definitions', 'headersOrReferences')
60
- LinksOrReferences = openapi_class.call('definitions', 'linksOrReferences')
61
- MediaTypes = openapi_class.call('definitions', 'mediaTypes')
62
- ParametersOrReferences = openapi_class.call('definitions', 'parametersOrReferences')
63
- RequestBodiesOrReferences = openapi_class.call('definitions', 'requestBodiesOrReferences')
64
- ResponsesOrReferences = openapi_class.call('definitions', 'responsesOrReferences')
65
- SchemasOrReferences = openapi_class.call('definitions', 'schemasOrReferences')
16
+ # generated: puts Scorpio::OpenAPI::V3::Document.schema['definitions'].select { |k,v| ['object', nil].include?(v['type']) }.keys.map { |k| "#{k[0].upcase}#{k[1..-1]} = openapi_class.call('definitions', '#{k}')" }
17
+ Info = openapi_class.call('definitions', 'info')
18
+ Contact = openapi_class.call('definitions', 'contact')
19
+ License = openapi_class.call('definitions', 'license')
20
+ Server = openapi_class.call('definitions', 'server')
21
+ ServerVariable = openapi_class.call('definitions', 'serverVariable')
22
+ Components = openapi_class.call('definitions', 'components')
23
+ Paths = openapi_class.call('definitions', 'paths')
24
+ PathItem = openapi_class.call('definitions', 'pathItem')
25
+ Operation = openapi_class.call('definitions', 'operation')
26
+ ExternalDocs = openapi_class.call('definitions', 'externalDocs')
27
+ Parameter = openapi_class.call('definitions', 'parameter')
28
+ RequestBody = openapi_class.call('definitions', 'requestBody')
29
+ MediaType = openapi_class.call('definitions', 'mediaType')
30
+ Encoding = openapi_class.call('definitions', 'encoding')
31
+ Responses = openapi_class.call('definitions', 'responses')
32
+ Response = openapi_class.call('definitions', 'response')
33
+ Callback = openapi_class.call('definitions', 'callback')
34
+ Example = openapi_class.call('definitions', 'example')
35
+ Link = openapi_class.call('definitions', 'link')
36
+ Header = openapi_class.call('definitions', 'header')
37
+ Tag = openapi_class.call('definitions', 'tag')
38
+ Examples = openapi_class.call('definitions', 'examples')
39
+ Reference = openapi_class.call('definitions', 'reference')
40
+ Schema = openapi_class.call('definitions', 'schema')
41
+ Discriminator = openapi_class.call('definitions', 'discriminator')
42
+ Xml = openapi_class.call('definitions', 'xml')
43
+ SecurityScheme = openapi_class.call('definitions', 'securityScheme')
44
+ OauthFlows = openapi_class.call('definitions', 'oauthFlows')
45
+ OauthFlow = openapi_class.call('definitions', 'oauthFlow')
46
+ SecurityRequirement = openapi_class.call('definitions', 'securityRequirement')
47
+ AnyOrExpression = openapi_class.call('definitions', 'anyOrExpression')
48
+ CallbackOrReference = openapi_class.call('definitions', 'callbackOrReference')
49
+ ExampleOrReference = openapi_class.call('definitions', 'exampleOrReference')
50
+ HeaderOrReference = openapi_class.call('definitions', 'headerOrReference')
51
+ LinkOrReference = openapi_class.call('definitions', 'linkOrReference')
52
+ ParameterOrReference = openapi_class.call('definitions', 'parameterOrReference')
53
+ RequestBodyOrReference = openapi_class.call('definitions', 'requestBodyOrReference')
54
+ ResponseOrReference = openapi_class.call('definitions', 'responseOrReference')
55
+ SchemaOrReference = openapi_class.call('definitions', 'schemaOrReference')
56
+ SecuritySchemeOrReference = openapi_class.call('definitions', 'securitySchemeOrReference')
57
+ AnysOrExpressions = openapi_class.call('definitions', 'anysOrExpressions')
58
+ CallbacksOrReferences = openapi_class.call('definitions', 'callbacksOrReferences')
59
+ Encodings = openapi_class.call('definitions', 'encodings')
60
+ ExamplesOrReferences = openapi_class.call('definitions', 'examplesOrReferences')
61
+ HeadersOrReferences = openapi_class.call('definitions', 'headersOrReferences')
62
+ LinksOrReferences = openapi_class.call('definitions', 'linksOrReferences')
63
+ MediaTypes = openapi_class.call('definitions', 'mediaTypes')
64
+ ParametersOrReferences = openapi_class.call('definitions', 'parametersOrReferences')
65
+ RequestBodiesOrReferences = openapi_class.call('definitions', 'requestBodiesOrReferences')
66
+ ResponsesOrReferences = openapi_class.call('definitions', 'responsesOrReferences')
67
+ SchemasOrReferences = openapi_class.call('definitions', 'schemasOrReferences')
66
68
  SecuritySchemesOrReferences = openapi_class.call('definitions', 'securitySchemesOrReferences')
67
- ServerVariables = openapi_class.call('definitions', 'serverVariables')
68
- Strings = openapi_class.call('definitions', 'strings')
69
- Object = openapi_class.call('definitions', 'object')
70
- Any = openapi_class.call('definitions', 'any')
71
- Expression = openapi_class.call('definitions', 'expression')
72
- SpecificationExtension = openapi_class.call('definitions', 'specificationExtension')
73
- DefaultType = openapi_class.call('definitions', 'defaultType')
69
+ ServerVariables = openapi_class.call('definitions', 'serverVariables')
70
+ Strings = openapi_class.call('definitions', 'strings')
71
+ Object = openapi_class.call('definitions', 'object')
72
+ Any = openapi_class.call('definitions', 'any')
73
+ Expression = openapi_class.call('definitions', 'expression')
74
+ SpecificationExtension = openapi_class.call('definitions', 'specificationExtension')
75
+ DefaultType = openapi_class.call('definitions', 'defaultType')
74
76
  end
75
77
  module V2
76
- openapi_schema = Scorpio::Schema.new(::JSON.parse(Scorpio.root.join('documents/swagger.io/v2/schema.json').read))
78
+ openapi_schema = JSI::Schema.new(::JSON.parse(Scorpio.root.join('documents/swagger.io/v2/schema.json').read))
77
79
  openapi_class = proc do |*key|
78
- Scorpio.class_for_schema(key.inject(openapi_schema, &:[]))
80
+ JSI.class_for_schema(key.inject(openapi_schema, &:[]))
79
81
  end
80
82
 
81
83
  Document = openapi_class.call()
82
84
 
83
85
  # naming these is not strictly necessary, but is nice to have.
84
- # generated: puts Scorpio::OpenAPI::V2::Document.schema_document['definitions'].select { |k,v| ['object', nil].include?(v['type']) }.keys.map { |k| "#{k[0].upcase}#{k[1..-1]} = openapi_class.call('definitions', '#{k}')" }
85
- Info = openapi_class.call('definitions', 'info')
86
- Contact = openapi_class.call('definitions', 'contact')
87
- License = openapi_class.call('definitions', 'license')
88
- Paths = openapi_class.call('definitions', 'paths')
89
- Definitions = openapi_class.call('definitions', 'definitions')
90
- ParameterDefinitions = openapi_class.call('definitions', 'parameterDefinitions')
91
- ResponseDefinitions = openapi_class.call('definitions', 'responseDefinitions')
92
- ExternalDocs = openapi_class.call('definitions', 'externalDocs')
93
- Examples = openapi_class.call('definitions', 'examples')
94
- Operation = openapi_class.call('definitions', 'operation')
95
- PathItem = openapi_class.call('definitions', 'pathItem')
96
- Responses = openapi_class.call('definitions', 'responses')
97
- ResponseValue = openapi_class.call('definitions', 'responseValue')
98
- Response = openapi_class.call('definitions', 'response')
99
- Headers = openapi_class.call('definitions', 'headers')
100
- Header = openapi_class.call('definitions', 'header')
101
- VendorExtension = openapi_class.call('definitions', 'vendorExtension')
102
- BodyParameter = openapi_class.call('definitions', 'bodyParameter')
103
- HeaderParameterSubSchema = openapi_class.call('definitions', 'headerParameterSubSchema')
104
- QueryParameterSubSchema = openapi_class.call('definitions', 'queryParameterSubSchema')
105
- FormDataParameterSubSchema = openapi_class.call('definitions', 'formDataParameterSubSchema')
106
- PathParameterSubSchema = openapi_class.call('definitions', 'pathParameterSubSchema')
107
- NonBodyParameter = openapi_class.call('definitions', 'nonBodyParameter')
108
- Parameter = openapi_class.call('definitions', 'parameter')
109
- Schema = openapi_class.call('definitions', 'schema')
110
- FileSchema = openapi_class.call('definitions', 'fileSchema')
111
- PrimitivesItems = openapi_class.call('definitions', 'primitivesItems')
112
- SecurityRequirement = openapi_class.call('definitions', 'securityRequirement')
113
- Xml = openapi_class.call('definitions', 'xml')
114
- Tag = openapi_class.call('definitions', 'tag')
115
- SecurityDefinitions = openapi_class.call('definitions', 'securityDefinitions')
86
+ # generated: puts Scorpio::OpenAPI::V2::Document.schema['definitions'].select { |k,v| ['object', nil].include?(v['type']) }.keys.map { |k| "#{k[0].upcase}#{k[1..-1]} = openapi_class.call('definitions', '#{k}')" }
87
+ Info = openapi_class.call('definitions', 'info')
88
+ Contact = openapi_class.call('definitions', 'contact')
89
+ License = openapi_class.call('definitions', 'license')
90
+ Paths = openapi_class.call('definitions', 'paths')
91
+ Definitions = openapi_class.call('definitions', 'definitions')
92
+ ParameterDefinitions = openapi_class.call('definitions', 'parameterDefinitions')
93
+ ResponseDefinitions = openapi_class.call('definitions', 'responseDefinitions')
94
+ ExternalDocs = openapi_class.call('definitions', 'externalDocs')
95
+ Examples = openapi_class.call('definitions', 'examples')
96
+ Operation = openapi_class.call('definitions', 'operation')
97
+ PathItem = openapi_class.call('definitions', 'pathItem')
98
+ Responses = openapi_class.call('definitions', 'responses')
99
+ ResponseValue = openapi_class.call('definitions', 'responseValue')
100
+ Response = openapi_class.call('definitions', 'response')
101
+ Headers = openapi_class.call('definitions', 'headers')
102
+ Header = openapi_class.call('definitions', 'header')
103
+ VendorExtension = openapi_class.call('definitions', 'vendorExtension')
104
+ BodyParameter = openapi_class.call('definitions', 'bodyParameter')
105
+ HeaderParameterSubSchema = openapi_class.call('definitions', 'headerParameterSubSchema')
106
+ QueryParameterSubSchema = openapi_class.call('definitions', 'queryParameterSubSchema')
107
+ FormDataParameterSubSchema = openapi_class.call('definitions', 'formDataParameterSubSchema')
108
+ PathParameterSubSchema = openapi_class.call('definitions', 'pathParameterSubSchema')
109
+ NonBodyParameter = openapi_class.call('definitions', 'nonBodyParameter')
110
+ Parameter = openapi_class.call('definitions', 'parameter')
111
+ Schema = openapi_class.call('definitions', 'schema')
112
+ FileSchema = openapi_class.call('definitions', 'fileSchema')
113
+ PrimitivesItems = openapi_class.call('definitions', 'primitivesItems')
114
+ SecurityRequirement = openapi_class.call('definitions', 'securityRequirement')
115
+ Xml = openapi_class.call('definitions', 'xml')
116
+ Tag = openapi_class.call('definitions', 'tag')
117
+ SecurityDefinitions = openapi_class.call('definitions', 'securityDefinitions')
116
118
  BasicAuthenticationSecurity = openapi_class.call('definitions', 'basicAuthenticationSecurity')
117
- ApiKeySecurity = openapi_class.call('definitions', 'apiKeySecurity')
118
- Oauth2ImplicitSecurity = openapi_class.call('definitions', 'oauth2ImplicitSecurity')
119
- Oauth2PasswordSecurity = openapi_class.call('definitions', 'oauth2PasswordSecurity')
120
- Oauth2ApplicationSecurity = openapi_class.call('definitions', 'oauth2ApplicationSecurity')
121
- Oauth2AccessCodeSecurity = openapi_class.call('definitions', 'oauth2AccessCodeSecurity')
122
- Oauth2Scopes = openapi_class.call('definitions', 'oauth2Scopes')
123
- Title = openapi_class.call('definitions', 'title')
124
- Description = openapi_class.call('definitions', 'description')
125
- Default = openapi_class.call('definitions', 'default')
126
- MultipleOf = openapi_class.call('definitions', 'multipleOf')
127
- Maximum = openapi_class.call('definitions', 'maximum')
128
- ExclusiveMaximum = openapi_class.call('definitions', 'exclusiveMaximum')
129
- Minimum = openapi_class.call('definitions', 'minimum')
130
- ExclusiveMinimum = openapi_class.call('definitions', 'exclusiveMinimum')
131
- MaxLength = openapi_class.call('definitions', 'maxLength')
132
- MinLength = openapi_class.call('definitions', 'minLength')
133
- Pattern = openapi_class.call('definitions', 'pattern')
134
- MaxItems = openapi_class.call('definitions', 'maxItems')
135
- MinItems = openapi_class.call('definitions', 'minItems')
136
- UniqueItems = openapi_class.call('definitions', 'uniqueItems')
137
- Enum = openapi_class.call('definitions', 'enum')
138
- JsonReference = openapi_class.call('definitions', 'jsonReference')
119
+ ApiKeySecurity = openapi_class.call('definitions', 'apiKeySecurity')
120
+ Oauth2ImplicitSecurity = openapi_class.call('definitions', 'oauth2ImplicitSecurity')
121
+ Oauth2PasswordSecurity = openapi_class.call('definitions', 'oauth2PasswordSecurity')
122
+ Oauth2ApplicationSecurity = openapi_class.call('definitions', 'oauth2ApplicationSecurity')
123
+ Oauth2AccessCodeSecurity = openapi_class.call('definitions', 'oauth2AccessCodeSecurity')
124
+ Oauth2Scopes = openapi_class.call('definitions', 'oauth2Scopes')
125
+ Title = openapi_class.call('definitions', 'title')
126
+ Description = openapi_class.call('definitions', 'description')
127
+ Default = openapi_class.call('definitions', 'default')
128
+ MultipleOf = openapi_class.call('definitions', 'multipleOf')
129
+ Maximum = openapi_class.call('definitions', 'maximum')
130
+ ExclusiveMaximum = openapi_class.call('definitions', 'exclusiveMaximum')
131
+ Minimum = openapi_class.call('definitions', 'minimum')
132
+ ExclusiveMinimum = openapi_class.call('definitions', 'exclusiveMinimum')
133
+ MaxLength = openapi_class.call('definitions', 'maxLength')
134
+ MinLength = openapi_class.call('definitions', 'minLength')
135
+ Pattern = openapi_class.call('definitions', 'pattern')
136
+ MaxItems = openapi_class.call('definitions', 'maxItems')
137
+ MinItems = openapi_class.call('definitions', 'minItems')
138
+ UniqueItems = openapi_class.call('definitions', 'uniqueItems')
139
+ Enum = openapi_class.call('definitions', 'enum')
140
+ JsonReference = openapi_class.call('definitions', 'jsonReference')
141
+ end
139
142
 
140
- class Operation
141
- attr_writer :path
142
- attr_writer :http_method
143
- def path
144
- @path ||= if parent.is_a?(Scorpio::OpenAPI::V2::PathItem) && parent.parent.is_a?(Scorpio::OpenAPI::V2::Paths)
145
- parent.instance.path.last
146
- end
147
- end
148
- def http_method
149
- @http_method ||= if parent.is_a?(Scorpio::OpenAPI::V2::PathItem)
150
- instance.path.last
151
- end
152
- end
143
+ begin
144
+ # the autoloads for OpenAPI::Operation and OpenAPI::Document
145
+ # should not be triggered until all the classes their files reference are defined (above)
146
+ end # (this block is here just so the above informative comment is not interpreted as module doc)
153
147
 
154
- # there should only be one body parameter; this returns it
155
- def body_parameter
156
- (parameters || []).detect do |parameter|
157
- parameter['in'] == 'body'
158
- end
159
- end
148
+ module V3
149
+ class Operation
150
+ include OpenAPI::Operation
151
+ end
152
+ class Document
153
+ include OpenAPI::Document
154
+ end
155
+ require 'scorpio/openapi/v3/server'
156
+ end
160
157
 
161
- def request_schema
162
- if body_parameter && body_parameter['schema']
163
- Scorpio::Schema.new(body_parameter['schema'])
164
- end
165
- end
158
+ module V2
159
+ class Operation
160
+ include OpenAPI::Operation
161
+ end
162
+ class Document
163
+ include OpenAPI::Document
166
164
  end
167
165
  end
168
166
  end