Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow circular references #151

Merged

Conversation

wdullaer
Copy link
Contributor

@wdullaer wdullaer commented Dec 7, 2022

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 of RefreshTokenSource 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.

@danielgtaylor
Copy link
Owner

Awesome, thank you!

@danielgtaylor danielgtaylor merged commit b5765fb into danielgtaylor:main Dec 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants