attributor 6.4 → 6.5

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: 7299ae5b05648dd2b4dd2f787734222f4037458a8531440a7891b3d9adfbda47
4
- data.tar.gz: cfa9c950f3628426bf1b8b00d9ea61cd2304ce7636eaf976fb993432fdd739bf
3
+ metadata.gz: 9242ef6d878ab79e69393d7bf31b6459873d39a8307c9dac0ea05ce8c4a01912
4
+ data.tar.gz: 0b2f333abe4957d1575df87c734c4f642274a83d50562059c33fb261154e44a5
5
5
  SHA512:
6
- metadata.gz: e840b98417976fd4fb49ca16b3c5863c0c3e3c76ef349771a2c189dec2795759186a80da6cc59320c834ad7bf68a013d2ed9f927ed1a0e55bb83c5dbb83b4470
7
- data.tar.gz: 1243afa58fb5a4f8309d66b3654d29dcda8542c655d99ed3351cb12ffc9541859aac8a736024f5e3789c013d73c2f1d0879cf4a8ded8dd93038282fcb0537657
6
+ metadata.gz: 48a0ea86f5550dd44b0d162ea96c1a98bbd7019955857f607817efe921fc4250c210e2591664d18a9388fd614d323547c83421b64ba678369c47d248423770ca
7
+ data.tar.gz: dcd17fa9b98e35d02e471ef340b641ba15ff4fafd6f05d5ac650204830ba7cc7a44feaf40b6a2386c660ab17d3b8d0b881d01d84c4a83a46fe41c6552a2ec74d
data/CHANGELOG.md CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  ## next
4
4
 
5
+ ## 6.5 (1/19/2023)
6
+ - Fix JSON schema reporting for BigDecimal types to be a string, with a format=bigdecimal
7
+
5
8
  ## 6.4 (10/26/2022)
6
9
  - Cache default values for a type, to speedup loading/coercing an object to it
7
10
 
@@ -1,8 +1,9 @@
1
1
  require 'bigdecimal'
2
2
 
3
3
  module Attributor
4
- class BigDecimal
5
- include Numeric
4
+ class BigDecimal
5
+ include Type
6
+
6
7
  def self.native_type
7
8
  ::BigDecimal
8
9
  end
@@ -19,7 +20,18 @@ module Attributor
19
20
  end
20
21
 
21
22
  def self.json_schema_type
22
- :number
23
+ :string
24
+ end
25
+
26
+ # Bigdecimal numbers are too big to be represented as numbers in JSON schema
27
+ # The way to do so, is to represent them as strings, but add a 'format' specifying
28
+ # how to parse that (seemingly, there is a 'double' well known type that json API
29
+ # claims we can use) ... not sure if this is the right one, as technically BigDecimal
30
+ # has very large precision that a double wouldn't be able to fit...
31
+ def self.as_json_schema( shallow: false, example: nil, attribute_options: {} )
32
+ hash = super
33
+ hash[:format] = 'bigdecimal'
34
+ hash
23
35
  end
24
36
  end
25
37
  end
@@ -1,3 +1,3 @@
1
1
  module Attributor
2
- VERSION = '6.4'.freeze
2
+ VERSION = '6.5'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attributor
3
3
  version: !ruby/object:Gem::Version
4
- version: '6.4'
4
+ version: '6.5'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josep M. Blanquer
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-10-26 00:00:00.000000000 Z
12
+ date: 2023-01-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: hashie