Closed
Description
When using a Spec with equivalent paths (e.g. /projects/{id:int} and /projects/{uid:string}) openapi-diff outputs the following error:
Unexpected exception. Reason: Two path items have the same signature: /projects/{}
java.lang.IllegalArgumentException: Two path items have the same signature: /projects/{}
at org.openapitools.openapidiff.core.compare.PathsDiff.lambda$null$1(PathsDiff.java:50)
at java.util.function.BinaryOperator.lambda$minBy$0(BinaryOperator.java:59)
at java.util.stream.ReduceOps$2ReducingSink.accept(ReduceOps.java:123)
at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
at java.util.Iterator.forEachRemaining(Iterator.java:116)
at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.reduce(ReferencePipeline.java:546)
at java.util.stream.ReferencePipeline.min(ReferencePipeline.java:587)
at org.openapitools.openapidiff.core.compare.PathsDiff.lambda$diff$3(PathsDiff.java:48)
at java.util.LinkedHashMap$LinkedKeySet.forEach(LinkedHashMap.java:559)
at org.openapitools.openapidiff.core.compare.PathsDiff.diff(PathsDiff.java:41)
at org.openapitools.openapidiff.core.compare.OpenApiDiff.compare(OpenApiDiff.java:95)
at org.openapitools.openapidiff.core.compare.OpenApiDiff.compare(OpenApiDiff.java:66)
at org.openapitools.openapidiff.core.OpenApiCompare.fromSpecifications(OpenApiCompare.java:101)
at org.openapitools.openapidiff.core.OpenApiCompare.fromLocations(OpenApiCompare.java:90)
at org.openapitools.openapidiff.cli.Main.main(Main.java:169)
Equivalent paths are not supported in the swagger 2.0 specification. Validation tools output the following error: "Equivalent paths are not allowed."
But since parameter overloading is supported in openapi 3.0 equivalent paths should be supported.
When using a spec like the one below in openapi 3.0 validators, no errors are outputted. But when running the openapi-diff the error "Unexpected exception. Reason: Two path items have the same signature" is displayed.
Sample spec with equivalent paths (parameter overloading):
openapi: 3.0.2
info:
title: Projects API
version: 1.0.0
paths:
/projects/{id}:
get:
parameters:
- in: path
name: id
required: true
schema:
type: integer
format: int64
description: The Project ID
responses:
'200':
description: 'Success'
content:
application/json:
schema:
$ref: '#/components/schemas/Project'
/projects/{uid}:
get:
parameters:
- in: path
name: uid
required: true
schema:
type: string
format: uuid
description: The Project ID
responses:
'200':
description: 'Success'
content:
application/json:
schema:
$ref: '#/components/schemas/Project'
components:
schemas:
Project:
type: object
properties:
id:
type: integer
uid:
type: string
name:
type: string
required:
- id
- uid
- name