-
Notifications
You must be signed in to change notification settings - Fork 246
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
ValidateOneOfDiscriminator errors #383
Comments
Here's a test to reproduce the error: [Fact]
public void ValidateOneOfDiscriminatorTest()
{
var openApiDocument = new OpenApiDocument
{
Info = new OpenApiInfo {Title = "My API", Version = "v1"},
Components = new OpenApiComponents(),
Paths = new OpenApiPaths
{
["/people"] = new OpenApiPathItem
{
Operations = new Dictionary<OperationType, OpenApiOperation>
{
[OperationType.Get] = new OpenApiOperation
{
Description = "Returns all people",
Responses = new OpenApiResponses
{
["200"] = new OpenApiResponse
{
Description = "OK",
Content = new Dictionary<string, OpenApiMediaType>
{
["application/json"] = new OpenApiMediaType
{
Schema = new OpenApiSchema
{
Type = "array",
Items = new OpenApiSchema
{
Discriminator = new OpenApiDiscriminator
{
PropertyName = "Type"
},
OneOf = new List<OpenApiSchema>
{
new OpenApiSchema
{
Reference = new OpenApiReference
{
Type = ReferenceType.Schema,
Id = "Person"
}
}
}
}
}
}
}
}
}
}
}
}
}
};
openApiDocument.Components.Schemas.Add("Person", new OpenApiSchema
{
Type = "object",
Required = new HashSet<string> {"Type", "Name"},
Properties = new Dictionary<string, OpenApiSchema>
{
{"Type", new OpenApiSchema {Type = "string"}},
{ "Name", new OpenApiSchema {Type = "string"}}
}
});
var openApiErrors = openApiDocument.Validate(ValidationRuleSet.GetDefaultRuleSet());
Assert.Empty(openApiErrors);
} |
closing as duplicate of #402 as we have more people engaged on 402 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm currently trying to generate an OpenAPI documentation using this library. When I try to add a discriminator in combination with
oneOf
I get a ton of errors after validation for theValidateOneOfDiscriminator
rule and I can't figure out what exactly is wrong.Error message examples:
When I serialize the
OpenApiDocument
and copy it to https://editor.swagger.io/ everything seems to be valid. Even if I use theOpenApiStreamReader
and validate it again there are no errors and after serializing it again there's no diff between the two documents.Any idea what the problem might be?
Here's a short version of my openapi.yaml
The text was updated successfully, but these errors were encountered: