taro 2.4.0 → 2.5.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 +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +0 -1
- data/lib/taro/export/open_api_v3.rb +2 -2
- data/lib/taro/types/base_type.rb +1 -0
- data/lib/taro/types/field.rb +4 -0
- data/lib/taro/types/shared/openapi_format.rb +61 -0
- data/lib/taro/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8f629d8573ed34c2d60303a387e99cae4cc9fcb0b14901d7080def1e27d0d90
|
4
|
+
data.tar.gz: 40c3ae606ade65922c5b69f9dd86353f2740d061b6d7094f61abe906e5f9198f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34b8e8d9ef5c2f016f56a887b674fa243ae6074fc59e4d29a1cb1873c4dfc3e87d8c24a37dd93a461ad71fc0fd38849462360bed7f6f9a1cca89e37fb3ad192b
|
7
|
+
data.tar.gz: d99f3bdc2e40e555a1a0b54dcac6a62d5774b6ae2c7c0d5e05c5ee0f1457864af696b37949173d8189769b03b5d9ce589eb1f49d855209c5c2bccadf32b51d84
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -410,7 +410,6 @@ end
|
|
410
410
|
- mixed arrays
|
411
411
|
- mixed enums
|
412
412
|
- nullable enums
|
413
|
-
- string format specifications (e.g. binary, int64, password ...)
|
414
413
|
- string minLength and maxLength (substitute: `self.pattern = /\A.{3,5}\z/`)
|
415
414
|
- number minimum, exclusiveMinimum, maximum, multipleOf
|
416
415
|
- readOnly, writeOnly
|
@@ -129,7 +129,7 @@ class Taro::Export::OpenAPIv3 < Taro::Export::Base # rubocop:disable Metrics/Cla
|
|
129
129
|
|
130
130
|
def export_type(type)
|
131
131
|
if type < Taro::Types::ScalarType && !custom_scalar_type?(type)
|
132
|
-
{ type: type.openapi_type }
|
132
|
+
{ type: type.openapi_type, format: type.openapi_format }.compact
|
133
133
|
else
|
134
134
|
extract_component_ref(type)
|
135
135
|
end
|
@@ -148,7 +148,7 @@ class Taro::Export::OpenAPIv3 < Taro::Export::Base # rubocop:disable Metrics/Cla
|
|
148
148
|
end
|
149
149
|
|
150
150
|
def export_scalar_field(field)
|
151
|
-
base = { type: field.openapi_type }
|
151
|
+
base = { type: field.openapi_type, format: field.openapi_format }.compact
|
152
152
|
# Using oneOf seems more correct than an array of types
|
153
153
|
# as it puts props like format together with the main type.
|
154
154
|
# https://github.com/OAI/OpenAPI-Specification/issues/3148
|
data/lib/taro/types/base_type.rb
CHANGED
@@ -17,6 +17,7 @@ Taro::Types::BaseType = Struct.new(:object) do
|
|
17
17
|
extend Taro::Types::Shared::Description
|
18
18
|
extend Taro::Types::Shared::Equivalence
|
19
19
|
extend Taro::Types::Shared::Name
|
20
|
+
extend Taro::Types::Shared::OpenAPIFormat
|
20
21
|
extend Taro::Types::Shared::OpenAPIName
|
21
22
|
extend Taro::Types::Shared::OpenAPIType
|
22
23
|
extend Taro::Types::Shared::Rendering
|
data/lib/taro/types/field.rb
CHANGED
@@ -0,0 +1,61 @@
|
|
1
|
+
# Provides a setter and getter for type classes' `openapi_format`,
|
2
|
+
# for use in the OpenAPI export.
|
3
|
+
module Taro::Types::Shared::OpenAPIFormat
|
4
|
+
OPENAPI_STRING_FORMATS = %i[
|
5
|
+
date
|
6
|
+
date-time
|
7
|
+
password
|
8
|
+
byte
|
9
|
+
binary
|
10
|
+
email
|
11
|
+
uuid
|
12
|
+
uri
|
13
|
+
hostname
|
14
|
+
ipv4
|
15
|
+
ipv6
|
16
|
+
].freeze
|
17
|
+
|
18
|
+
OPENAPI_INTEGER_FORMATS = %i[
|
19
|
+
int32
|
20
|
+
int64
|
21
|
+
].freeze
|
22
|
+
|
23
|
+
OPENAPI_NUMBER_FORMATS = %i[
|
24
|
+
float
|
25
|
+
double
|
26
|
+
].freeze
|
27
|
+
|
28
|
+
def openapi_format
|
29
|
+
return unless @openapi_format
|
30
|
+
|
31
|
+
unless valid_formats_for_openapi_type.include?(@openapi_format)
|
32
|
+
raise(Taro::ArgumentError, "openapi_format #{@openapi_format.inspect} is invalid for openapi_type #{@openapi_type.inspect}, must be one for #{valid_formats_for_openapi_type}")
|
33
|
+
end
|
34
|
+
|
35
|
+
@openapi_format
|
36
|
+
end
|
37
|
+
|
38
|
+
def openapi_format=(arg)
|
39
|
+
@openapi_format = arg
|
40
|
+
end
|
41
|
+
|
42
|
+
def inherited(subclass)
|
43
|
+
subclass.instance_variable_set(:@openapi_format, @openapi_format)
|
44
|
+
super
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def valid_formats_for_openapi_type
|
50
|
+
case @openapi_type
|
51
|
+
when :string
|
52
|
+
OPENAPI_STRING_FORMATS
|
53
|
+
when :integer
|
54
|
+
OPENAPI_INTEGER_FORMATS
|
55
|
+
when :number
|
56
|
+
OPENAPI_NUMBER_FORMATS
|
57
|
+
else
|
58
|
+
[]
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/lib/taro/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: taro
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Janosch Müller
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2025-
|
12
|
+
date: 2025-04-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|
@@ -115,6 +115,7 @@ files:
|
|
115
115
|
- lib/taro/types/shared/item_type.rb
|
116
116
|
- lib/taro/types/shared/name.rb
|
117
117
|
- lib/taro/types/shared/object_coercion.rb
|
118
|
+
- lib/taro/types/shared/openapi_format.rb
|
118
119
|
- lib/taro/types/shared/openapi_name.rb
|
119
120
|
- lib/taro/types/shared/openapi_type.rb
|
120
121
|
- lib/taro/types/shared/pattern.rb
|
@@ -146,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
147
|
- !ruby/object:Gem::Version
|
147
148
|
version: '0'
|
148
149
|
requirements: []
|
149
|
-
rubygems_version: 3.5.
|
150
|
+
rubygems_version: 3.5.16
|
150
151
|
signing_key:
|
151
152
|
specification_version: 4
|
152
153
|
summary: Typed Api using Ruby Objects.
|