foobara-json-schema-generator 1.0.1 → 1.1.1

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: 941cc81aba10dd18bb19c8b8427033e76247b4487e827aba21c77c71b5b5ed79
4
- data.tar.gz: 30d402402fe3ba09559aebfc141f6b770afd7c944a895cb9e6c1ce7b01dc7859
3
+ metadata.gz: fe982c9eb854665188f26a61de404de190cc917fd91b413c338d428d083426e3
4
+ data.tar.gz: 042aff0322c960a4ba71c001bbb1bd8d2a12873329f2348e261d5d3d6f12e09d
5
5
  SHA512:
6
- metadata.gz: 8687222ac9cd86b7792aff4b6a2604172ba1c191e81fc0c88a487685cb016b2e73150bb5b5387e2f8aa77b7dab45f3ffaef63d1bba646851ec426f4e5581209e
7
- data.tar.gz: 4921a18e39e14b4dd9e5ae3fb41af9cc6eee0e045da79ff836e5b452e9c9b7131d7b30020d35fecd668c84c43bcc499726da48044d814cbcb88d1e634a59bd41
6
+ metadata.gz: 30df660d339042da76dbcd1d3a1b8d698351a770c180a6d9264eff7e228f48d58a7ab08f4a61592cbeeaa901a7f15c0a71c33b1276c26a984eec01ecdcd9f4c2
7
+ data.tar.gz: b48856f56dec9e6db8623149cf627ce8bc03359a7834ee014eae125cbdd9cafc4ae83d2ec42e9ff23417d1079d5e0c127257e61c96edaa25112733ac0676f14f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [1.1.1] - 2026-09-11
2
+
3
+ - Handle removed JSON.fast_generate
4
+
5
+ ## [1.1.0] - 2025-08-22
6
+
7
+ - Handle Foobara 0.1.0 declaration changes
8
+
1
9
  ## [1.0.1] - 2025-07-12
2
10
 
3
11
  - Add support for tuples
@@ -4,7 +4,7 @@ module Foobara
4
4
  def to_json_schema(type, association_depth: Foobara::AssociationDepth::ATOM)
5
5
  poro = to_json_schema_structure(type, association_depth:)
6
6
 
7
- JSON.fast_generate(poro)
7
+ JSON.generate(poro)
8
8
  end
9
9
 
10
10
  def to_json_schema_structure(type, association_depth: Foobara::AssociationDepth::ATOM)
@@ -105,28 +105,30 @@ module Foobara
105
105
  { type: "number" }
106
106
  elsif type.extends?(BuiltinTypes[:associative_array])
107
107
  # TODO: implement this
108
- # :nocov:
108
+ # simplecov:disable
109
109
  raise ArgumentError, "Associative array not yet supported"
110
- # :nocov:
110
+ # simplecov:enable
111
111
  elsif type.extends?(BuiltinTypes[:duck])
112
112
  {}
113
113
  else
114
- # :nocov:
114
+ # simplecov:disable
115
115
  # This should be unreachable because every type extends duck...
116
116
  raise ArgumentError, "Unable to convert #{declaration_data} to a JSON schema type"
117
- # :nocov:
117
+ # simplecov:enable
118
118
  end
119
119
 
120
- one_of = DataPath.value_at(:one_of, declaration_data)
120
+ unless type.primitive?
121
+ one_of = DataPath.value_at(:one_of, declaration_data)
121
122
 
122
- if one_of&.any?
123
- type_hash[:enum] = one_of
124
- end
123
+ if one_of&.any?
124
+ type_hash[:enum] = one_of
125
+ end
125
126
 
126
- allow_nil = DataPath.value_at(:allow_nil, declaration_data)
127
+ allow_nil = DataPath.value_at(:allow_nil, declaration_data)
127
128
 
128
- if allow_nil && type_hash.key?(:type)
129
- type_hash[:type] = [type_hash[:type], "null"]
129
+ if allow_nil && type_hash.key?(:type)
130
+ type_hash[:type] = [type_hash[:type], "null"]
131
+ end
130
132
  end
131
133
 
132
134
  if description
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foobara-json-schema-generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi
@@ -15,7 +15,7 @@ dependencies:
15
15
  requirements:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
- version: 0.0.136
18
+ version: 0.1.1
19
19
  - - "<"
20
20
  - !ruby/object:Gem::Version
21
21
  version: 2.0.0
@@ -25,7 +25,7 @@ dependencies:
25
25
  requirements:
26
26
  - - ">="
27
27
  - !ruby/object:Gem::Version
28
- version: 0.0.136
28
+ version: 0.1.1
29
29
  - - "<"
30
30
  - !ruby/object:Gem::Version
31
31
  version: 2.0.0
@@ -64,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
64
64
  - !ruby/object:Gem::Version
65
65
  version: '0'
66
66
  requirements: []
67
- rubygems_version: 3.6.9
67
+ rubygems_version: 4.0.16
68
68
  specification_version: 4
69
69
  summary: Takes a Foobara type and converts it to a json schema
70
70
  test_files: []