prevent self-referential types in generated modules

This commit is contained in:
Bryton Hall 2022-08-28 01:52:29 -04:00
parent 8fec3d8f9e
commit 6dfa8e81c7
7 changed files with 44 additions and 38 deletions

View file

@ -138,7 +138,10 @@ with lib; let
type = requiredOrNot (mapType swagger.definitions.${refDefinition property});
}
else {
type = requiredOrNot (submoduleOf definitions (refDefinition property));
type =
if (refDefinition property) == _name
then types.unspecified # do not allow self-referential values
else requiredOrNot (submoduleOf definitions (refDefinition property));
}
# if property has an array type
else if property.type == "array"
@ -165,7 +168,10 @@ with lib; let
}
# in other case it's a simple list
else {
type = requiredOrNot (types.listOf (submoduleOf definitions (refDefinition property.items)));
type =
if (refDefinition property.items) == _name
then types.unspecified # do not allow self-referential values
else requiredOrNot (types.listOf (submoduleOf definitions (refDefinition property.items)));
}
# in other case it only references a simple type
else {