Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The main change in this PR is to stop panicking when an API has circular references.
After the change I made here pb33f/libopenapi#39 libopenapi will return both the
Model
and a list of errors, if the only errors it encountered are circular references.Restish has no issues with processing API documents that contain circular references (verified experimentally).
An alternative implementation is to check if the Model is not nil, but I think the current implementation represents the intent better, at the expense of slightly more verbose error checking code.
I also took the liberty of fixing some deprecated function lint warnings.
Finally, I also changed the
Token
method ofRefreshTokenSource
to be a pointer receiver. The last line in that function tries to save the new token on the original token source, but that is ineffective: because it has a value receiver, you work on a copied value, and the change is never visible outside.This probably causes restish to go through a full auth flow way more often than it needs to be (essentially makes the refresh token single use).
It might be worthwhile to set up golangci-lint in CI, it's excellent at highlighting bugs like these.