Class: OasCore::YARD::OasCoreFactory
- Inherits:
-
YARD::Tags::DefaultFactory
- Object
- YARD::Tags::DefaultFactory
- OasCore::YARD::OasCoreFactory
- Defined in:
- lib/oas_core/yard/oas_core_factory.rb
Instance Method Summary collapse
-
#parse_tag_with_parameter(tag_name, text) ⇒ ParameterTag
Parses a tag that represents a parameter.
-
#parse_tag_with_parameter_reference(tag_name, text) ⇒ ParameterReferenceTag
Parses a tag that represents a parameter reference.
-
#parse_tag_with_request_body(tag_name, text) ⇒ RequestBodyTag
Parses a tag that represents a request body.
-
#parse_tag_with_request_body_example(tag_name, text) ⇒ RequestBodyExampleTag
Parses a tag that represents a request body example.
-
#parse_tag_with_request_body_reference(tag_name, text) ⇒ RequestBodyReferenceTag
Parses a tag that represents a request body reference.
-
#parse_tag_with_response(tag_name, text) ⇒ ResponseTag
Parses a tag that represents a response.
-
#parse_tag_with_response_example(tag_name, text) ⇒ ResponseExampleTag
Parses a tag that represents a response example.
-
#parse_tag_with_response_reference(tag_name, text) ⇒ ResponseReferenceTag
Parses a tag that represents a response reference.
Instance Method Details
#parse_tag_with_parameter(tag_name, text) ⇒ ParameterTag
Parses a tag that represents a parameter.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/oas_core/yard/oas_core_factory.rb', line 41 def parse_tag_with_parameter(tag_name, text) match = text.squish.match(/^(.*?)\s*\[(.*?)\]\s*(.*)$/) if match first = match[1] second = match[2] description = match[3] end name, location = text_and_last_parenthesis_content(first) raw_type, required = text_and_required(second) schema = raw_type_to_content(raw_type) name = "#{name}[]" if location == 'query' && schema[:type] == 'array' description, schema_keywords = extract_schema_keywords(description) schema.merge!(schema_keywords) ParameterTag.new(tag_name, name, description.strip, schema, location, required:) rescue StandardError => e raise TagParsingError, "Failed to parse parameter tag: #{e.}" end |
#parse_tag_with_parameter_reference(tag_name, text) ⇒ ParameterReferenceTag
Parses a tag that represents a parameter reference.
92 93 94 95 96 97 98 |
# File 'lib/oas_core/yard/oas_core_factory.rb', line 92 def parse_tag_with_parameter_reference(tag_name, text) ref = text.strip reference = OasCore::Spec::Reference.new(ref) ParameterReferenceTag.new(tag_name, reference) rescue StandardError => e raise TagParsingError, "Failed to parse parameter reference tag: #{e.}" end |
#parse_tag_with_request_body(tag_name, text) ⇒ RequestBodyTag
Parses a tag that represents a request body.
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/oas_core/yard/oas_core_factory.rb', line 12 def parse_tag_with_request_body(tag_name, text) description, raw_type = split_description_and_type(text.squish) description, content_type = text_and_last_parenthesis_content(description) raw_type, required = text_and_required(raw_type) content = raw_type_to_content(raw_type) RequestBodyTag.new(tag_name, description, content:, required:, content_type:) rescue StandardError => e raise TagParsingError, "Failed to parse request body tag: #{e.}" end |
#parse_tag_with_request_body_example(tag_name, text) ⇒ RequestBodyExampleTag
Parses a tag that represents a request body example.
27 28 29 30 31 32 33 34 35 |
# File 'lib/oas_core/yard/oas_core_factory.rb', line 27 def parse_tag_with_request_body_example(tag_name, text) description, raw_type = split_description_and_type(text.squish) raw_type, = text_and_required(raw_type) content = raw_type_to_content(raw_type) RequestBodyExampleTag.new(tag_name, description, content: content) rescue StandardError => e raise TagParsingError, "Failed to parse request body example tag: #{e.}" end |
#parse_tag_with_request_body_reference(tag_name, text) ⇒ RequestBodyReferenceTag
Parses a tag that represents a request body reference.
104 105 106 107 108 109 110 |
# File 'lib/oas_core/yard/oas_core_factory.rb', line 104 def parse_tag_with_request_body_reference(tag_name, text) ref = text.strip reference = OasCore::Spec::Reference.new(ref) RequestBodyReferenceTag.new(tag_name, reference) rescue StandardError => e raise TagParsingError, "Failed to parse request body reference tag: #{e.}" end |
#parse_tag_with_response(tag_name, text) ⇒ ResponseTag
Parses a tag that represents a response.
64 65 66 67 68 69 70 71 72 |
# File 'lib/oas_core/yard/oas_core_factory.rb', line 64 def parse_tag_with_response(tag_name, text) description, raw_type = split_description_and_type(text.squish) description, code = text_and_last_parenthesis_content(description) content = raw_type_to_content(raw_type) ResponseTag.new(tag_name, description, code, content) rescue StandardError => e raise TagParsingError, "Failed to parse response tag: #{e.}" end |
#parse_tag_with_response_example(tag_name, text) ⇒ ResponseExampleTag
Parses a tag that represents a response example.
78 79 80 81 82 83 84 85 86 |
# File 'lib/oas_core/yard/oas_core_factory.rb', line 78 def parse_tag_with_response_example(tag_name, text) description, raw_type = split_description_and_type(text.squish) description, code = text_and_last_parenthesis_content(description) content = raw_type_to_content(raw_type) ResponseExampleTag.new(tag_name, description, content: content, code:) rescue StandardError => e raise TagParsingError, "Failed to parse response example tag: #{e.}" end |
#parse_tag_with_response_reference(tag_name, text) ⇒ ResponseReferenceTag
Parses a tag that represents a response reference.
116 117 118 119 120 121 122 |
# File 'lib/oas_core/yard/oas_core_factory.rb', line 116 def parse_tag_with_response_reference(tag_name, text) reference_str, code_text = text_and_first_parenthesis_content(text.strip) reference = OasCore::Spec::Reference.new(reference_str) ResponseReferenceTag.new(tag_name, reference, code: code_text.to_i) rescue StandardError => e raise TagParsingError, "Failed to parse response reference tag: #{e.}" end |