You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 15, 2022. It is now read-only.
The current setup has no way of gracefully handling recursive types; Recursively describing a type will expand the type tree forever with no way of stopping. In order to support recursive types we don't need to change anything about the Describe trait. Most of the work is handled by the Describer implementation:
A Describer should keep track of visited types and emit the appropriate type reference description.
When appropriate, a Describer should allow users to configure how type references in recursive types are handled, e.g. expanding the first occurrence of a type and then emitting a type ref for subsequent occurrences (ensuring that a generated schema is fully self-describing) vs always emitting type refs (which simplifies generated schemas but requires that all included types be described separately).
To update the provided Schema type and its describer, the following changes will also need to be made:
Add a TypeRef variant to the Schema containing a TypeName value`.
Internally track the TypeId of visited types and emits TypeRef for a named type after the first time its visited.
Support an alternate description mode where all named types are described as TypeRef.
It might be a good idea to provide a helper type that handles the common logic of tracking visited types. That logic is probably going to need to be shared by all Describer implementations, so we should provide utilities to reduce code duplication.
The text was updated successfully, but these errors were encountered:
The current setup has no way of gracefully handling recursive types; Recursively describing a type will expand the type tree forever with no way of stopping. In order to support recursive types we don't need to change anything about the
Describe
trait. Most of the work is handled by theDescriber
implementation:Describer
should keep track of visited types and emit the appropriate type reference description.Describer
should allow users to configure how type references in recursive types are handled, e.g. expanding the first occurrence of a type and then emitting a type ref for subsequent occurrences (ensuring that a generated schema is fully self-describing) vs always emitting type refs (which simplifies generated schemas but requires that all included types be described separately).To update the provided
Schema
type and its describer, the following changes will also need to be made:TypeRef
variant to theSchema
containing aTypeName
value`.TypeId
of visited types and emitsTypeRef
for a named type after the first time its visited.TypeRef
.It might be a good idea to provide a helper type that handles the common logic of tracking visited types. That logic is probably going to need to be shared by all
Describer
implementations, so we should provide utilities to reduce code duplication.The text was updated successfully, but these errors were encountered: