blueprinter_schema 1.0.1 → 1.0.2
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.
- checksums.yaml +4 -4
- data/.devcontainer/devcontainer.json +1 -1
- data/.tool-versions +1 -0
- data/Dockerfile +0 -1
- data/README.md +3 -9
- data/lib/blueprinter_schema/generator.rb +4 -3
- data/lib/blueprinter_schema/version.rb +1 -1
- metadata +4 -4
- data/.ruby-version +0 -1
- /data/{docker-compose.yml → compose.yml} +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 62a979f21048d765a9ee74d4525c1d15e354c079432beef7ba8d730b4f8f2dd0
|
|
4
|
+
data.tar.gz: 778688f0c08a12f682b0fd8aa82a3b0ecbe25c96f82172d92ebf884230cba7fd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '08fbf14b76e149fd139b7678c8e06908f12c06858e90d42b9f5f28d71155a12317b4ed5efb8ffd9f399b7348a7074ae8d710ae266638c6bae7931a594aed87dd'
|
|
7
|
+
data.tar.gz: 997fa37f5e23f7a6081ea52a377afe58a22498b414f6cfd31cfb4ba6eef2c15d10bb496947e776c48257bf08c357bd351406730211da629efec508c971a2a5fd
|
data/.tool-versions
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ruby 4.0.1
|
data/Dockerfile
CHANGED
data/README.md
CHANGED
|
@@ -47,7 +47,7 @@ BlueprinterSchema.generate(serializer: UserSerializer)
|
|
|
47
47
|
}
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
### Pass an ActiveRecord Model to automatically infer types from DB fields:
|
|
51
51
|
|
|
52
52
|
```rb
|
|
53
53
|
class UserSerializer < Blueprinter::Base
|
|
@@ -82,7 +82,7 @@ BlueprinterSchema.generate(serializer: UserSerializer, model: User)
|
|
|
82
82
|
}
|
|
83
83
|
```
|
|
84
84
|
|
|
85
|
-
|
|
85
|
+
### Use associations:
|
|
86
86
|
|
|
87
87
|
```rb
|
|
88
88
|
class UserSerializer < Blueprinter::Base
|
|
@@ -156,16 +156,10 @@ BlueprinterSchema.generate(
|
|
|
156
156
|
Devcontainer / Codespaces / Native
|
|
157
157
|
|
|
158
158
|
```sh
|
|
159
|
+
mise install
|
|
159
160
|
bin/setup
|
|
160
161
|
```
|
|
161
162
|
|
|
162
|
-
Docker
|
|
163
|
-
|
|
164
|
-
```sh
|
|
165
|
-
docker compose up -d
|
|
166
|
-
docker compose exec ruby bin/setup
|
|
167
|
-
```
|
|
168
|
-
|
|
169
163
|
Then, run `bundle exec rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
170
164
|
|
|
171
165
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
@@ -127,18 +127,19 @@ module BlueprinterSchema
|
|
|
127
127
|
ar_association = @model&.reflect_on_association(association.name)
|
|
128
128
|
is_collection = ar_association ? ar_association.collection? : association.options[:collection]
|
|
129
129
|
|
|
130
|
-
|
|
130
|
+
view = association.options[:view] || :default
|
|
131
|
+
associated_schema = recursive_generate(blueprint_class, ar_association&.klass, view)
|
|
131
132
|
|
|
132
133
|
is_collection ? { 'type' => 'array', 'items' => associated_schema } : associated_schema
|
|
133
134
|
end
|
|
134
135
|
|
|
135
|
-
def recursive_generate(serializer, model)
|
|
136
|
+
def recursive_generate(serializer, model, view)
|
|
136
137
|
BlueprinterSchema.generate(
|
|
137
138
|
serializer:,
|
|
138
139
|
model:,
|
|
139
140
|
skip_conditional_fields: @skip_conditional_fields,
|
|
140
141
|
fallback_definition: @fallback_definition,
|
|
141
|
-
view:
|
|
142
|
+
view:
|
|
142
143
|
)
|
|
143
144
|
end
|
|
144
145
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: blueprinter_schema
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- thisismydesign
|
|
@@ -18,12 +18,12 @@ files:
|
|
|
18
18
|
- ".devcontainer/devcontainer.json"
|
|
19
19
|
- ".rspec"
|
|
20
20
|
- ".rubocop.yml"
|
|
21
|
-
- ".
|
|
21
|
+
- ".tool-versions"
|
|
22
22
|
- Dockerfile
|
|
23
23
|
- LICENSE.txt
|
|
24
24
|
- README.md
|
|
25
25
|
- Rakefile
|
|
26
|
-
-
|
|
26
|
+
- compose.yml
|
|
27
27
|
- lib/blueprinter_schema.rb
|
|
28
28
|
- lib/blueprinter_schema/generator.rb
|
|
29
29
|
- lib/blueprinter_schema/version.rb
|
|
@@ -49,7 +49,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
49
49
|
- !ruby/object:Gem::Version
|
|
50
50
|
version: '0'
|
|
51
51
|
requirements: []
|
|
52
|
-
rubygems_version:
|
|
52
|
+
rubygems_version: 4.0.3
|
|
53
53
|
specification_version: 4
|
|
54
54
|
summary: Create JSON Schema from Blueprinter serializers and ActiveRecord Models.
|
|
55
55
|
test_files: []
|
data/.ruby-version
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
ruby-3.4.3
|
|
File without changes
|