Skip to content
This repository has been archived by the owner on Sep 27, 2023. It is now read-only.

Bug in handling of tags when parsing Swagger 2.0 #43

Open
HaywardsHeathen opened this issue Nov 12, 2017 · 3 comments
Open

Bug in handling of tags when parsing Swagger 2.0 #43

HaywardsHeathen opened this issue Nov 12, 2017 · 3 comments

Comments

@HaywardsHeathen
Copy link

Parsing a Swagger 2.0 file which contains tags in an operation field results in the following exception being thrown.
Message: System.ArgumentNullException : Value cannot be null.
Parameter name: stream.

I created a new test to demonstrate the problem. It pulls in the swagger petstore example yaml file.

`V2ParsingTests
using Xunit;
using Tavis.OpenApi;

namespace OpenApiTests.V2Tests
{
public class V2ParsingTests
{
[Theory,
InlineData("OpenApiTests.V2Tests.V2Samples.petstore.yaml", true)]
public void Tests(string filename, bool expectedResult)
{
var v2stream = this.GetType().Assembly.GetManifestResourceStream(filename);
var openApiDoc2 = OpenApiParser.Parse(v2stream).OpenApiDocument;
var result = openApiDoc2.Version == "2.0";
Assert.True(result == expectedResult);
}

}

}
`
This is the resultant stack trace when the test is executed

Test Name: OpenApiTests.V2Tests.V2ParsingTests.Tests(filename: "OpenApiTests.V2Tests.V2Samples.petstore.yaml", expectedResult: True)
Test FullName: OpenApiTests.V2Tests.V2ParsingTests.Tests
Test Source: C:\Users\Rich\source\repos\Tavis.OpenApi\src\OpenApiTests\V2Tests\V2ParsingTests.cs : line 11
Test Outcome: Failed
Test Duration: 0:00:00.083

Result StackTrace:
at System.IO.StreamReader..ctor(Stream stream, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize, Boolean leaveOpen)
at System.IO.StreamReader..ctor(Stream stream)
at Tavis.OpenApi.OpenApiParser.Parse(Stream stream)
at OpenApiTests.V2Tests.V2ParsingTests.Tests(String filename, Boolean expectedResult) in C:\Users\Rich\source\repos\Tavis.OpenApi\src\OpenApiTests\V2Tests\V2ParsingTests.cs:line 13
Result Message:
System.ArgumentNullException : Value cannot be null.
Parameter name: stream

@darrelmiller
Copy link
Member

Thanks. Will investigate.

@darrelmiller
Copy link
Member

Sorry for the slow response. I believe the issue is resolved in this project https://github.com/Microsoft/OpenAPI.NET A nuget will be published soon.

@HaywardsHeathen
Copy link
Author

Thanks for following up 👍 I will take a look at https://github.com/Microsoft/OpenAPI.NET

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants