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.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +0 -0
- data/.gitignore +0 -0
- data/.prettierrc +0 -0
- data/.rspec +0 -0
- data/.rubocop.yml +0 -0
- data/.rubocop_airbnb.yml +0 -0
- data/CHANGELOG.md +12 -0
- data/Gemfile +0 -0
- data/LICENSE +0 -0
- data/README.md +11 -10
- data/Rakefile +0 -0
- data/bin/console +0 -0
- data/bin/fmt +0 -0
- data/bin/setup +0 -0
- data/lib/swagger/schema/component.rb +0 -0
- data/lib/swagger/schema/component_set.rb +19 -0
- data/lib/swagger/schema/components.rb +21 -0
- data/lib/swagger/schema/content.rb +0 -0
- data/lib/swagger/schema/handle_servers.rb +0 -0
- data/lib/swagger/schema/header.rb +0 -0
- data/lib/swagger/schema/headers.rb +0 -0
- data/lib/swagger/schema/media_type/deserializer.rb +0 -0
- data/lib/swagger/schema/media_type/validator.rb +0 -0
- data/lib/swagger/schema/media_type.rb +0 -0
- data/lib/swagger/schema/operation.rb +0 -0
- data/lib/swagger/schema/parameter.rb +0 -0
- data/lib/swagger/schema/parameter_base.rb +0 -0
- data/lib/swagger/schema/parameters/deserializer.rb +0 -0
- data/lib/swagger/schema/parameters/validator.rb +0 -0
- data/lib/swagger/schema/parameters.rb +0 -0
- data/lib/swagger/schema/path_item.rb +0 -0
- data/lib/swagger/schema/request_body.rb +0 -0
- data/lib/swagger/schema/response.rb +0 -0
- data/lib/swagger/schema/responses.rb +0 -0
- data/lib/swagger/schema/schema_accessor.rb +0 -0
- data/lib/swagger/schema/server.rb +0 -0
- data/lib/swagger/schema/util.rb +0 -0
- data/lib/swagger/schema.rb +5 -7
- data/lib/swagger/serializer/model.rb +1 -1
- data/lib/swagger/serializer/rails_controller.rb +0 -0
- data/lib/swagger/serializer/store.rb +3 -2
- data/lib/swagger/serializer/version.rb +1 -1
- data/lib/swagger/serializer.rb +2 -2
- data/swagger-serializer.gemspec +1 -1
- metadata +18 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bbb250d6c1883291921652478c9a65725bf1c81a9d6ce93280160157ffbfd806
|
4
|
+
data.tar.gz: b653e8be0346bb4ca79d8283edcba2ce53426afd50a7e178b833541dcd0aa674
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7f88dec0338b293ec30285ebdb167264e546cb809a322b716e19cd92711ac89721c919b2b2a5749ffea53dfbdcf033fc3c5455ab93de3edfebdcdfb810c8951
|
7
|
+
data.tar.gz: dbccb3a869dc576bb118999dce2183620d93f6ff8808bd6de0352f72542930080df3298f0b8cbde05608661cffd0e5c3466e56bba9f5e48f1b0a57b934af8583
|
data/.github/workflows/ruby.yml
CHANGED
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
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
|
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
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
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
|
data/lib/swagger/schema/util.rb
CHANGED
File without changes
|
data/lib/swagger/schema.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require_relative "./schema/
|
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
|
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
|
40
|
-
|
41
|
-
|
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.
|
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] ||=
|
32
|
+
@injectors[name] ||= serializer_name.safe_constantize
|
32
33
|
else
|
33
|
-
|
34
|
+
serializer_name.safe_constantize
|
34
35
|
end
|
35
36
|
end
|
36
37
|
end
|
data/lib/swagger/serializer.rb
CHANGED
data/swagger-serializer.gemspec
CHANGED
@@ -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", "
|
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.
|
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:
|
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.
|
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
|
-
|
254
|
-
|
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: []
|