Skip to content

Conversation

@MaggieKimani1
Copy link
Contributor

@MaggieKimani1 MaggieKimani1 commented Aug 20, 2024

This PR:

  • Uninstalls JsonSchema.NET library from the core and Readers project
  • Refactors the entire codebase by replacing the JsonSchema object from JsonSchema.NET with our native OpenApiSchema implementation that supports all V2, V3, and V31-specific keywords.
  • Adds support for pattern properties keyword in line with JSON schema.
  • Adds support for the examples keyword in the OpenApiSchema object in line with JSON schema as the example property has been deprecated in favor of it.
  • Enables local and external document dereferencing using JSON pointer to component as well as $ref to $id by:
    • Refactoring component registry to use id as a locator when registering schemas in the registry and performing lookups during reference resolution.
    • Creating an OpenApiSchemaReference object that acts as a proxy for lazy schema reference resolution
  • Refactors to use JsonNode in place of OpenApiAny for Enums and Examples
  • Adds tests for validation and refactors existing tests.

Issues resolved
#1789
#1790
#1791
#1792
#1793

# Conflicts:
#	src/Microsoft.OpenApi/Models/OpenApiSchema.cs
@MaggieKimani1 MaggieKimani1 marked this pull request as draft August 20, 2024 14:47
ExternalResource = externalResource
};

Reference = _reference;

Check warning

Code scanning / CodeQL

Virtual call in constructor or destructor

Avoid virtual calls in a constructor or destructor.
Comment on lines 91 to 107
foreach (var kvp in anyObject)
{
foreach (var detail in results.Details)
var key = kvp.Key;
context.Enter(key);

if (schema.Properties != null &&
schema.Properties.TryGetValue(key, out var property))
{
if (detail.Errors != null && detail.Errors.Any())
{
foreach (var error in detail.Errors)
{
if (!string.IsNullOrEmpty(error.Key) || !string.IsNullOrEmpty(error.Value.Trim()))
{
context.CreateWarning(ruleName, string.Format("{0} : {1} at {2}", error.Key, error.Value.Trim(), detail.InstanceLocation));
}
}
}
ValidateDataTypeMismatch(context, ruleName, anyObject[key], property);
}
else
{
ValidateDataTypeMismatch(context, ruleName, anyObject[key], schema.AdditionalProperties);
}

context.Exit();
}

Check notice

Code scanning / CodeQL

Missed opportunity to use Select

This foreach loop immediately [maps its iteration variable to another variable](1) - consider mapping the sequence explicitly using '.Select(...)'.
@MaggieKimani1 MaggieKimani1 marked this pull request as ready for review August 27, 2024 08:33
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
74.9% Coverage on New Code (required ≥ 80%)
D 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 4fdd0e8 into release/2.0.0 Aug 27, 2024
@MaggieKimani1 MaggieKimani1 deleted the mk/use-json-schema-model branch August 27, 2024 13:41
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