|
9 | 9 | #include <rapidjson/istreamwrapper.h>
|
10 | 10 | #include <sstream>
|
11 | 11 |
|
12 |
| -OASValidatorImp::OASValidatorImp(const std::string& oas_specs) |
| 12 | +OASValidatorImp::OASValidatorImp(const std::string& oas_specs, bool head_mapped_get) |
| 13 | + : head_mapped_get_(head_mapped_get) |
13 | 14 | {
|
14 | 15 | rapidjson::Document doc;
|
15 | 16 | ParseSpecs(oas_specs, doc);
|
@@ -175,7 +176,21 @@ ValidationError OASValidatorImp::GetValidators(const std::string& method, const
|
175 | 176 | auto err_code = method_validator_.Validate(method, error_msg);
|
176 | 177 | CHECK_ERROR(err_code)
|
177 | 178 |
|
178 |
| - auto enum_method = kStringToMethod.at(method); |
| 179 | + err_code = GetValidators(method, method, http_path, validators, error_msg, param_idxs, query); |
| 180 | + |
| 181 | + if (head_mapped_get_ && ValidationError::INVALID_ROUTE == err_code && (method == "head" || method == "HEAD")) { |
| 182 | + return GetValidators(method, "get", http_path, validators, error_msg, param_idxs, query); |
| 183 | + } |
| 184 | + |
| 185 | + return err_code; |
| 186 | +} |
| 187 | + |
| 188 | +ValidationError OASValidatorImp::GetValidators(const std::string& method, const std::string& mapped_method, |
| 189 | + const std::string& http_path, ValidatorsStore*& validators, |
| 190 | + std::string& error_msg, |
| 191 | + std::unordered_map<size_t, ParamRange>* param_idxs, std::string* query) |
| 192 | +{ |
| 193 | + auto enum_method = kStringToMethod.at(mapped_method); |
179 | 194 |
|
180 | 195 | auto query_pos = http_path.find('?');
|
181 | 196 | if (std::string::npos != query_pos && query) {
|
|
0 commit comments