Skip to content

Commit

Permalink
fix: don't crash when trying to add an already registrer type for the…
Browse files Browse the repository at this point in the history
… same type.
  • Loading branch information
Angelinsky7 committed Apr 15, 2024
1 parent 0108842 commit 9e72993
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,17 @@ public void RegisterType(Type type, string schemaId)
{
var conflictingType = _reservedIds.First(entry => entry.Value == schemaId).Key;

throw new InvalidOperationException(
$"Can't use schemaId \"${schemaId}\" for type \"${type}\". " +
$"The same schemaId is already used for type \"${conflictingType}\"");
if(conflictingType != type)
{
throw new InvalidOperationException(
$"Can't use schemaId \"${schemaId}\" for type \"${type}\". " +
$"The same schemaId is already used for type \"${conflictingType}\"");
}
}
else
{
_reservedIds.Add(type, schemaId);
}

_reservedIds.Add(type, schemaId);
}

public bool TryLookupByType(Type type, out OpenApiSchema referenceSchema)
Expand Down

0 comments on commit 9e72993

Please sign in to comment.