Class: Apipie::Generator::Swagger::Warning
- Inherits:
-
Object
- Object
- Apipie::Generator::Swagger::Warning
- Defined in:
- lib/apipie/generator/swagger/warning.rb
Constant Summary collapse
- MISSING_METHOD_SUMMARY_CODE =
100
- ADDED_MISSING_SLASH_CODE =
101
- NO_RETURN_CODES_SPECIFIED_CODE =
102
- HASH_WITHOUT_INTERNAL_TYPESPEC_CODE =
103
- OPTIONAL_PARAM_IN_PATH_CODE =
104
- OPTIONAL_WITHOUT_DEFAULT_VALUE_CODE =
105
- PARAM_IGNORED_IN_FORM_DATA_CODE =
106
- PATH_PARAM_NOT_DESCRIBED_CODE =
107
- CODES =
{ missing_method_summary: MISSING_METHOD_SUMMARY_CODE, added_missing_slash: ADDED_MISSING_SLASH_CODE, no_return_codes_specified: NO_RETURN_CODES_SPECIFIED_CODE, hash_without_internal_typespec: HASH_WITHOUT_INTERNAL_TYPESPEC_CODE, optional_param_in_path: OPTIONAL_PARAM_IN_PATH_CODE, optional_without_default_value: OPTIONAL_WITHOUT_DEFAULT_VALUE_CODE, param_ignored_in_form_data: PARAM_IGNORED_IN_FORM_DATA_CODE, path_param_not_described_code: PATH_PARAM_NOT_DESCRIBED_CODE }.freeze
- MESSAGES =
{ MISSING_METHOD_SUMMARY_CODE => "Missing short description for method", ADDED_MISSING_SLASH_CODE => "Added missing / at beginning of path: %{path}", HASH_WITHOUT_INTERNAL_TYPESPEC_CODE => "The parameter :%{parameter} is a generic Hash without an internal type specification", NO_RETURN_CODES_SPECIFIED_CODE => "No return codes ('errors') specified", OPTIONAL_PARAM_IN_PATH_CODE => "The parameter :%{parameter} is 'in-path'. Ignoring 'not required' in DSL", OPTIONAL_WITHOUT_DEFAULT_VALUE_CODE => "The parameter :%{parameter} is optional but default value is not specified (use :default_value => ...)", PARAM_IGNORED_IN_FORM_DATA_CODE => "Ignoring param :%{parameter} -- cannot include Hash without fields in a formData specification", PATH_PARAM_NOT_DESCRIBED_CODE => "The parameter :%{name} appears in the path %{path} but is not described" }.freeze
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
Class Method Summary collapse
Instance Method Summary collapse
- #id ⇒ Object
-
#initialize(code, info_message, method_id) ⇒ Warning
constructor
A new instance of Warning.
- #warn ⇒ Object
- #warn_through_writer ⇒ Object
- #warning_message ⇒ Object
Constructor Details
#initialize(code, info_message, method_id) ⇒ Warning
Returns a new instance of Warning.
35 36 37 38 39 |
# File 'lib/apipie/generator/swagger/warning.rb', line 35 def initialize(code, , method_id) @code = code @info_message = @method_id = method_id end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
33 34 35 |
# File 'lib/apipie/generator/swagger/warning.rb', line 33 def code @code end |
Class Method Details
.for_code(code, method_id, message_attributes = {}) ⇒ Apipie::Generator::Swagger::Warning
61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/apipie/generator/swagger/warning.rb', line 61 def self.for_code(code, method_id, = {}) if !CODES.value?(code) raise ArgumentError, 'Unknown warning code' end = if .present? self::MESSAGES[code] % else self::MESSAGES[code] end Apipie::Generator::Swagger::Warning.new(code, , method_id) end |
Instance Method Details
#id ⇒ Object
41 42 43 |
# File 'lib/apipie/generator/swagger/warning.rb', line 41 def id "#{@method_id}#{@code}#{@info_message}" end |
#warn ⇒ Object
49 50 51 |
# File 'lib/apipie/generator/swagger/warning.rb', line 49 def warn Warning.warn() end |
#warn_through_writer ⇒ Object
53 54 55 |
# File 'lib/apipie/generator/swagger/warning.rb', line 53 def warn_through_writer Apipie::Generator::Swagger::WarningWriter.instance.warn(self) end |
#warning_message ⇒ Object
45 46 47 |
# File 'lib/apipie/generator/swagger/warning.rb', line 45 def "WARNING (#{@code}): [#{@method_id}] -- #{@info_message}\n" end |