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 ID wrappers as path variables #33

Merged
merged 1 commit into from
Sep 2, 2021
Merged

Allow ID wrappers as path variables #33

merged 1 commit into from
Sep 2, 2021

Conversation

sgrimm
Copy link
Contributor

@sgrimm sgrimm commented Sep 2, 2021

Previously, if we wanted to include an ID value in the URL path, we had to declare
the path variable as Long in the controller and then explicitly create an ID
wrapper object.

This was needed because Spring MVC didn't know how to convert a string to an
instance of an ID wrapper class. So the simple fix is to add a constructor to the
wrapper classes that takes a string argument. If the client uses a non-numeric
value, it will fail with HTTP 400 the same way it fails with Long parameters.

Update all the controller methods that used to take Long arguments to instead
use the appropriate wrapper classes.

This caused us to hit swagger-api/swagger-core#3904 so
upgrade the OpenAPI library to get the fix for that.

Previously, if we wanted to include an ID value in the URL path, we had to declare
the path variable as `Long` in the controller and then explicitly create an ID
wrapper object.

This was needed because Spring MVC didn't know how to convert a string to an
instance of an ID wrapper class. So the simple fix is to add a constructor to the
wrapper classes that takes a string argument. If the client uses a non-numeric
value, it will fail with HTTP 400 the same way it fails with `Long` parameters.

Update all the controller methods that used to take `Long` arguments to instead
use the appropriate wrapper classes.

This caused us to hit swagger-api/swagger-core#3904 so
upgrade the OpenAPI library to get the fix for that.
@sgrimm
Copy link
Contributor Author

sgrimm commented Sep 2, 2021

In addition to running the test suite, I also tested this by running the seedbank-app Cypress test suite to confirm this doesn't introduce any behavior changes that break the front end.

@sgrimm sgrimm merged commit 64813e8 into main Sep 2, 2021
@sgrimm sgrimm deleted the wrapper-params branch September 2, 2021 21:33
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.

1 participant