Skip to content

Add deserializers and restructure the Reader unit tests - #113

Merged
Darrel (darrelmiller) merged 11 commits into
masterfrom
PerthCharern/UpdateV2Reader
Dec 11, 2017
Merged

Darrel (darrelmiller) merged 11 commits into
masterfrom
PerthCharern/UpdateV2Reader

Conversation

@PerthCharern

Copy link
Copy Markdown
Contributor

Fix #32, Fix #50, Fix #109

Deserializer

  • Add V3 deserializer for
    • Discriminator
    • Xml
    • Encoding
  • Add V2 deserializer
    • Xml
  • Fix V2 and V3 deserializers
    • Schema
    • Document
  • Revise the entire logic in V2 deserializer
    • SecurityScheme

Unit tests

  • Revise the structure of Reader unit test. I had to write unit test for my changes above, so I took this chance to rewrite or modify the related tests.
    • V3 and V2 tests are now completly separated.
    • For each version, the tests are separated by the class objects they are actually testing (eg. Document, Schema). This mirrors the partial classes in the code in the Reader itself.
    • Use File.OpenRead
    • Add more examples and tests for all the classes I touched above. Only one test exists for V2 right now (SecurityScheme). More tests can be added later.

- Fix deserializer for SecurityScheme, Schema, Document
- Update V2Tests
- Restructure the tests to resemble the deserializers. Future tests can now be written per object type.
- Fix issues in Schema Deserializer

namespace Microsoft.OpenApi.Tests.Models
{
[Collection("DefaultSettings")]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

[Collection("DefaultSettings")] [](start = 1, length = 34)

I'll create another issue to add this Fixture to all test classes in Microsoft.OpenApi.Tests in a separate PR since I don't want to blow up this one, which is already pretty big.

Nothing is failing there right now, but this is a good safeguard.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Created #114 to track this work.


In reply to: 155909370 [](ancestors = 155909370)

public class ParameterTests
{
[Collection("DefaultSettings")]
public class OpenApiParameterTests

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

OpenApiParameterTests [](start = 17, length = 21)

This behavior should not be in scope for our library. Handling different ways to serialize parameter based on the given properties should be the job of other toolings (e.g. Swagger UI). I'll remove this test.

namespace Microsoft.OpenApi.Readers.V2
{
/// <summary>
/// Class containing logic to deserialize Open API V3 document into

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Will fix comment to V2

}

// Put the Flow object in the right Flows property based on the string in "flow"
if (flowValue == OpenApiConstants.Implicit)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

if [](start = 12, length = 2)

nit, consider a switch statement

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll make this fix with a future PR.

<None Include="V3Tests\Samples\OpenApiCallback\advancedCallbackWithReference.yaml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="V3Tests\Samples\OpenApiInfo\advancedInfo.yaml">

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[](start = 4, length = 2)

nit, indentation

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This will be a part of #129

@scott-lin Scott Lin (scott-lin) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

:shipit:

@darrelmiller

Copy link
Copy Markdown
Member

I'm going to merge this so that I can add more tests without creating merge conflicts.

@darrelmiller
Darrel (darrelmiller) merged commit 7d48424 into master Dec 11, 2017
@darrelmiller
Darrel (darrelmiller) deleted the PerthCharern/UpdateV2Reader branch December 11, 2017 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants