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

Failing test for an api with two different methods but same route. #1486

Closed
Closed
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 @@ -59,6 +59,14 @@ public async Task DiagnosticReportMergedForExternalReference()
result.OpenApiDiagnostic.Errors.Should().BeEquivalentTo(new List<OpenApiError> {
new( new OpenApiException("[File: ./TodoReference.yaml] Invalid Reference identifier 'object-not-existing'.")) });
}

[Fact]
public void DifferentVerbSameRouteShouldPass()
{
using var stream = Resources.GetStream("OpenApiReaderTests/Samples/differentMethodSameRoute.json");
new OpenApiStreamReader().Read(stream, out var diagnostic);
diagnostic.Errors.Should().BeEmpty();
}
}

public class ResourceLoader : IStreamLoader
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
"openapi": "3.0.1",
"info": {
"title": "OpenApi.IntegrationTest",
"version": "1.0"
},
"paths": {
"/api/v2/someroute/areatype/{index}/{arg}": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this snippet is invalid according to the specification

The following paths are considered identical and invalid:
/pets/{petId}
/pets/{name}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the response. Do I understand this correctly that it would be fine if language below would be renamed to arg and regenerated?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, but as you do so you'd then have to follow JSON conventions and merge the two nodes.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course. I could also include the verb hard coded in the path to keep them seperated.

I guess you're just following the specification, but it makes no sense to me.
Decrease readability or clutter the path. A bit frustrating for something that did pass just fine and now is not, Server handled it well. Clients handled it well. The specification doesn't.

In the end it's just two different endpoints without a direct relation.

Anyways, thanks for your time @baywet to shed some light over the behaviour.

"get": {
"tags": [
"Test"
],
"parameters": [
{
"name": "index",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"format": "int64"
}
},
{
"name": "arg",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Success"
}
}
}
},
"/api/v2/someroute/areatype/{index}/{language}": {
"put": {
"tags": [
"Test"
],
"parameters": [
{
"name": "index",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"format": "int32"
}
},
{
"name": "language",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "text",
"in": "query",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Success"
}
}
}
}
},
"components": {}
}