This is a nasty bug: so far I've failed to nail it.
When expanding schemas in a spec for further use (e.g. validating the spec, flattening it with the expand option),
circular $ref are left in a unusable state in the $ref cache, leading to jsonpointer errors (e.g. "xxx has no key yyy")
when attempting to resolve.
This is for example the root cause for go-swagger/go-swagger#2346.
In go-swagger, it is possible to work around this issue by reloading the spec as a fresh go-openapi/loads.Document,
but this is not ideal.
This workaround is used on 2 occasions in go-swagger:
This is a nasty bug: so far I've failed to nail it.
When expanding schemas in a spec for further use (e.g. validating the spec, flattening it with the expand option), circular $ref are left in a unusable state in the $ref cache, leading to jsonpointer errors (e.g. "xxx has no key yyy") when attempting to resolve.
This is for example the root cause for go-swagger/go-swagger#2346. In go-swagger, it is possible to work around this issue by reloading the spec as a fresh go-openapi/loads.Document, but this is not ideal. This workaround is used on 2 occasions in go-swagger: