swagger-serializer 0.8.1 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +0 -0
  3. data/.gitignore +0 -0
  4. data/.prettierrc +0 -0
  5. data/.rspec +0 -0
  6. data/.rubocop.yml +0 -0
  7. data/.rubocop_airbnb.yml +0 -0
  8. data/CHANGELOG.md +12 -0
  9. data/Gemfile +0 -0
  10. data/LICENSE +0 -0
  11. data/README.md +11 -10
  12. data/Rakefile +0 -0
  13. data/bin/console +0 -0
  14. data/bin/fmt +0 -0
  15. data/bin/setup +0 -0
  16. data/lib/swagger/schema/component.rb +0 -0
  17. data/lib/swagger/schema/component_set.rb +19 -0
  18. data/lib/swagger/schema/components.rb +21 -0
  19. data/lib/swagger/schema/content.rb +0 -0
  20. data/lib/swagger/schema/handle_servers.rb +0 -0
  21. data/lib/swagger/schema/header.rb +0 -0
  22. data/lib/swagger/schema/headers.rb +0 -0
  23. data/lib/swagger/schema/media_type/deserializer.rb +0 -0
  24. data/lib/swagger/schema/media_type/validator.rb +0 -0
  25. data/lib/swagger/schema/media_type.rb +0 -0
  26. data/lib/swagger/schema/operation.rb +0 -0
  27. data/lib/swagger/schema/parameter.rb +0 -0
  28. data/lib/swagger/schema/parameter_base.rb +0 -0
  29. data/lib/swagger/schema/parameters/deserializer.rb +0 -0
  30. data/lib/swagger/schema/parameters/validator.rb +0 -0
  31. data/lib/swagger/schema/parameters.rb +0 -0
  32. data/lib/swagger/schema/path_item.rb +0 -0
  33. data/lib/swagger/schema/request_body.rb +0 -0
  34. data/lib/swagger/schema/response.rb +0 -0
  35. data/lib/swagger/schema/responses.rb +0 -0
  36. data/lib/swagger/schema/schema_accessor.rb +0 -0
  37. data/lib/swagger/schema/server.rb +0 -0
  38. data/lib/swagger/schema/util.rb +0 -0
  39. data/lib/swagger/schema.rb +5 -7
  40. data/lib/swagger/serializer/model.rb +1 -1
  41. data/lib/swagger/serializer/rails_controller.rb +0 -0
  42. data/lib/swagger/serializer/store.rb +3 -2
  43. data/lib/swagger/serializer/version.rb +1 -1
  44. data/lib/swagger/serializer.rb +2 -2
  45. data/swagger-serializer.gemspec +1 -1
  46. metadata +18 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7b762d9acb939ae91811002d9f0e439ea69668460f2cc76011e97d8110e5ed83
4
- data.tar.gz: b86c503146e5122e6c7b1441335d6b97616b444934c95b56ac3339b289fd6a72
3
+ metadata.gz: bbb250d6c1883291921652478c9a65725bf1c81a9d6ce93280160157ffbfd806
4
+ data.tar.gz: b653e8be0346bb4ca79d8283edcba2ce53426afd50a7e178b833541dcd0aa674
5
5
  SHA512:
6
- metadata.gz: 29bc447d31f6b1a50cf7a03f88ee17fd51fb49d6f7a4b47c49b49c84de0075d2ca957a811d471730b9cdd1ed9d7fe2febbaad17c35d5ccd20a7a7a4f97fcce33
7
- data.tar.gz: 04d105d4016fecc947ca791a082131d47b4e5f51bf8fbf01e6ca39806db9460402e969326ad8a241c41ecbb30088d461d01eeba480ecfcb6416d4fdb21bda352
6
+ metadata.gz: e7f88dec0338b293ec30285ebdb167264e546cb809a322b716e19cd92711ac89721c919b2b2a5749ffea53dfbdcf033fc3c5455ab93de3edfebdcdfb810c8951
7
+ data.tar.gz: dbccb3a869dc576bb118999dce2183620d93f6ff8808bd6de0352f72542930080df3298f0b8cbde05608661cffd0e5c3466e56bba9f5e48f1b0a57b934af8583
File without changes
data/.gitignore CHANGED
File without changes
data/.prettierrc CHANGED
File without changes
data/.rspec CHANGED
File without changes
data/.rubocop.yml CHANGED
File without changes
data/.rubocop_airbnb.yml CHANGED
File without changes
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.9.0
4
+
5
+ - mod(brake): adjust to OAS3 spec
6
+
7
+ ## 0.8.3
8
+
9
+ - add: class component
10
+
11
+ ## 0.7.0
12
+
13
+ - add: context
14
+
3
15
  ## 0.6.0
