Class: RswagJsonLoader::SchemaHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/rswag_json_loader.rb

Class Method Summary collapse

Class Method Details

.json_schemasObject



12
13
14
15
16
17
18
19
20
21
# File 'lib/rswag_json_loader.rb', line 12

def self.json_schemas
  schemas = {}

  Dir[RswagJsonLoader.schema_path].each do |json|
    file_name = File.basename(json, ".json")
    humanized = file_name.split("_").map(&:capitalize).join
    schemas[humanized] = Schemas::Loader.new(json).load
  end
  schemas
end

.setup!Object



23
24
25
26
27
# File 'lib/rswag_json_loader.rb', line 23

def self.setup!
  RSpec.configure do |config|
    config.swagger_docs[RswagJsonLoader.openapi_path][:components][:schemas].merge!(json_schemas)
  end
end