Class: OasRails::YARD::OasRailsFactory

Inherits:
YARD::Tags::DefaultFactory
  • Object
show all
Defined in:
lib/oas_rails/yard/oas_rails_factory.rb

Instance Method Summary collapse

Instance Method Details

#parse_tag_with_parameter(tag_name, text) ⇒ ParameterTag

Parses a tag that represents a parameter.

Parameters:

  • tag_name (String)

    The name of the tag.

  • text (String)

    The tag text to parse.

Returns:



26
27
28
29
# File 'lib/oas_rails/yard/oas_rails_factory.rb', line 26

def parse_tag_with_parameter(tag_name, text)
  name, location, schema, required, description = extract_name_location_schema_and_description(text)
  ParameterTag.new(tag_name, name, description, schema, location, required:)
end

#parse_tag_with_request_body(tag_name, text) ⇒ RequestBodyTag

Parses a tag that represents a request body.

Parameters:

  • tag_name (String)

    The name of the tag.

  • text (String)

    The tag text to parse.

Returns:



8
9
10
11
# File 'lib/oas_rails/yard/oas_rails_factory.rb', line 8

def parse_tag_with_request_body(tag_name, text)
  description, klass, schema, required = extract_description_and_schema(text)
  RequestBodyTag.new(tag_name, description, klass, schema:, required:)
end

#parse_tag_with_request_body_example(tag_name, text) ⇒ RequestBodyExampleTag

Parses a tag that represents a request body example.

Parameters:

  • tag_name (String)

    The name of the tag.

  • text (String)

    The tag text to parse.

Returns:



17
18
19
20
# File 'lib/oas_rails/yard/oas_rails_factory.rb', line 17

def parse_tag_with_request_body_example(tag_name, text)
  description, _, hash = extract_description_type_and_content(text, process_content: true, expresion: /^(.*?)\[([^\]]*)\](.*)$/m)
  RequestBodyExampleTag.new(tag_name, description, content: hash)
end

#parse_tag_with_response(tag_name, text) ⇒ ResponseTag

Parses a tag that represents a response.

Parameters:

  • tag_name (String)

    The name of the tag.

  • text (String)

    The tag text to parse.

Returns:



35
36
37
38
# File 'lib/oas_rails/yard/oas_rails_factory.rb', line 35

def parse_tag_with_response(tag_name, text)
  name, code, schema = extract_name_code_and_schema(text)
  ResponseTag.new(tag_name, code, name, schema)
end

#parse_tag_with_response_example(tag_name, text) ⇒ ResponseExampleTag

Parses a tag that represents a response example.

Parameters:

  • tag_name (String)

    The name of the tag.

  • text (String)

    The tag text to parse.

Returns:



44
45
46
47
# File 'lib/oas_rails/yard/oas_rails_factory.rb', line 44

def parse_tag_with_response_example(tag_name, text)
  description, code, hash = extract_name_code_and_hash(text)
  ResponseExampleTag.new(tag_name, description, content: hash, code:)
end