It is possible to have endpoints where the path parameters determine which specific endpoint is called, for example:
get(/\/items\/(\d+)/) do |id|
content_type :json
JSON.generate(items[id.to_i])
end
get(/\/items\/([^\d]+)/) do |name|
content_type :json
JSON.generate(items_map[name])
end
Currently OpenapiFirst cannot handle these weird cases as every path parameter is replaced with %r{([^/?#]+)} in lib/openapi_first/router/path_template.rb meaning that calls to both endpoints will be validated against the same endpoint form the openapi definition.
I suggest (and have already implemented in a fork) that you have an optional setting which uses the regex provided with the pattern of a path parameter to match paths.
This needs to be optional since people might use these patterns to validate the user input.
It is possible to have endpoints where the path parameters determine which specific endpoint is called, for example:
Currently OpenapiFirst cannot handle these weird cases as every path parameter is replaced with
%r{([^/?#]+)}in lib/openapi_first/router/path_template.rb meaning that calls to both endpoints will be validated against the same endpoint form the openapi definition.I suggest (and have already implemented in a fork) that you have an optional setting which uses the regex provided with the
patternof a path parameter to match paths.This needs to be optional since people might use these patterns to validate the user input.