Module: OasRails::Extractors::OasRouteExtractor
- Included in:
- Builders::OperationBuilder
- Defined in:
- lib/oas_rails/extractors/oas_route_extractor.rb
Instance Method Summary collapse
- #default_tags(oas_route:) ⇒ Object
- #extract_operation_id(oas_route:) ⇒ Object
- #extract_security(oas_route:) ⇒ Object
- #extract_summary(oas_route:) ⇒ Object
- #extract_tags(oas_route:) ⇒ Object
Instance Method Details
#default_tags(oas_route:) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/oas_rails/extractors/oas_route_extractor.rb', line 21 def (oas_route:) = [] if OasRails.config. == :namespace tag = oas_route.path.split('/').reject(&:empty?).first.try(:titleize) << tag unless tag.nil? else << oas_route.controller.gsub("/", " ").titleize end end |
#extract_operation_id(oas_route:) ⇒ Object
8 9 10 |
# File 'lib/oas_rails/extractors/oas_route_extractor.rb', line 8 def extract_operation_id(oas_route:) "#{oas_route.method}#{oas_route.path.gsub('/', '_').gsub(/[{}]/, '')}" end |
#extract_security(oas_route:) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/oas_rails/extractors/oas_route_extractor.rb', line 32 def extract_security(oas_route:) return [] if oas_route.docstring.(:no_auth).any? if (methods = oas_route.docstring.(:auth).first) OasRails.config.security_schemas.keys.map { |key| { key => [] } }.select do |schema| methods.types.include?(schema.keys.first.to_s) end elsif OasRails.config.authenticate_all_routes_by_default OasRails.config.security_schemas.keys.map { |key| { key => [] } } else [] end end |
#extract_summary(oas_route:) ⇒ Object
4 5 6 |
# File 'lib/oas_rails/extractors/oas_route_extractor.rb', line 4 def extract_summary(oas_route:) oas_route.docstring.(:summary).first.try(:text) || generate_crud_name(oas_route.method, oas_route.controller.downcase) || "#{oas_route.verb} #{oas_route.path}" end |
#extract_tags(oas_route:) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/oas_rails/extractors/oas_route_extractor.rb', line 12 def (oas_route:) = oas_route.docstring.(:tags).first if .nil? (oas_route:) else .text.split(",").map(&:strip).map(&:titleize) end end |