Class: R2OAS::Schema::V3::PathnameManager
- Defined in:
- lib/r2-oas/schema/v3/manager/pathname_manager.rb
Constant Summary
Constants inherited from Base
Base::SUPPORT_COMPONENTS_OBJECTS
Instance Method Summary collapse
-
#initialize(path, path_type = :full) ⇒ PathnameManager
constructor
e.x.) path = “#/components/schemas/Account” (when path_type = :ref).
- #object_type ⇒ Object
- #relative_save_file_path ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(path, path_type = :full) ⇒ PathnameManager
e.x.) path = “#/components/schemas/Account” (when path_type = :ref)
10 11 12 13 14 15 |
# 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 |
Instance Method Details
#object_type ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# 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 ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# 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 |