Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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 if provided parameter pairs are equal by type and format
*
* @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 if provided parameter pair is 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());
}
}
35 changes: 35 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}:
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 Expand Up @@ -35,6 +50,26 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/SampleResponse'
/projects/{id}.{idPostfix}:
get:
parameters:
- in: path
name: id
required: true
schema:
type: string
- in: path
name: idPostfix
required: true
schema:
type: string
responses:
'200':
description: 'Success'
content:
application/json:
schema:
$ref: '#/components/schemas/SampleResponse'
components:
schemas:
SampleResponse:
Expand Down