blueprinter_schema 1.0.1 → 1.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9246edd433fe3a71df7924c38bfd92928af95ddfdc90aebab7285ed6270e3fdc
4
- data.tar.gz: 228234c8612cdf7e8b728e67974831263bc077864ea6ec0f0608d6c23c8cbe8b
3
+ metadata.gz: 79f76768380ae6cbe77da6ec153325e079ca2d5ee30df459378e0ebb90f674c2
4
+ data.tar.gz: 50a119f7dd0fb32789a24ed6ccddd05026a0bb8525f4c5c60f94f232edcc3e31
5
5
  SHA512:
6
- metadata.gz: e1d5833548d59cb364765ea3db2bee8c50c13fadb12bd18e742014e48c8636de6a1ef4519ab79ac8c194b3301fa5dc9b0f9cdd61da70383d052e50687619a496
7
- data.tar.gz: 3e731df8e7f2ac8736fda0fdcd40797b6ec024297cb186c255e71087fdb9a6a9db365517c5dd9fb25a24ea5f128c2c49b5e1aebef1fd83f8ecd500f22fc82d23
6
+ metadata.gz: f057fdac75f35be16f955cbc083326ab32940ed5210ec8ed26922b4614741e0371e0e762371081d7afdf31dbee97d7fc14794650bde811ef636f3de64a2cb52f
7
+ data.tar.gz: e82e0011242c7838709c55c2d4d6ca8d2a43e620a6ff7c244c9fc70b816e6dd7c211a995ebea6fd57390744c0523d2b467168e9fc52e8bdec02ecebb10888811
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blueprinter_schema",
3
- "dockerComposeFile": "../docker-compose.yml",
3
+ "dockerComposeFile": "../compose.yml",
4
4
  "service": "ruby",
5
5
  "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
6
6
 
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 4.0.1
data/Dockerfile CHANGED
@@ -4,7 +4,6 @@
4
4
  ARG RUBY_VERSION=3.4.3
5
5
  FROM docker.io/library/ruby:$RUBY_VERSION-slim
6
6
 
7
- # Rails app lives here
8
7
  WORKDIR /workspaces/blueprinter_schema
9
8
 
10
9
  # Install packages needed to build gems
data/README.md CHANGED
@@ -47,7 +47,7 @@ BlueprinterSchema.generate(serializer: UserSerializer)
47
47
  }
48
48
  ```
49
49
 
50
- You can pass an ActiveRecord Model to automatically infer types from DB fields:
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
- You can use associations:
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).
@@ -74,6 +74,7 @@ module BlueprinterSchema
74
74
  type_definition = ar_column_to_json_schema(column)
75
75
  end
76
76
 
77
+ type_definition['items'] = field.options[:items].deep_stringify_keys if field.options[:items]
77
78
  type_definition['format'] = field.options[:format] if field.options[:format]
78
79
  type_definition['description'] = field.options[:description] if field.options[:description]
79
80
  type_definition
@@ -127,18 +128,19 @@ module BlueprinterSchema
127
128
  ar_association = @model&.reflect_on_association(association.name)
128
129
  is_collection = ar_association ? ar_association.collection? : association.options[:collection]
129
130
 
130
- associated_schema = recursive_generate(blueprint_class, ar_association&.klass)
131
+ view = association.options[:view] || :default
132
+ associated_schema = recursive_generate(blueprint_class, ar_association&.klass, view)
131
133
 
132
134
  is_collection ? { 'type' => 'array', 'items' => associated_schema } : associated_schema
133
135
  end
134
136
 
135
- def recursive_generate(serializer, model)
137
+ def recursive_generate(serializer, model, view)
136
138
  BlueprinterSchema.generate(
137
139
  serializer:,
138
140
  model:,
139
141
  skip_conditional_fields: @skip_conditional_fields,
140
142
  fallback_definition: @fallback_definition,
141
- view: @view
143
+ view:
142
144
  )
143
145
  end
144
146
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BlueprinterSchema
4
- VERSION = '1.0.1'
4
+ VERSION = '1.1.0'
5
5
  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.1
4
+ version: 1.1.0
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
- - ".ruby-version"
21
+ - ".tool-versions"
22
22
  - Dockerfile
23
23
  - LICENSE.txt
24
24
  - README.md
25
25
  - Rakefile
26
- - docker-compose.yml
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: 3.6.7
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