apiculture 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/apiculture/openapi_documentation.rb +26 -14
- data/lib/apiculture/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd3d6da6eca1e6a1c63d824bfbed2d43d2a74032f966dc6f17df09c6458548c8
|
4
|
+
data.tar.gz: 53581729f4b81574b5bc400786509cfa6f9364fde56486611ae8eab8c3370f8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2f325148ce9a454206d278f665b583fbd896b442d5f07eecfef481a43143299001c3097eceaf37e2d61866f8f06e5523677ffcad031a9a5811419ce7f84ee9e
|
7
|
+
data.tar.gz: 97159d92a46fef3e7c093c87ce4b80e783a4610c073857f80c74205ddfcabc7d6b019d3d29b1b2a66d5fd2a6fff92a2fef9f2d3c910dc62478613d42e692dabe
|
data/CHANGELOG.md
CHANGED
@@ -8,9 +8,9 @@ module OpenApiDocumentation
|
|
8
8
|
@paths = chunks.select { |chunk| chunk.respond_to?(:http_verb) }
|
9
9
|
@data = {
|
10
10
|
openapi: '3.0.0',
|
11
|
-
info: {
|
12
|
-
title: @app.to_s,
|
13
|
-
version: '0.0.1',
|
11
|
+
info: {
|
12
|
+
title: @app.to_s,
|
13
|
+
version: '0.0.1',
|
14
14
|
description: @app.to_s + " " + chunks.select { |chunk| chunk.respond_to?(:to_markdown) }.map(&:to_markdown).join("\n")
|
15
15
|
},
|
16
16
|
tags: []
|
@@ -27,7 +27,7 @@ module OpenApiDocumentation
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def spec
|
30
|
-
@data
|
30
|
+
@data
|
31
31
|
end
|
32
32
|
|
33
33
|
private
|
@@ -137,7 +137,7 @@ module OpenApiDocumentation
|
|
137
137
|
|
138
138
|
def build_request_body
|
139
139
|
return nil if VERBS_WITHOUT_BODY.include?(@path.http_verb)
|
140
|
-
|
140
|
+
|
141
141
|
body_params = Hash[ @path.parameters.collect do |parameter|
|
142
142
|
[parameter.name, {
|
143
143
|
type: Util.map_type(parameter.matchable),
|
@@ -171,7 +171,7 @@ module OpenApiDocumentation
|
|
171
171
|
unless response.jsonable_object_example.nil? || response.jsonable_object_example.empty?
|
172
172
|
_response[:content] = {
|
173
173
|
'application/json': {
|
174
|
-
schema:
|
174
|
+
schema:
|
175
175
|
{ type: 'object',
|
176
176
|
properties: Util.response_to_schema(response.jsonable_object_example) }
|
177
177
|
}
|
@@ -198,15 +198,27 @@ module OpenApiDocumentation
|
|
198
198
|
}.freeze
|
199
199
|
|
200
200
|
def self.response_to_schema(response)
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
201
|
+
case response
|
202
|
+
when NilClass
|
203
|
+
when String
|
204
|
+
{ type: 'string', example: response }
|
205
|
+
when Integer
|
206
|
+
{ type: 'integer', example: response }
|
207
|
+
when Float
|
208
|
+
{ type: 'float', example: response }
|
209
|
+
when Array
|
210
|
+
if response.empty?
|
211
|
+
{ type: 'array', items: {} }
|
212
|
+
else
|
213
|
+
{ type: 'array', items: response.map { |elem| response_to_schema(elem) } }
|
214
|
+
end
|
215
|
+
when Hash
|
216
|
+
response.each_with_object({}) do |(key, val), schema_hash|
|
217
|
+
schema_hash[key] = response_to_schema(val)
|
218
|
+
end
|
219
|
+
else
|
220
|
+
{ type: response.class.name.downcase, example: response.to_s }
|
208
221
|
end
|
209
|
-
schema
|
210
222
|
end
|
211
223
|
|
212
224
|
def self.map_type(type)
|
data/lib/apiculture/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apiculture
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julik Tarkhanov
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2023-
|
12
|
+
date: 2023-11-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: builder
|
@@ -216,7 +216,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
216
216
|
- !ruby/object:Gem::Version
|
217
217
|
version: '0'
|
218
218
|
requirements: []
|
219
|
-
rubygems_version: 3.
|
219
|
+
rubygems_version: 3.4.6
|
220
220
|
signing_key:
|
221
221
|
specification_version: 4
|
222
222
|
summary: Sweet API sauce on top of Rack
|