oas_rails 0.4.3 → 0.4.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/oas_rails/builders/path_item_builder.rb +3 -1
- data/lib/oas_rails/builders/responses_builder.rb +2 -2
- data/lib/oas_rails/configuration.rb +1 -1
- data/lib/oas_rails/extractors/oas_route_extractor.rb +2 -2
- data/lib/oas_rails/extractors/render_response_extractor.rb +1 -1
- data/lib/oas_rails/utils.rb +1 -6
- data/lib/oas_rails/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: 5285e5cf1a83ddb32b2d4b74a79d5694175fa2e7959211f264ab58a0b9dadf36
|
4
|
+
data.tar.gz: d16c39e306c501bda6fd38d842df96820cc7621bf29b76026e4a0ea8e1070588
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 638314dfa65ce344c4fdb8c7e725503f6556a7276aa4839c406d738a7d06b9bfd8533e68dcf720bf95573e4b75f7d91f0600528b4fd00670e2c94990a92f5a04
|
7
|
+
data.tar.gz: 606103ec7b8640f5fbbcc1afcbd9c56d5671df6dbacd89e7ab1c30ead4b2480f583cb2f6bc31a6cf4a731399d77e101e1a5b4d7f8465c548da49307ad170f4d3
|
@@ -8,7 +8,9 @@ module OasRails
|
|
8
8
|
|
9
9
|
def from_path(path, route_extractor: Extractors::RouteExtractor)
|
10
10
|
route_extractor.host_routes_by_path(path).each do |oas_route|
|
11
|
-
|
11
|
+
oas_route.verb.downcase.split("|").each do |v|
|
12
|
+
@path_item.add_operation(v, OperationBuilder.new(@specification).from_oas_route(oas_route).build)
|
13
|
+
end
|
12
14
|
end
|
13
15
|
|
14
16
|
self
|
@@ -15,7 +15,7 @@ module OasRails
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def add_autodiscovered_responses(oas_route)
|
18
|
-
return unless OasRails.config.autodiscover_responses
|
18
|
+
return self unless OasRails.config.autodiscover_responses
|
19
19
|
|
20
20
|
new_responses = Extractors::RenderResponseExtractor.extract_responses_from_source(@specification, source: oas_route.source_string)
|
21
21
|
|
@@ -27,7 +27,7 @@ module OasRails
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def add_default_responses(oas_route, security)
|
30
|
-
return unless OasRails.config.set_default_responses
|
30
|
+
return self unless OasRails.config.set_default_responses
|
31
31
|
|
32
32
|
content = ContentBuilder.new(@specification, :outgoing).with_schema(Utils.hash_to_json_schema(OasRails.config.response_body_of_default)).build
|
33
33
|
common_errors = []
|
@@ -20,11 +20,11 @@ module OasRails
|
|
20
20
|
|
21
21
|
def default_tags(oas_route:)
|
22
22
|
tags = []
|
23
|
-
if OasRails.config.default_tags_from ==
|
23
|
+
if OasRails.config.default_tags_from == :namespace
|
24
24
|
tag = oas_route.path.split('/').reject(&:empty?).first.try(:titleize)
|
25
25
|
tags << tag unless tag.nil?
|
26
26
|
else
|
27
|
-
tags << oas_route.controller.titleize
|
27
|
+
tags << oas_route.controller.gsub("/", " ").titleize
|
28
28
|
end
|
29
29
|
tags
|
30
30
|
end
|
@@ -34,7 +34,7 @@ module OasRails
|
|
34
34
|
status_int = Utils.status_to_integer(status)
|
35
35
|
content = Builders::ContentBuilder.new(specification, :outgoing).with_schema(schema).with_examples(examples).build
|
36
36
|
|
37
|
-
Builders::ResponseBuilder.new(specification).with_code(status_int).with_description(Utils.
|
37
|
+
Builders::ResponseBuilder.new(specification).with_code(status_int).with_description(Utils.get_definition(status_int)).with_content(content).build
|
38
38
|
end
|
39
39
|
|
40
40
|
# Builds schema and examples based on the content type.
|
data/lib/oas_rails/utils.rb
CHANGED
@@ -80,8 +80,7 @@ module OasRails
|
|
80
80
|
if status.to_s =~ /^\d+$/
|
81
81
|
status.to_i
|
82
82
|
else
|
83
|
-
|
84
|
-
Rack::Utils::SYMBOL_TO_STATUS_CODE[status.to_sym]
|
83
|
+
Rack::Utils.status_code(status.to_sym)
|
85
84
|
end
|
86
85
|
end
|
87
86
|
|
@@ -89,10 +88,6 @@ module OasRails
|
|
89
88
|
#
|
90
89
|
# @param status_code [Integer] The status code.
|
91
90
|
# @return [String] The text description of the status code.
|
92
|
-
def status_code_to_text(status_code)
|
93
|
-
Rack::Utils::HTTP_STATUS_CODES[status_code] || "Unknown Status Code"
|
94
|
-
end
|
95
|
-
|
96
91
|
def get_definition(status_code)
|
97
92
|
HTTP_STATUS_DEFINITIONS[status_code] || "Definition not found for status code #{status_code}"
|
98
93
|
end
|
data/lib/oas_rails/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oas_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- a-chacon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-08-
|
11
|
+
date: 2024-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: method_source
|