Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for distinguishing equivalent paths by parameter format in overloaded parameters #661

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ private static boolean methodsAndParametersIntersect(PathItem a, PathItem b) {
}

/**
* Checks is provided parameter pairs are equal by type and format
DrSatyr marked this conversation as resolved.
Show resolved Hide resolved
*
* @param left parameters from the first compared method
* @param right parameters from the second compared method
* @return <code>true</code> in case each parameter pair is of the same type; <code>false</code>
Expand All @@ -134,9 +136,21 @@ private static boolean parametersIntersect(List<Parameter> left, List<Parameter>
int parametersSize = left.size();
long intersectedParameters =
IntStream.range(0, left.size())
.filter(
i -> left.get(i).getSchema().getType().equals(right.get(i).getSchema().getType()))
.filter(i -> parametersTypeEquals(left.get(i), right.get(i)))
.count();
return parametersSize == intersectedParameters;
}

/**
* Checks is provided parameter pair equal by type and format
*
* @param left parameter from the first compared method
* @param right parameter from the second compared method
* @return <code>true</code> in case parameter pair is of the same type; <code>false</code>
* otherwise
*/
private static boolean parametersTypeEquals(Parameter left, Parameter right) {
return Objects.equals(left.getSchema().getType(), right.getSchema().getType())
&& Objects.equals(left.getSchema().getFormat(), right.getSchema().getFormat());
DrSatyr marked this conversation as resolved.
Show resolved Hide resolved
}
}
15 changes: 15 additions & 0 deletions core/src/test/resources/parameters_overloading.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@ info:
title: Projects API
version: 1.0.0
paths:
/projects/{key}:
DrSatyr marked this conversation as resolved.
Show resolved Hide resolved
get:
parameters:
- in: path
name: key
required: true
schema:
type: string
responses:
'200':
description: 'Success'
content:
application/json:
schema:
$ref: '#/components/schemas/SampleResponse'
/projects/{id}:
get:
parameters:
Expand Down