4
16
 
5
17
  - mod(brake): separate serialize_options and deserialize_options
data/Gemfile CHANGED
File without changes
data/LICENSE CHANGED
File without changes
data/README.md CHANGED
@@ -184,7 +184,7 @@ end
184
184
  Now you can get `{ "id" => 42, "name" => "me!!!!" }`.
185
185
 
186
186
  This serializer class detection uses the schema's `title` key.
187
- If you want to use `Foo::BarSerializer`, set `Foo::Bar` to `title` key.
187
+ If you want to use `Foo::BarSerializer`, set `Foo-Bar` to `title` key.
188
188
 
189
189
  The key is configurable by
190
190
 
@@ -219,15 +219,16 @@ info:
219
219
  title: example api
220
220
  version: 0.1.0
221
221
  components:
222
- User: &User
223
- title: User
224
- type: object
225
- properties:
226
- id:
227
- type: integer
228
- name:
229
- type: string
230
- required: [id]
222
+ schemas:
223
+ User: &User
224
+ title: User
225
+ type: object
226
+ properties:
227
+ id:
228
+ type: integer
229
+ name:
230
+ type: string
231
+ required: [id]
231
232
  paths:
232
233
  /users:
233
234
  get:
data/Rakefile CHANGED
File without changes
data/bin/console CHANGED
File without changes
data/bin/fmt CHANGED
File without changes
data/bin/setup CHANGED
File without changes
File without changes
@@ -0,0 +1,19 @@
1
+ require_relative "./util"
2
+ require_relative "./component"
3
+
4
+ module Swagger
5
+ class Schema
6
+ class ComponentSet
7
+ def initialize(schema)
8
+ @schema = schema
9
+ end
10
+
11
+ def [](name)
12
+ # HogeSerializer
13
+ name = name.name.sub(/Serializer$/, "").gsub(/::/, '-') if name.class == Class
14
+ component = Util.try_hash(@schema, name)
15
+ Component.new(component) if component
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,21 @@
1
+ require_relative "./util"
2
+ require_relative "./component_set"
3
+
4
+ module Swagger
5
+ class Schema
6
+ class Components
7
+ def initialize(schema)
8
+ @schema = schema
9
+ end
10
+
11
+ def [](name)
12
+ component_set = Util.try_hash(@schema, name)
13
+ ComponentSet.new(component_set) if component_set
14
+ end
15
+
16
+ def schemas
17
+ self[:schemas]
18
+ end
19
+ end
20
+ end
21
+ end
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,4 +1,4 @@
1
- require_relative "./schema/component"
1
+ require_relative "./schema/components"
2
2
  require_relative "./schema/path_item"
3
3
  require_relative "./schema/server"
4
4
  require_relative "./schema/schema_accessor"
@@ -29,18 +29,16 @@ module Swagger
29
29
  @schema = schema
30
30
  end
31
31
 
32
- define_schema_accessor :paths, :components
32
+ define_schema_accessor :paths
33
33
 
34
34
  def path(path)
35
35
  path_item = Util.try_hash(paths, path)
36
36
  PathItem.new(path_item) if path_item
37
37
  end
38
38
 
39
- def component(name)
40
- # HogeSerializer
41
- name = name.name.sub(/Serializer$/, "") if name.class == Class
42
- component = Util.try_hash(components, name)
43
- Component.new(component) if component
39
+ def components
40
+ components = Util.try_hash(@schema, 'components')
41
+ Components.new(components) if components
44
42
  end
45
43
  end
46
44
  end
@@ -1,7 +1,7 @@
1
1
  module Swagger::Serializer::Model
