Class: Sbuilder::ParamSetLoaderSwagger
- Inherits:
-
ApiLoaderPlugin
- Object
- LoaderPluginRoot
- ApiLoaderPlugin
- Sbuilder::ParamSetLoaderSwagger
- Defined in:
- lib/sbuilder/param_set_loader_swagger.rb
Constant Summary
Constants inherited from LoaderPluginRoot
Constants included from Utils::MyLogger
Construct && configure collapse
-
.configure(configuration) ⇒ Object
class method configure.
-
#doConfigure(configuration) ⇒ Object
Instance configuration.
-
#initialize(options = {}) ⇒ ParamSetLoaderSwagger
constructor
——————————————————————.
Instance Method Summary collapse
-
#doLoadDefinitions(swagger_hash) ⇒ Object
calls ‘@controller.modelDefinition’ for each parameter set found in swagger configuration.
-
#doLoadInterfaces(swagger_hash) ⇒ Object
calls ‘@facade.modelInterface’ for each parameter set found in swagger configuration.
- #load(yamlFileUri) ⇒ Object
- #readLines(yamlFileUri) ⇒ Object
-
#validate(json) ⇒ true
Validates this object against the Swagger specification and returns the first detected error.
Methods included from ApiLoaderPluginMixer
Methods inherited from LoaderPluginRoot
#configure, #logger, #oneOf, #validateProperties, validateProperties
Methods included from Utils::MyLogger
Constructor Details
#initialize(options = {}) ⇒ ParamSetLoaderSwagger
18 19 20 |
# File 'lib/sbuilder/param_set_loader_swagger.rb', line 18 def initialize( = {} ) super( ) end |
Class Method Details
.configure(configuration) ⇒ Object
class method configure
27 28 |
# File 'lib/sbuilder/param_set_loader_swagger.rb', line 27 def self.configure( configuration ) end |
Instance Method Details
#doConfigure(configuration) ⇒ Object
Instance configuration
sbuilder.yaml
36 37 |
# File 'lib/sbuilder/param_set_loader_swagger.rb', line 36 def doConfigure( configuration ) end |
#doLoadDefinitions(swagger_hash) ⇒ Object
calls ‘@controller.modelDefinition’ for each parameter set found in swagger configuration
90 91 92 93 94 95 96 |
# File 'lib/sbuilder/param_set_loader_swagger.rb', line 90 def doLoadDefinitions( swagger_hash ) paramsSets = parseDefinitions( swagger_hash ) paramsSets.each do |paramSet| facade.modelDefinition( paramSet ) end end |
#doLoadInterfaces(swagger_hash) ⇒ Object
calls ‘@facade.modelInterface’ for each parameter set found in swagger configuration
103 104 105 106 107 108 109 110 111 |
# File 'lib/sbuilder/param_set_loader_swagger.rb', line 103 def doLoadInterfaces( swagger_hash ) interface_paramsSets = parseInterfaces( swagger_hash ) logger.info( "#{__method__} loaded=#{interface_paramsSets.length} interface_paramsSets" ) interface_paramsSets.each do |interface| facade.modelInterface( interface ) end end |
#load(yamlFileUri) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/sbuilder/param_set_loader_swagger.rb', line 56 def load( yamlFileUri ) logger.info( "#{__method__} yamlFileUri=#{yamlFileUri}" ) begin # use facade services to read lines in yaml_lines = readLines( yamlFileUri ) # YAML parse & schema validation swagger_hash = YAML.load( yaml_lines ) rescue Exception => e msg = <<-EOS.gsub( /^\s*/, '' ) Error #{e.} when loading '#{yamlFileUri}' EOS raise Sbuilder::LoaderException.new, msg, e.backtrace end validate( swagger_hash ) # and extract interfaces && definitions doLoadInterfaces( swagger_hash ) doLoadDefinitions( swagger_hash ) end |
#readLines(yamlFileUri) ⇒ Object
46 47 48 49 |
# File 'lib/sbuilder/param_set_loader_swagger.rb', line 46 def readLines( yamlFileUri ) yaml_lines = facade.read_cached( yamlFileUri ) return yaml_lines end |
#validate(json) ⇒ true
Validates this object against the Swagger specification and returns the first detected error. Faster than #fully_validate.
121 122 123 124 125 126 |
# File 'lib/sbuilder/param_set_loader_swagger.rb', line 121 def validate( json ) JSON::Validator.validate!(swagger_schema, json ) # # JSON::Validator.fully_validate(swagger_schema, json ) # rescue JSON::Schema::ValidationError => e raise Sbuilder::LoaderException.new, e. end |