openapi_blocks 0.3.0 → 0.4.1

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.
@@ -16,15 +16,17 @@ module OpenapiBlocks
16
16
  schemas = @openapi_classes.each_with_object({}) do |klass, hash|
17
17
  schema_klass = klass.respond_to?(:_resource) && klass._resource ? klass._resource : klass
18
18
 
19
- begin
20
- next unless schema_klass.model
19
+ model = begin
20
+ schema_klass.model
21
21
  rescue StandardError
22
22
  next
23
23
  end
24
24
 
25
- schema_name = schema_klass.model.name
25
+ next unless model
26
+
27
+ schema_name = model.name
26
28
  extractor = Schema::Extractor.new(schema_klass)
27
- validator = Schema::Validator.new(schema_klass.model)
29
+ validator = Schema::Validator.new(model)
28
30
 
29
31
  schema = extractor.extract
30
32
  schema[:properties] = merge_validations(schema[:properties], validator.extract)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OpenapiBlocks
4
- VERSION = "0.3.0"
4
+ VERSION = "0.4.1"
5
5
  end
@@ -18,13 +18,17 @@ require_relative "openapi_blocks/spec/components"
18
18
  require_relative "openapi_blocks/spec/paths"
19
19
  require_relative "openapi_blocks/spec/document"
20
20
  require_relative "openapi_blocks/builder"
21
- require_relative "openapi_blocks/serializer"
22
- require_relative "openapi_blocks/base"
23
21
  require_relative "openapi_blocks/engine"
24
22
  require_relative "openapi_blocks/railtie"
25
23
  require_relative "openapi_blocks/operation_builder"
26
- require_relative "openapi_blocks/resource"
24
+ require_relative "openapi_blocks/concerns/schemable"
25
+ require_relative "openapi_blocks/concerns/documentable"
26
+ require_relative "openapi_blocks/serialization"
27
+ require_relative "openapi_blocks/base"
28
+ require_relative "openapi_blocks/serializer"
27
29
  require_relative "openapi_blocks/controller"
30
+ require_relative "openapi_blocks/registry"
31
+ require_relative "openapi_blocks/auto_serialize"
28
32
 
29
33
  module OpenapiBlocks # rubocop:disable Style/Documentation
30
34
  class Error < StandardError; end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openapi_blocks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Caio Santos
@@ -122,7 +122,9 @@ dependencies:
122
122
  - !ruby/object:Gem::Version
123
123
  version: '2.1'
124
124
  description: Generates OpenAPI specs automatically from ActiveRecord models, ActiveModel
125
- validations and Rails routes, inspired by ActiveModel::Serializer.
125
+ validations and Rails routes. Includes a built-in serializer ~3.6x faster than as_json,
126
+ Scalar and Swagger UI out of the box, and optional auto-serialization via render
127
+ json:. Inspired by ActiveModel::Serializer.
126
128
  email:
127
129
  - caio.francelinosena@gmail.com
128
130
  executables: []
@@ -138,9 +140,12 @@ files:
138
140
  - app/controllers/openapi_blocks/spec_controller.rb
139
141
  - config/routes.rb
140
142
  - lib/openapi_blocks.rb
143
+ - lib/openapi_blocks/auto_serialize.rb
141
144
  - lib/openapi_blocks/base.rb
142
145
  - lib/openapi_blocks/builder.rb
143
146
  - lib/openapi_blocks/cache.rb
147
+ - lib/openapi_blocks/concerns/documentable.rb
148
+ - lib/openapi_blocks/concerns/schemable.rb
144
149
  - lib/openapi_blocks/configuration.rb
145
150
  - lib/openapi_blocks/configuration/contact_builder.rb
146
151
  - lib/openapi_blocks/configuration/info_builder.rb
@@ -154,12 +159,13 @@ files:
154
159
  - lib/openapi_blocks/middleware.rb
155
160
  - lib/openapi_blocks/operation_builder.rb
156
161
  - lib/openapi_blocks/railtie.rb
157
- - lib/openapi_blocks/resource.rb
162
+ - lib/openapi_blocks/registry.rb
158
163
  - lib/openapi_blocks/routing/extractor.rb
159
164
  - lib/openapi_blocks/routing/operation.rb
160
165
  - lib/openapi_blocks/schema/extractor.rb
161
166
  - lib/openapi_blocks/schema/types.rb
162
167
  - lib/openapi_blocks/schema/validator.rb
168
+ - lib/openapi_blocks/serialization.rb
163
169
  - lib/openapi_blocks/serializer.rb
164
170
  - lib/openapi_blocks/spec/components.rb
165
171
  - lib/openapi_blocks/spec/document.rb
@@ -188,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
188
194
  - !ruby/object:Gem::Version
189
195
  version: '0'
190
196
  requirements: []
191
- rubygems_version: 4.0.9
197
+ rubygems_version: 4.0.3
192
198
  specification_version: 4
193
- summary: DSL to generate OpenAPI 3.0/3.1 documentation for Rails applications
199
+ summary: OpenAPI 3.0/3.1 documentation and high-performance serializer for Rails
194
200
  test_files: []
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module OpenapiBlocks
4
- class Resource < Base # rubocop:disable Style/Documentation
5
- class << self
6
- private
7
-
8
- def infer_model
9
- model_name = name
10
- .gsub(/Resource$/, "")
11
- .split("::")
12
- .last
13
-
14
- Object.const_get(model_name)
15
- rescue NameError
16
- raise Error, "Could not infer model from #{name}. Use `model ModelClass` to define it explicitly."
17
- end
18
- end
19
- end
20
- end