Class: RailsOpenapiGen::Parsers::AttributeParser

Inherits:
Object
  • Object
show all
Includes:
BaseAttributeParser
Defined in:
lib/rails-openapi-gen/parsers/comment_parsers/attribute_parser.rb

Constant Summary collapse

REGEX =
/@openapi\s+(.+)$/

Instance Method Summary collapse

Instance Method Details

#parse(comment_text) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/rails-openapi-gen/parsers/comment_parsers/attribute_parser.rb', line 12

def parse(comment_text)
  # Skip conditional pattern which is handled by ConditionalParser
  return nil if comment_text.match?(/@openapi\s+conditional:true\s*$/)

  match = comment_text.match(REGEX)
  return nil unless match

  openapi_content = match[1].strip
  parse_attributes(openapi_content)
end