open_api_annotator 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -1
- data/CHANGELOG.md +5 -0
- data/lib/open_api_annotator/paths_builder.rb +40 -7
- data/lib/open_api_annotator/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3783c346bf9c75e17861f54e485de4296630782ada42af36aa409383883bf711
|
4
|
+
data.tar.gz: b1c2120fa5db9eb13e8d07aefdc84ab4c38cc41d5dd3d6f32b1cf3e13599e432
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a867ddd7f65ac82c63038a3832751d384e26b6c7d4dfd039780fd39738e913b751f6fab2ab1933dd4acc635356e3ba07c40647daa045b923283cf9b9e24c505
|
7
|
+
data.tar.gz: 8edcad36fcef036a465fee95f15e138b40b99372e0722416300ba4e97c07a3d761ce006baa0b18fd31ac31ec37c954b8d9655cbb1619b62aef347118fd068b78
|
data/.travis.yml
CHANGED
@@ -6,7 +6,9 @@ language: ruby
|
|
6
6
|
rvm:
|
7
7
|
- 2.4.4
|
8
8
|
- 2.5.1
|
9
|
-
before_install:
|
9
|
+
before_install:
|
10
|
+
- gem install -v 1.17.3 bundler --no-rdoc --no-ri
|
11
|
+
- bundle _1.17.3_ install
|
10
12
|
before_script:
|
11
13
|
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
12
14
|
- chmod +x ./cc-test-reporter
|
data/CHANGELOG.md
CHANGED
@@ -54,9 +54,21 @@ module OpenApiAnnotator
|
|
54
54
|
|
55
55
|
case type
|
56
56
|
when Array
|
57
|
-
|
57
|
+
name = build_type_name(type.first)
|
58
|
+
"Returns an array of #{name}"
|
59
|
+
else
|
60
|
+
name = build_type_name(type)
|
61
|
+
"Returns a #{name}"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def build_type_name(type)
|
66
|
+
type = convert_primitive_class_to_data_type(type)
|
67
|
+
case type
|
68
|
+
when OpenApi::DataType
|
69
|
+
"#{type.name}"
|
58
70
|
when Class
|
59
|
-
"
|
71
|
+
"#{type.name}"
|
60
72
|
else
|
61
73
|
raise "not supported class #{type.class}"
|
62
74
|
end
|
@@ -68,18 +80,39 @@ module OpenApiAnnotator
|
|
68
80
|
|
69
81
|
case type
|
70
82
|
when Array
|
71
|
-
|
72
|
-
|
73
|
-
|
83
|
+
schema_of_array = resolve_media_type_schema(type.first)
|
84
|
+
schema = OpenApi::Schema.new(type: "array", items: schema_of_array)
|
85
|
+
OpenApi::MediaType.new(schema: schema)
|
86
|
+
else
|
87
|
+
schema = resolve_media_type_schema(type)
|
74
88
|
OpenApi::MediaType.new(schema: schema)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def resolve_media_type_schema(type)
|
93
|
+
type = convert_primitive_class_to_data_type(type)
|
94
|
+
case type
|
95
|
+
when OpenApi::DataType
|
96
|
+
OpenApi::Schema.new(type: type.name, format: type.format)
|
75
97
|
when Class
|
76
|
-
|
77
|
-
OpenApi::MediaType.new(schema: reference)
|
98
|
+
OpenApi::Reference.new(ref: "#/components/schemas/#{type.name}")
|
78
99
|
else
|
79
100
|
raise "not supported class #{type.class}"
|
80
101
|
end
|
81
102
|
end
|
82
103
|
|
104
|
+
def convert_primitive_class_to_data_type(type)
|
105
|
+
if type == String
|
106
|
+
OpenApi::DataType.new(:string, :string, :string)
|
107
|
+
elsif type == Integer
|
108
|
+
OpenApi::DataType.new(:integer, :integer, :int32)
|
109
|
+
elsif type == Float
|
110
|
+
OpenApi::DataType.new(:float, :number, :float)
|
111
|
+
else
|
112
|
+
type
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
83
116
|
def resolve_type(controller_name, action_name)
|
84
117
|
controller_class_name = "#{controller_name}_controller".classify
|
85
118
|
begin
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: open_api_annotator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kent Nagata
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: open_api
|