2
2
  def serialize(name = self.class.name)
3
3
  serializer =
4
- Swagger::Schema.current.component(name).serializer(Swagger::Serializer::Store.current.serialize_options)
4
+ Swagger::Schema.current.components.schemas[name].serializer(Swagger::Serializer::Store.current.serialize_options)
5
5
  serializer.serialize(self)
6
6
  end
7
7
  end
File without changes
@@ -27,10 +27,11 @@ module Swagger
27
27
  end
28
28
 
29
29
  def [](name)
30
+ serializer_name = name.to_s.gsub(/-/, '::').sub(/(?:Serializer)?$/, "Serializer")
30
31
  if @cache
31
- @injectors[name] ||= "#{name}Serializer".safe_constantize
32
+ @injectors[name] ||= serializer_name.safe_constantize
32
33
  else
33
- "#{name}Serializer".safe_constantize
34
+ serializer_name.safe_constantize
34
35
  end
35
36
  end
36
37
  end
@@ -1,5 +1,5 @@
1
1
  module Swagger
2
2
  module Serializer
3
- VERSION = "0.8.1".freeze
3
+ VERSION = "0.9.0".freeze
4
4
  end
5
5
  end
@@ -22,8 +22,8 @@ module Swagger
22
22
  end
23
23
  end
24
24
 
25
- def method_missing(name, *args)
26
- @model.public_send(name, *args)
25
+ def method_missing(name, *args, &block)
26
+ @model.public_send(name, *args, &block)
27
27
  end
28
28
 
29
29
  def nil?
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
27
27
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
28
  spec.require_paths = %w[lib]
29
29
 
30
- spec.add_dependency "json-schema-serializer", "~> 1.6"
30
+ spec.add_dependency "json-schema-serializer", [">= 1.6", "< 3"]
31
31
  spec.add_dependency "snake_camel", "~> 1.1"
32
32
  spec.add_development_dependency "bundler", "~> 2"
33
33
  spec.add_development_dependency "rake", "~> 13.0"
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swagger-serializer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Narazaka
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-18 00:00:00.000000000 Z
11
+ date: 2022-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json-schema-serializer
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.6'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '3'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
25
28
  - !ruby/object:Gem::Version
26
29
  version: '1.6'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '3'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: snake_camel
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -178,7 +184,7 @@ dependencies:
178
184
  - - "~>"
179
185
  - !ruby/object:Gem::Version
180
186
  version: '0.9'
181
- description:
187
+ description:
182
188
  email:
183
189
  - info@narazaka.net
184
190
  executables: []
@@ -201,6 +207,8 @@ files:
201
207
  - bin/setup
202
208
  - lib/swagger/schema.rb
203
209
  - lib/swagger/schema/component.rb
210
+ - lib/swagger/schema/component_set.rb
211
+ - lib/swagger/schema/components.rb
204
212
  - lib/swagger/schema/content.rb
205
213
  - lib/swagger/schema/handle_servers.rb
206
214
  - lib/swagger/schema/header.rb
@@ -234,8 +242,8 @@ metadata:
234
242
  homepage_uri: https://github.com/Narazaka/swagger-serializer
235
243
  source_code_uri: https://github.com/Narazaka/swagger-serializer.git
236
244
  changelog_uri: https://github.com/Narazaka/swagger-serializer/blob/master/CHANGELOG.md
237
- documentation_uri: https://www.rubydoc.info/gems/swagger-serializer/0.8.1
238
- post_install_message:
245
+ documentation_uri: https://www.rubydoc.info/gems/swagger-serializer/0.9.0
246
+ post_install_message:
239
247
  rdoc_options: []
240
248
  require_paths:
241
249
  - lib
@@ -250,9 +258,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
250
258
  - !ruby/object:Gem::Version
251
259
  version: '0'
252
260
  requirements: []
253
- rubyforge_project:
254
- rubygems_version: 2.7.6
255
- signing_key:
261
+ rubygems_version: 3.1.4
262
+ signing_key:
256
263
  specification_version: 4
257
264
  summary: Swagger (OpenAPI 3) schema based Serializer
258
265
  test_files: []