module Insights::API::Common::ApplicationControllerMixins::RequestPath::ClassMethods
Private Instance Methods
id_parameter_from_api_doc(primary_collection_name)
click to toggle source
# File lib/insights/api/common/application_controller_mixins/request_path.rb, line 57 def id_parameter_from_api_doc(primary_collection_name) # Find the id parameter in the documented route id_parameter = api_doc.paths.fetch_path("/#{primary_collection_name}/{id}", "get", "parameters", 0) # The route isn't documented, return nil return unless id_parameter # Return the id parameter or resolve the reference to it and return that reference = id_parameter["$ref"] return id_parameter unless reference api_doc.parameters[reference.split("parameters/").last] end
id_regexp(primary_collection_name)
click to toggle source
# File lib/insights/api/common/application_controller_mixins/request_path.rb, line 46 def id_regexp(primary_collection_name) @id_regexp_table ||= {} if @id_regexp_table.empty? || @id_regexp_table[primary_collection_name].nil? id_parameter = id_parameter_from_api_doc(primary_collection_name) @id_regexp_table[primary_collection_name] = id_parameter ? id_parameter.fetch_path("schema", "pattern") : /^\d+$/ end @id_regexp_table[primary_collection_name] end