oas_core 1.1.0 → 1.2.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/lib/oas_core/version.rb +1 -1
- data/lib/oas_core/yard/oas_core_factory.rb +33 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a77360fd7e6944eb6e1ea64830375d480b04c289e478b63b444c3dc6f12134f9
|
4
|
+
data.tar.gz: 371786121bec6160afd368ed2677999055189aad0cbfa35c26a8c16a572c2505
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ddd844dd639cda56c2635b52bd46db947a07428c8ef482f82184ca5693768665f7bb29ebd0d1ca275104a3ff506d5c9f5530d13255f2a5bccbdecd80aa3b7181
|
7
|
+
data.tar.gz: e66985fb30da4835e342a0580947de67a008f01c55d8799e59135d3ad137d42a341198fd96b988a095ab20353a429441f1ef3753c0a87517fb637ac70f227a5c
|
data/lib/oas_core/version.rb
CHANGED
@@ -49,6 +49,8 @@ module OasCore
|
|
49
49
|
raw_type, required = text_and_required(second)
|
50
50
|
schema = raw_type_to_content(raw_type)
|
51
51
|
name = "#{name}[]" if location == 'query' && schema[:type] == 'array'
|
52
|
+
description, schema_keywords = extract_schema_keywords(description)
|
53
|
+
schema.merge!(schema_keywords)
|
52
54
|
|
53
55
|
ParameterTag.new(tag_name, name, description.strip, schema, location, required:)
|
54
56
|
rescue StandardError => e
|
@@ -201,6 +203,37 @@ module OasCore
|
|
201
203
|
[text.strip, nil]
|
202
204
|
end
|
203
205
|
end
|
206
|
+
|
207
|
+
# Only allows keywords defined in the OpenAPI 3.0 specification for parameter schemas.
|
208
|
+
# @param text [String] The text to parse.
|
209
|
+
# @return [Array] An array containing the cleaned description and a hash of extracted keywords.
|
210
|
+
def extract_schema_keywords(text)
|
211
|
+
allowed_keywords = %i[
|
212
|
+
default minimum maximum enum format pattern multipleOf
|
213
|
+
exclusiveMinimum exclusiveMax minLength maxLength nullable
|
214
|
+
].freeze
|
215
|
+
|
216
|
+
keywords = {}
|
217
|
+
cleaned_text = text.dup
|
218
|
+
|
219
|
+
text.scan(/(\w+):\s*\(([^)]+)\)/) do |keyword, value|
|
220
|
+
keyword_sym = keyword.to_sym
|
221
|
+
if allowed_keywords.include?(keyword_sym)
|
222
|
+
parsed_value = case keyword_sym
|
223
|
+
when :nullable, :exclusiveMinimum, :exclusiveMaximum
|
224
|
+
value.strip.downcase == 'true'
|
225
|
+
when :enum
|
226
|
+
value.strip.split(/\s*,\s*/)
|
227
|
+
else
|
228
|
+
value.strip
|
229
|
+
end
|
230
|
+
keywords[keyword_sym] = parsed_value
|
231
|
+
cleaned_text.sub!(/#{keyword}:\s*\([^)]+\)/, '')
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
[cleaned_text.strip, keywords]
|
236
|
+
end
|
204
237
|
end
|
205
238
|
end
|
206
239
|
end
|