swagger-serializer 0.8.3 → 0.9.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: 64f8aa131df07ce9de11beb3384f3c8bd94431136b0fd0032b05bc1a102a06cd
4
- data.tar.gz: 56b1e7f8f3364a3df476bd12b4e08760c8dd5e8f39ebb079b15bc798a3a64d8c
3
+ metadata.gz: bbb250d6c1883291921652478c9a65725bf1c81a9d6ce93280160157ffbfd806
4
+ data.tar.gz: b653e8be0346bb4ca79d8283edcba2ce53426afd50a7e178b833541dcd0aa674
5
5
  SHA512:
6
- metadata.gz: f8c0b337e81158f0384139aca9be740108567bb6c8d3e94ac7d4d6d404a0353bec53505938771a1bd4fab010e7170dcf8659e35d20fe14113b59267477923cd2
7
- data.tar.gz: 97c6fc013f5e9339d23f38a1850fe20c4b5b21c0de715d7a5e0f1e019e33a6e95b52372b96503e00f411e194b376491656a0e0e5d5cf41237270c0dbc928b65f
6
+ metadata.gz: e7f88dec0338b293ec30285ebdb167264e546cb809a322b716e19cd92711ac89721c919b2b2a5749ffea53dfbdcf033fc3c5455ab93de3edfebdcdfb810c8951
7
+ data.tar.gz: dbccb3a869dc576bb118999dce2183620d93f6ff8808bd6de0352f72542930080df3298f0b8cbde05608661cffd0e5c3466e56bba9f5e48f1b0a57b934af8583
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/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:
@@ -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
@@ -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
@@ -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.3".freeze
3
+ VERSION = "0.9.0".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swagger-serializer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.3
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Narazaka
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-02-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
@@ -207,6 +207,8 @@ files:
207
207
  - bin/setup
208
208
  - lib/swagger/schema.rb
209
209
  - lib/swagger/schema/component.rb
210
+ - lib/swagger/schema/component_set.rb
211
+ - lib/swagger/schema/components.rb
210
212
  - lib/swagger/schema/content.rb
211
213
  - lib/swagger/schema/handle_servers.rb
212
214
  - lib/swagger/schema/header.rb
@@ -240,7 +242,7 @@ metadata:
240
242
  homepage_uri: https://github.com/Narazaka/swagger-serializer
241
243
  source_code_uri: https://github.com/Narazaka/swagger-serializer.git
242
244
  changelog_uri: https://github.com/Narazaka/swagger-serializer/blob/master/CHANGELOG.md
243
- documentation_uri: https://www.rubydoc.info/gems/swagger-serializer/0.8.3
245
+ documentation_uri: https://www.rubydoc.info/gems/swagger-serializer/0.9.0
244
246
  post_install_message:
245
247
  rdoc_options: []
246
248
  require_paths:
@@ -256,7 +258,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
256
258
  - !ruby/object:Gem::Version
257
259
  version: '0'
258
260
  requirements: []
259
- rubygems_version: 3.2.3
261
+ rubygems_version: 3.1.4
260
262
  signing_key:
261
263
  specification_version: 4
262
264
  summary: Swagger (OpenAPI 3) schema based Serializer