Skip to content

Commit

Permalink
Resolves RicoSuter#1547: Make RemoveNullability virtual for extendabi…
Browse files Browse the repository at this point in the history
…lity

This allows to implement different logic e.g. treat JsonSchema.OneOf
to have multiple (non nullable) items instead of zero or one.
  • Loading branch information
SamuelBerger committed Aug 7, 2022
1 parent 5476815 commit 1d4363f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/NJsonSchema.CodeGeneration/TypeResolverBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public void RegisterSchemaDefinitions(IDictionary<string, JsonSchema> definition
/// <summary>Removes a nullable oneOf reference if available.</summary>
/// <param name="schema">The schema.</param>
/// <returns>The actually resolvable schema</returns>
public JsonSchema RemoveNullability(JsonSchema schema)
public virtual JsonSchema RemoveNullability(JsonSchema schema)
{
// TODO: Method on JsonSchema4?
return schema.OneOf.FirstOrDefault(o => !o.IsNullable(SchemaType.JsonSchema)) ?? schema;
Expand Down

0 comments on commit 1d4363f

Please sign in to comment.