OpenAPI.NET icon indicating copy to clipboard operation
OpenAPI.NET copied to clipboard

Investigate how to skip validation of unresolved reference schema

Open irvinesunday opened this issue 2 years ago • 0 comments

This test has been removed in v2. We need to investigate how to properly check for unresolve JSON Schema refs and skip validation.

public void UnresolvedReferenceSchemaShouldNotBeValidated()
{
    // Arrange
    var sharedSchema = new JsonSchemaBuilder().Type(SchemaValueType.String).Ref("test").Build();

    OpenApiDocument document = new OpenApiDocument();
    document.Components = new OpenApiComponents()
    {
        Schemas = new Dictionary<string, JsonSchema>()
        {
            ["test"] = sharedSchema
        }
    };

    // Act
    var rules = new Dictionary<string, IList<ValidationRule>>()
    {
        { typeof(JsonSchema).Name,
            new List<ValidationRule>() { new AlwaysFailRule<JsonSchema>() }
        }
    };

    var errors = document.Validate(new ValidationRuleSet(rules));

    // Assert
    Assert.True(!errors.Any());
}

irvinesunday avatar Oct 18 '23 12:10 irvinesunday