Validate path params defined on the path item
Since parameters can be defined on both the path item or the operation, we need to validate path params against both objects, like we do with the query params.
@ota42y ahh good catch! I'm not likely to be able to look at this for a week or so. If I get to it before you I'm happy to have a go, otherwise all yours. Thanks! 😁
There is no reason to rush to release a new version, so give it a try! 😄
@ota42y I haven't added any specs for this yet, I wanted to see what you thought of the implementation. I've opted to merge the individual hashes explicitly in the OpenAPIParser::Schemas::Operation class since I think it makes it clearer what's going on.
Alternatively, we could add a public ParameterValidatable#merged_params method and keep the merging all inside the ParameterValidatable concern. Something like:
# module OpenAPIParser::ParameterValidatable
def merged_params
return divided_parameter_hash unless parent&.respond_to?(:merged_params)
@merged_params ||= Hash.new do |merged_params, location|
parent_params = parent.merged_params[location] || {}
merged_params[location] = parent_params.merge(divided_parameter_hash[location])
end
end
def header_parameter_hash
merged_params['header'] || {}
end
# etc…
I think this is a more abstract and less obvious approach though.
What do you think?
Sorry for late reply... 🙇
I think this is a more abstract and less obvious approach though. I think so too.
Your approach( merging in the OpenAPIParser::Schemas::Operation ) is very good 👍 👍 👍 👍 👍
- Performance is good because once merged it will not change after that.
- Components Object does not have Operation Object in OpenAPI 3 definition so Operation Object is always under the Path Item Object.
@ota42y thanks for the feedback. I'll add some specs and ping you for a final review.