Class: Apipie::SwaggerGenerator
- Inherits:
-
Object
- Object
- Apipie::SwaggerGenerator
- Defined in:
- lib/apipie/swagger_generator.rb
Overview
Defined Under Namespace
Classes: SwaggerTypeWithFormat
Instance Attribute Summary collapse
-
#computed_interface_id ⇒ Object
readonly
Returns the value of attribute computed_interface_id.
Instance Method Summary collapse
- #add_missing_params(method, path) ⇒ Object
- #add_params_from_hash(swagger_params_array, param_defs, prefix = nil, default_value_for_in = nil) ⇒ Object
- #add_resource_description(resource_name, resource) ⇒ Object
- #add_resource_methods(resource_name, resource_defs) ⇒ Object
-
#add_resources(resources) ⇒ Object
————————————————————————– Engine interface methods ————————————————————————–.
-
#add_ruby_method(paths, ruby_method) ⇒ Object
————————————————————————– Create swagger definitions for a ruby method ————————————————————————–.
-
#body_allowed_for_current_method ⇒ Object
————————————————————————– swagger “Params” block generation ————————————————————————–.
- #gen_referenced_block_from_params_array(name, params_array) ⇒ Object
- #generate_from_resources(version, resources, method_name, lang, clear_warnings = false) ⇒ Object
-
#include_op_id_in_computed_interface_id(op_id) ⇒ Object
the @computed_interface_id is a number that is uniquely derived from the list of operations added to the swagger definition (in an order-dependent way).
- #include_warning_tags? ⇒ Boolean
- #info(msg) ⇒ Object
-
#init_swagger_vars(version, lang, clear_warnings = false) ⇒ Object
————————————————————————– Initialization ————————————————————————–.
-
#initialize(apipie) ⇒ SwaggerGenerator
constructor
A new instance of SwaggerGenerator.
- #json_schema_obj_from_params_array(params_array) ⇒ Object
- #json_schema_param_defs_from_params_array(params_array) ⇒ Object
- #lookup ⇒ Object
-
#param_names_from_path(path) ⇒ Object
————————————————————————– Auto-insertion of parameters that are implicitly defined in the path ————————————————————————–.
- #params_in_body? ⇒ Boolean
- #params_in_body_use_reference? ⇒ Boolean
-
#ref_to(name) ⇒ Object
————————————————————————– JSON schema and referenced-object generation ————————————————————————–.
- #remove_colons(str) ⇒ Object
-
#response_schema(response) ⇒ Object
————————————————————————– Responses ————————————————————————–.
-
#ruby_name_for_method(method) ⇒ Object
————————————————————————– Logging, debugging and regression-testing utilities ————————————————————————–.
- #save_field(entry, openapi_key, v, apipie_key = openapi_key, translate = false) ⇒ Object
-
#swagger_atomic_param(param_desc, in_schema, name) ⇒ Object
————————————————————————– The core routine for creating a swagger parameter definition block.
- #swagger_op_id_for_method(method) ⇒ Object
- #swagger_op_id_for_path(http_method, path) ⇒ Object
- #swagger_param_type(param_desc) ⇒ Object
- #swagger_params_array_for_method(method, path) ⇒ Object
-
#swagger_path(str) ⇒ Object
————————————————————————– Utilities for conversion of ruby syntax to swagger syntax ————————————————————————–.
- #swagger_responses_hash_for_method(method) ⇒ Object
-
#tag_name_for_resource(resource) ⇒ Object
————————————————————————– Create a tag description for a described resource ————————————————————————–.
- #warn(warning_num, msg) ⇒ Object
- #warn_added_missing_slash(path) ⇒ Object
- #warn_hash_without_internal_typespec(param_name) ⇒ Object
- #warn_inferring_boolean(name) ⇒ Object
- #warn_missing_method_summary ⇒ Object
- #warn_no_return_codes_specified ⇒ Object
- #warn_optional_param_in_path(param_name) ⇒ Object
- #warn_optional_without_default_value(param_name) ⇒ Object
- #warn_param_ignored_in_form_data(param_name) ⇒ Object
- #warn_path_parameter_not_described(name, path) ⇒ Object
Constructor Details
#initialize(apipie) ⇒ SwaggerGenerator
Returns a new instance of SwaggerGenerator.
14 15 16 17 |
# File 'lib/apipie/swagger_generator.rb', line 14 def initialize(apipie) @apipie = apipie @issued_warnings = [] end |
Instance Attribute Details
#computed_interface_id ⇒ Object (readonly)
Returns the value of attribute computed_interface_id.
12 13 14 |
# File 'lib/apipie/swagger_generator.rb', line 12 def computed_interface_id @computed_interface_id end |
Instance Method Details
#add_missing_params(method, path) ⇒ Object
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 |
# File 'lib/apipie/swagger_generator.rb', line 400 def add_missing_params(method, path) param_names_from_method = method.params.map {|name, desc| name} missing = param_names_from_path(path) - param_names_from_method result = method.params missing.each do |name| warn_path_parameter_not_described(name, path) result[name.to_sym] = OpenStruct.new({ required: true, _gen_added_from_path: true, name: name, validator: Apipie::Validator::NumberValidator.new(nil), options: { in: "path" } }) end result end |
#add_params_from_hash(swagger_params_array, param_defs, prefix = nil, default_value_for_in = nil) ⇒ Object
595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 |
# File 'lib/apipie/swagger_generator.rb', line 595 def add_params_from_hash(swagger_params_array, param_defs, prefix=nil, default_value_for_in=nil) if default_value_for_in @default_value_for_param_in = default_value_for_in else if body_allowed_for_current_method @default_value_for_param_in = "formData" else @default_value_for_param_in = "query" end end param_defs.each do |name, desc| if !prefix.nil? name = "#{prefix}[#{name}]" end if swagger_param_type(desc) == "object" if desc.validator.params_ordered params_hash = Hash[desc.validator.params_ordered.map {|desc| [desc.name, desc]}] add_params_from_hash(swagger_params_array, params_hash, name) else warn_param_ignored_in_form_data(desc.name) end else param_entry = swagger_atomic_param(desc, false, name) if param_entry[:required] swagger_params_array.unshift(param_entry) else swagger_params_array.push(param_entry) end end end end |
#add_resource_description(resource_name, resource) ⇒ Object
178 179 180 181 182 183 184 185 |
# File 'lib/apipie/swagger_generator.rb', line 178 def add_resource_description(resource_name, resource) if resource._full_description @tags << { name: tag_name_for_resource(resource), description: Apipie.app.translate(resource._full_description, @current_lang) } end end |
#add_resource_methods(resource_name, resource_defs) ⇒ Object
108 109 110 111 112 |
# File 'lib/apipie/swagger_generator.rb', line 108 def add_resource_methods(resource_name, resource_defs) resource_defs._methods.each do |apipie_method_name, apipie_method_defs| add_ruby_method(@paths, apipie_method_defs) end end |
#add_resources(resources) ⇒ Object
Engine interface methods
101 102 103 104 105 106 |
# File 'lib/apipie/swagger_generator.rb', line 101 def add_resources(resources) resources.each do |resource_name, resource_defs| add_resource_description(resource_name, resource_defs) add_resource_methods(resource_name, resource_defs) end end |
#add_ruby_method(paths, ruby_method) ⇒ Object
Create swagger definitions for a ruby method
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
# File 'lib/apipie/swagger_generator.rb', line 191 def add_ruby_method(paths, ruby_method) if @only_method return unless ruby_method.method == @only_method else return if !ruby_method.show end for api in ruby_method.apis do # controller: ruby_method.resource.controller.name, path = swagger_path(api.path) paths[path] ||= {} methods = paths[path] @current_method = ruby_method @warnings_issued = false responses = swagger_responses_hash_for_method(ruby_method) if = @warnings_issued ? ['warnings issued'] : [] else = [] end op_id = swagger_op_id_for_path(api.http_method, api.path) include_op_id_in_computed_interface_id(op_id) method_key = api.http_method.downcase @current_http_method = method_key methods[method_key] = { tags: [tag_name_for_resource(ruby_method.resource)] + , consumes: params_in_body? ? ['application/json'] : ['application/x-www-form-urlencoded', 'multipart/form-data'], operationId: op_id, summary: Apipie.app.translate(api.short_description, @current_lang), parameters: swagger_params_array_for_method(ruby_method, api.path), responses: responses, description: ruby_method.full_description } if methods[method_key][:summary].nil? methods[method_key].delete(:summary) warn_missing_method_summary end end end |
#body_allowed_for_current_method ⇒ Object
swagger “Params” block generation
557 558 559 |
# File 'lib/apipie/swagger_generator.rb', line 557 def body_allowed_for_current_method !(['get', 'head'].include?(@current_http_method)) end |
#gen_referenced_block_from_params_array(name, params_array) ⇒ Object
501 502 503 504 505 506 507 508 509 |
# File 'lib/apipie/swagger_generator.rb', line 501 def gen_referenced_block_from_params_array(name, params_array) return ref_to(:name) if @definitions.key(:name) schema_obj = json_schema_obj_from_params_array(params_array) return nil if schema_obj.nil? @definitions[name.to_sym] = schema_obj ref_to(name.to_sym) end |
#generate_from_resources(version, resources, method_name, lang, clear_warnings = false) ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/apipie/swagger_generator.rb', line 32 def generate_from_resources(version, resources, method_name, lang, clear_warnings=false) init_swagger_vars(version, lang, clear_warnings) @lang = lang @only_method = method_name add_resources(resources) @swagger[:info]["x-computed-id"] = @computed_interface_id if Apipie.configuration.swagger_generate_x_computed_id_field? return @swagger end |
#include_op_id_in_computed_interface_id(op_id) ⇒ Object
the @computed_interface_id is a number that is uniquely derived from the list of operations added to the swagger definition (in an order-dependent way). it can be used for regression testing, allowing some differentiation between changes that result from changes to the input and those that result from changes to the generation algorithms. note that at the moment, this only takes operation ids into account, and ignores parameter definitions, so it’s only partially useful.
165 166 167 |
# File 'lib/apipie/swagger_generator.rb', line 165 def include_op_id_in_computed_interface_id(op_id) @computed_interface_id = Zlib::crc32("#{@computed_interface_id} #{op_id}") if Apipie.configuration.swagger_generate_x_computed_id_field? end |
#include_warning_tags? ⇒ Boolean
27 28 29 |
# File 'lib/apipie/swagger_generator.rb', line 27 def Apipie.configuration. end |
#info(msg) ⇒ Object
153 154 155 |
# File 'lib/apipie/swagger_generator.rb', line 153 def info(msg) print "--- INFO: [#{ruby_name_for_method(@current_method)}] -- #{msg}\n" end |
#init_swagger_vars(version, lang, clear_warnings = false) ⇒ Object
Initialization
48 49 50 51 52 53 54 55 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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/apipie/swagger_generator.rb', line 48 def init_swagger_vars(version, lang, clear_warnings=false) # docs = { # :name => Apipie.configuration.app_name, # :info => Apipie.app_info(version, lang), # :copyright => Apipie.configuration.copyright, # :doc_url => Apipie.full_url(url_args), # :api_url => Apipie.api_base_url(version), # :resources => _resources # } @swagger = { swagger: '2.0', info: { title: "#{Apipie.configuration.app_name}", description: "#{Apipie.app_info(version, lang)}#{Apipie.configuration.copyright}", version: "#{version}", "x-copyright" => Apipie.configuration.copyright, }, basePath: Apipie.api_base_url(version), consumes: [], paths: {}, definitions: {}, tags: [], } if Apipie.configuration.swagger_api_host @swagger[:host] = Apipie.configuration.swagger_api_host end if params_in_body? @swagger[:consumes] = ['application/json'] @swagger[:info][:title] += " (params in:body)" else @swagger[:consumes] = ['application/x-www-form-urlencoded', 'multipart/form-data'] @swagger[:info][:title] += " (params in:formData)" end @paths = @swagger[:paths] @definitions = @swagger[:definitions] @tags = @swagger[:tags] @issued_warnings = [] if clear_warnings || @issued_warnings.nil? @computed_interface_id = 0 @current_lang = lang end |
#json_schema_obj_from_params_array(params_array) ⇒ Object
490 491 492 493 494 495 496 497 498 499 |
# File 'lib/apipie/swagger_generator.rb', line 490 def json_schema_obj_from_params_array(params_array) (param_defs, required_params) = json_schema_param_defs_from_params_array(params_array) result = {type: "object"} result[:properties] = param_defs result[:additionalProperties] = false unless Apipie.configuration.swagger_allow_additional_properties_in_response result[:required] = required_params if required_params.length > 0 param_defs.length > 0 ? result : nil end |
#json_schema_param_defs_from_params_array(params_array) ⇒ Object
511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 |
# File 'lib/apipie/swagger_generator.rb', line 511 def json_schema_param_defs_from_params_array(params_array) param_defs = {} required_params = [] params_array ||= [] for param_desc in params_array if !param_desc.respond_to?(:required) # pp param_desc raise ("unexpected param_desc format") end required_params.push(param_desc.name.to_sym) if param_desc.required param_type = swagger_param_type(param_desc) if param_type == "object" && param_desc.validator.params_ordered schema = json_schema_obj_from_params_array(param_desc.validator.params_ordered) if param_desc.additional_properties schema[:additionalProperties] = true end if param_desc.is_array? new_schema = { type: 'array', items: schema } schema = new_schema end param_defs[param_desc.name.to_sym] = schema if !schema.nil? else param_defs[param_desc.name.to_sym] = swagger_atomic_param(param_desc, true, nil) end end [param_defs, required_params] end |
#lookup ⇒ Object
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 |
# File 'lib/apipie/swagger_generator.rb', line 284 def lookup @lookup ||= { numeric: "number", hash: "object", array: "array", # see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types integer: SwaggerTypeWithFormat.new("integer", "int32"), long: SwaggerTypeWithFormat.new("integer", "int64"), number: SwaggerTypeWithFormat.new("number", nil), # here just for completeness float: SwaggerTypeWithFormat.new("number", "float"), double: SwaggerTypeWithFormat.new("number", "double"), string: SwaggerTypeWithFormat.new("string", nil), # here just for completeness byte: SwaggerTypeWithFormat.new("string", "byte"), binary: SwaggerTypeWithFormat.new("string", "binary"), boolean: SwaggerTypeWithFormat.new("boolean", nil), # here just for completeness date: SwaggerTypeWithFormat.new("string", "date"), dateTime: SwaggerTypeWithFormat.new("string", "date-time"), password: SwaggerTypeWithFormat.new("string", "password"), } end |
#param_names_from_path(path) ⇒ Object
Auto-insertion of parameters that are implicitly defined in the path
394 395 396 397 398 |
# File 'lib/apipie/swagger_generator.rb', line 394 def param_names_from_path(path) path.scan(/:(\w+)/).map do |ar| ar[0].to_sym end end |
#params_in_body? ⇒ Boolean
19 20 21 |
# File 'lib/apipie/swagger_generator.rb', line 19 def params_in_body? Apipie.configuration.swagger_content_type_input == :json end |
#params_in_body_use_reference? ⇒ Boolean
23 24 25 |
# File 'lib/apipie/swagger_generator.rb', line 23 def params_in_body_use_reference? Apipie.configuration.swagger_json_input_uses_refs end |
#ref_to(name) ⇒ Object
JSON schema and referenced-object generation
485 486 487 |
# File 'lib/apipie/swagger_generator.rb', line 485 def ref_to(name) "#/definitions/#{name}" end |
#remove_colons(str) ⇒ Object
254 255 256 |
# File 'lib/apipie/swagger_generator.rb', line 254 def remove_colons(str) str.gsub(":", "_") end |
#response_schema(response) ⇒ Object
Responses
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 |
# File 'lib/apipie/swagger_generator.rb', line 337 def response_schema(response) begin # no need to warn about "missing default value for optional param" when processing response definitions prev_value = @disable_default_value_warning @disable_default_value_warning = true schema = json_schema_obj_from_params_array(response.params_ordered) ensure @disable_default_value_warning = prev_value end if response.is_array? && schema schema = { type: "array", items: schema } end if response.allow_additional_properties schema[:additionalProperties] = true end schema end |
#ruby_name_for_method(method) ⇒ Object
Logging, debugging and regression-testing utilities
119 120 121 122 |
# File 'lib/apipie/swagger_generator.rb', line 119 def ruby_name_for_method(method) return "<no method>" if method.nil? method.resource.controller.name + "#" + method.method end |
#save_field(entry, openapi_key, v, apipie_key = openapi_key, translate = false) ⇒ Object
427 428 429 430 431 432 433 434 435 |
# File 'lib/apipie/swagger_generator.rb', line 427 def save_field(entry, openapi_key, v, apipie_key=openapi_key, translate=false) if v.key?(apipie_key) if translate entry[openapi_key] = Apipie.app.translate(v[apipie_key], @current_lang) else entry[openapi_key] = v[apipie_key] end end end |
#swagger_atomic_param(param_desc, in_schema, name) ⇒ Object
The core routine for creating a swagger parameter definition block. The output is slightly different when the parameter is inside a schema block.
426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 |
# File 'lib/apipie/swagger_generator.rb', line 426 def swagger_atomic_param(param_desc, in_schema, name) def save_field(entry, openapi_key, v, apipie_key=openapi_key, translate=false) if v.key?(apipie_key) if translate entry[openapi_key] = Apipie.app.translate(v[apipie_key], @current_lang) else entry[openapi_key] = v[apipie_key] end end end swagger_def = {} swagger_def[:name] = name if !name.nil? swg_param_type = swagger_param_type(param_desc) swagger_def[:type] = swg_param_type.to_s if (swg_param_type.is_a? SwaggerTypeWithFormat) && !swg_param_type.str_format.nil? swagger_def[:format] = swg_param_type.str_format end if swagger_def[:type] == "array" swagger_def[:items] = {type: "string"} # TODO: add support for arrays of non-string items end if swagger_def[:type] == "enum" swagger_def[:type] = "string" swagger_def[:enum] = param_desc.validator.values end if swagger_def[:type] == "object" # we only get here if there is no specification of properties for this object swagger_def[:additionalProperties] = true warn_hash_without_internal_typespec(param_desc.name) end if !in_schema swagger_def[:in] = param_desc..fetch(:in, @default_value_for_param_in) swagger_def[:required] = param_desc.required if param_desc.required end save_field(swagger_def, :description, param_desc., :desc, true) unless param_desc.[:desc].nil? save_field(swagger_def, :default, param_desc., :default_value) if param_desc.respond_to?(:_gen_added_from_path) && !param_desc.required warn_optional_param_in_path(param_desc.name) swagger_def[:required] = true end if !swagger_def[:required] && !swagger_def.key?(:default) warn_optional_without_default_value(param_desc.name) unless @disable_default_value_warning end swagger_def end |
#swagger_op_id_for_method(method) ⇒ Object
258 259 260 |
# File 'lib/apipie/swagger_generator.rb', line 258 def swagger_op_id_for_method(method) remove_colons method.resource.controller.name + "::" + method.method end |
#swagger_op_id_for_path(http_method, path) ⇒ Object
262 263 264 265 266 |
# File 'lib/apipie/swagger_generator.rb', line 262 def swagger_op_id_for_path(http_method, path) # using lowercase http method, because the 'swagger-codegen' tool outputs # strange method names if the http method is in uppercase http_method.downcase + path.gsub(/\//,'_').gsub(/:(\w+)/, '\1').gsub(/_$/,'') end |
#swagger_param_type(param_desc) ⇒ Object
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 |
# File 'lib/apipie/swagger_generator.rb', line 307 def swagger_param_type(param_desc) if param_desc.nil? raise("problem") end v = param_desc.validator if v.nil? return "string" end if v.class == Apipie::Validator::EnumValidator || (v.respond_to?(:is_enum?) && v.is_enum?) if v.values - [true, false] == [] && [true, false] - v.values == [] warn_inferring_boolean(param_desc.name) return "boolean" else return "enum" end elsif v.class == Apipie::Validator::HashValidator # pp v end return lookup[v.expected_type.to_sym] || v.expected_type end |
#swagger_params_array_for_method(method, path) ⇒ Object
561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 |
# File 'lib/apipie/swagger_generator.rb', line 561 def swagger_params_array_for_method(method, path) swagger_result = [] all_params_hash = add_missing_params(method, path) body_param_defs_array = all_params_hash.map {|k, v| v if !param_names_from_path(path).include?(k)}.select{|v| !v.nil?} body_param_defs_hash = all_params_hash.select {|k, v| v if !param_names_from_path(path).include?(k)} path_param_defs_hash = all_params_hash.select {|k, v| v if param_names_from_path(path).include?(k)} path_param_defs_hash.each{|name,desc| desc.required = true} add_params_from_hash(swagger_result, path_param_defs_hash, nil, "path") if params_in_body? && body_allowed_for_current_method if params_in_body_use_reference? swagger_schema_for_body = {"$ref" => gen_referenced_block_from_params_array("#{swagger_op_id_for_method(method)}_input", body_param_defs_array)} else swagger_schema_for_body = json_schema_obj_from_params_array(body_param_defs_array) end swagger_body_param = { name: 'body', in: 'body', schema: swagger_schema_for_body } swagger_result.push(swagger_body_param) if !swagger_schema_for_body.nil? else add_params_from_hash(swagger_result, body_param_defs_hash) end swagger_result end |
#swagger_path(str) ⇒ Object
Utilities for conversion of ruby syntax to swagger syntax
243 244 245 246 247 248 249 250 251 252 |
# File 'lib/apipie/swagger_generator.rb', line 243 def swagger_path(str) str = str.gsub(/:(\w+)/, '{\1}') str = str.gsub(/\/$/, '') if str[0] != '/' warn_added_missing_slash(str) str = '/' + str end str end |
#swagger_responses_hash_for_method(method) ⇒ Object
361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 |
# File 'lib/apipie/swagger_generator.rb', line 361 def swagger_responses_hash_for_method(method) result = {} for error in method.errors error_block = {description: Apipie.app.translate(error.description, @current_lang)} result[error.code] = error_block end for response in method.returns swagger_response_block = { description: response.description } schema = response_schema(response) swagger_response_block[:schema] = schema if schema result[response.code] = swagger_response_block end if result.length == 0 warn_no_return_codes_specified result[200] = {description: 'ok'} end result end |
#tag_name_for_resource(resource) ⇒ Object
Create a tag description for a described resource
173 174 175 176 |
# File 'lib/apipie/swagger_generator.rb', line 173 def tag_name_for_resource(resource) # resource.controller resource._id end |
#warn(warning_num, msg) ⇒ Object
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/apipie/swagger_generator.rb', line 135 def warn(warning_num, msg) suppress = Apipie.configuration.swagger_suppress_warnings return if suppress == true return if suppress.is_a?(Array) && suppress.include?(warning_num) method_id = ruby_name_for_method(@current_method) warning_id = "#{method_id}#{warning_num}#{msg}" if @issued_warnings.include?(warning_id) # Already issued this warning for the current method return end print "WARNING (#{warning_num}): [#{method_id}] -- #{msg}\n" @issued_warnings.push(warning_id) @warnings_issued = true end |
#warn_added_missing_slash(path) ⇒ Object
126 |
# File 'lib/apipie/swagger_generator.rb', line 126 def warn_added_missing_slash(path) warn 101,"added missing / at beginning of path: #{path}"; end |
#warn_hash_without_internal_typespec(param_name) ⇒ Object
128 |
# File 'lib/apipie/swagger_generator.rb', line 128 def warn_hash_without_internal_typespec(param_name) warn 103,"the parameter :#{param_name} is a generic Hash without an internal type specification"; end |
#warn_inferring_boolean(name) ⇒ Object
133 |
# File 'lib/apipie/swagger_generator.rb', line 133 def warn_inferring_boolean(name) warn 108,"the parameter [#{name}] is Enum with [true,false] values. Inferring 'boolean'"; end |
#warn_missing_method_summary ⇒ Object
125 |
# File 'lib/apipie/swagger_generator.rb', line 125 def warn_missing_method_summary() warn 100, "missing short description for method"; end |
#warn_no_return_codes_specified ⇒ Object
127 |
# File 'lib/apipie/swagger_generator.rb', line 127 def warn_no_return_codes_specified() warn 102,"no return codes ('errors') specified"; end |
#warn_optional_param_in_path(param_name) ⇒ Object
129 |
# File 'lib/apipie/swagger_generator.rb', line 129 def warn_optional_param_in_path(param_name) warn 104, "the parameter :#{param_name} is 'in-path'. Ignoring 'not required' in DSL"; end |
#warn_optional_without_default_value(param_name) ⇒ Object
130 |
# File 'lib/apipie/swagger_generator.rb', line 130 def warn_optional_without_default_value(param_name) warn 105,"the parameter :#{param_name} is optional but default value is not specified (use :default_value => ...)"; end |
#warn_param_ignored_in_form_data(param_name) ⇒ Object
131 |
# File 'lib/apipie/swagger_generator.rb', line 131 def warn_param_ignored_in_form_data(param_name) warn 106,"ignoring param :#{param_name} -- cannot include Hash without fields in a formData specification"; end |
#warn_path_parameter_not_described(name, path) ⇒ Object
132 |
# File 'lib/apipie/swagger_generator.rb', line 132 def warn_path_parameter_not_described(name,path) warn 107,"the parameter :#{name} appears in the path #{path} but is not described"; end |