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

Libs(Go): unestting nullable array fields via PATCH request #1496

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

svix-onelson
Copy link
Contributor

Work was done previously [1] to make nullable containers (arrays, maps) generate as refs. This avoided a problem where the JSON serialization code incrrectly sent an empty array for cases where a field was left unset. This would result in requests incorrectly failing with a 422 response when it should have been OK.

During the openapi generator update [2], the resulting codegen no longer had the 422 issue since it correctly omitted empty arrays from the body for PATCH requests. However, this now means we have no way to explicitly set a field to null. This specific issue was fixed in the some other langs with the work done to update the generator, but the Go generator seems to have fallen behind.

This rev adds tests to demonstrate the shortfall. We may need to rework the template patch made for the old 5.x generator to solve this in the meantime.

Motivation

Solution

Work was done previously [1] to make nullable containers (arrays, maps)
generate as refs. This avoided a problem where the JSON serialization
code incrrectly sent an empty array for cases where a field was left
unset. This would result in requests incorrectly failing with a 422
response when it should have been OK.

During the openapi generator update [2], the resulting codegen no longer
had the 422 issue since it correctly omitted empty arrays from the body
for PATCH requests. However, this now means we have no way to explicitly
set a field to `null`. This specific issue was fixed in the some other langs
with the work done to update the generator, but the Go generator seems to
have fallen behind.

This rev adds tests to demonstrate the shortfall. We may need to rework
the template patch made for the old 5.x generator to solve this in the
meantime.

- 1: #1450
- 2: #1480
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