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

Use loading pattern #1553

Merged
merged 48 commits into from
Mar 26, 2024
Merged

Use loading pattern #1553

merged 48 commits into from
Mar 26, 2024

Conversation

MaggieKimani1
Copy link
Contributor

@MaggieKimani1 MaggieKimani1 commented Feb 7, 2024

This PR is an implementation of the loading design proposed as part of this conversation: #1446 (comment) which seeks to resolve the issue highlighted in #1434

It involves:

  • Creating a static factory for loading/parsing any OpenAPI model object that implements the Load/LoadAsync/Parse pattern as per this implementation https://learn.microsoft.com/en-us/dotnet/api/system.xml.linq.xdocument.load?view=net-7.0
  • Introducing static Load/LoadAsync/Parse methods in the OpenAPI document class to eliminate the discovery issue
  • Adding a registry class that allows users to register different OpenAPI format providers and their implementations
  • Moves the loading code into the core library so that people who only want to load JSON don't need a dependency on the third party YAML library
  • Short-circuits parsing of JSON documents by avoiding the YAML parser.

Fixes #1434
Fixes #1447

src/Microsoft.OpenApi/Reader/OpenApiReaderRegistry.cs Outdated Show resolved Hide resolved
src/Microsoft.OpenApi/Interfaces/IOpenApiReader.cs Outdated Show resolved Hide resolved
src/Microsoft.OpenApi/Interfaces/IOpenApiReader.cs Outdated Show resolved Hide resolved
src/Microsoft.OpenApi.Readers/OpenApiYamlReader.cs Outdated Show resolved Hide resolved
src/Microsoft.OpenApi/Models/OpenApiModelFactory.cs Outdated Show resolved Hide resolved
src/Microsoft.OpenApi/Models/OpenApiModelFactory.cs Outdated Show resolved Hide resolved
src/Microsoft.OpenApi/Reader/OpenApiJsonReader.cs Outdated Show resolved Hide resolved
Copy link

sonarcloud bot commented Feb 13, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
70.3% Coverage on New Code (required ≥ 80%)
13.8% Duplication on New Code (required ≤ 3%)
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarCloud

idea Catch issues before they fail your Quality Gate with our IDE extension SonarLint SonarLint

Copy link
Member

@darrelmiller darrelmiller left a comment

Choose a reason for hiding this comment

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

I think this PR looks good. I want have a conversation about having a Load method that doesn't require you to say what the format is, but we can defer that to conversation to after this PR has been merged..

Copy link

sonarcloud bot commented Mar 26, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
26.0% Coverage on New Code (required ≥ 80%)
15.5% Duplication on New Code (required ≤ 3%)
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarCloud

Catch issues before they fail your Quality Gate with our IDE extension SonarLint

@MaggieKimani1 MaggieKimani1 merged commit 624814d into release/2.0.0 Mar 26, 2024
5 of 8 checks passed
@MaggieKimani1 MaggieKimani1 deleted the mk/use-loading-pattern branch March 26, 2024 12:58
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.

4 participants