class R2OAS::Schema::V3::PathnameManager
Public Class Methods
new(path, path_type = :full)
click to toggle source
e.x.) path = “#/components/schemas/Account” (when path_type = :ref)
Calls superclass method
R2OAS::Base::new
# File lib/r2-oas/schema/v3/manager/pathname_manager.rb, line 10 def initialize(path, path_type = :full) super() @ext_name = :yml @path_type = path_type @path = path end
Public Instance Methods
object_type()
click to toggle source
# File lib/r2-oas/schema/v3/manager/pathname_manager.rb, line 17 def object_type case @path when /schemas/ 'schemas' when /requestBodies/ 'requestBodies' when /securitySchemes/ 'securitySchemes' when /parameters/ 'parameters' when /responses/ 'responses' when /examples/ 'examples' when /headers/ 'headers' when /links/ 'links' when /callbacks/ 'callbacks' end end
relative_save_file_path()
click to toggle source
# File lib/r2-oas/schema/v3/manager/pathname_manager.rb, line 40 def relative_save_file_path result = normalized_about_path_type if (@path_type.in? %i[ref relative]) && support_components_objects.include?(object_type) dirname = File.dirname(result) basename = File.basename(result, '.yml') basename = basename.gsub(ns_div, '/').underscore "#{schema_save_dir_path}/#{dirname}/#{basename}.yml" elsif @path_type.eql?(:relative) && !support_components_objects.include?(object_type) "#{schema_save_dir_path}/#{result.underscore}" elsif @path_type.eql?(:full) result else "#{schema_save_dir_path}/#{result}" end end
Private Instance Methods
normalized_about_path_type()
click to toggle source
# File lib/r2-oas/schema/v3/manager/pathname_manager.rb, line 58 def normalized_about_path_type case @path_type when :ref "#{@path.gsub('#/', '')}.#{@ext_name}" when :relative ext_name = File.extname(@path) if ext_name.empty? "#{@path}.#{@ext_name}" else @path end when :full @path else raise NoSupportError, "Do not support path_type: #{@path_type}" end end