class JSON::Oas::Fragment
This is a workaround for json-schema's fragment validation which does not allow to contain forward slashes due to an attempt split('/')
Public Class Methods
response_schema_for(version, path_or_name, method = nil, code = nil)
click to toggle source
# File lib/json-schema-oas/fragment.rb, line 8 def response_schema_for(version, path_or_name, method = nil, code = nil) case version when Version::OAS2 raise ArgumentError unless method && code new(['#', 'paths', path_or_name, method.to_s, 'responses', code.to_s, 'schema']) when Version::OAS3 v3_response_schema_for(path_or_name, method, code) else raise Error, Error::UNKNOWN_VERSION_ERROR end end
schema_for(version, name)
click to toggle source
# File lib/json-schema-oas/fragment.rb, line 21 def schema_for(version, name) case version when Version::OAS2 new(['#', 'definitions', name.to_s]) when Version::OAS3 new(['#', 'components', 'schemas', name.to_s]) else raise Error, Error::UNKNOWN_VERSION_ERROR end end
Private Class Methods
v3_paths_response_schema_for(path, method, code)
click to toggle source
# File lib/json-schema-oas/fragment.rb, line 45 def v3_paths_response_schema_for(path, method, code) raise ArgumentError unless method && code && path new(['#', 'paths', path, method.to_s, 'responses', code.to_s, 'content', 'application/json', 'schema']) end
v3_response_schema_for(path_or_name, method = nil, code = nil)
click to toggle source
@path_or_name String To avoid github.com/ruby-json-schema/json-schema/issues/229
# File lib/json-schema-oas/fragment.rb, line 35 def v3_response_schema_for(path_or_name, method = nil, code = nil) unless method && code raise ArgumentError unless path_or_name return new(['#', 'components', 'responses', path_or_name, 'content', 'application/json', 'schema']) end v3_paths_response_schema_for(path_or_name, method, code) end
Public Instance Methods
split(_options = nil)
click to toggle source
# File lib/json-schema-oas/fragment.rb, line 52 def split(_options = nil) dup end