You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm willing to sponsor work on this issue to the tune of $300 (cc @wing328)
Is your feature request related to a problem? Please describe.
I am trying to implement a PATCH endpoint that only modifies non-null attributes of the incoming request body. The request body has an optional field with type array, that should be set to null for PATCH requests that don't modify this field.
However, the jaxrs-spec codegen forces a default value of new ArrayList<>() instead of null. This means that the server cannot distinguish between a PATCH request that wants to set the field to an empty list, versus a PATCH request that wants to leave that field alone.
(Note that I'm very new to this codebase and doing my best to piece together how this all works, apologies if I'm not linking to the right places in code).
This PR has a very similar discussion and solution for the java generator: #3585 (comment)
I'm willing to sponsor work on this issue to the tune of $300 (cc @wing328)
Is your feature request related to a problem? Please describe.
I am trying to implement a
PATCH
endpoint that only modifies non-null attributes of the incoming request body. The request body has an optional field with typearray
, that should be set tonull
for PATCH requests that don't modify this field.However, the
jaxrs-spec
codegen forces a default value ofnew ArrayList<>()
instead ofnull
. This means that the server cannot distinguish between a PATCH request that wants to set the field to an empty list, versus a PATCH request that wants to leave that field alone.Describe the solution you'd like
It looks like the behavior I want is present in the JavaJaxRS/pojo.mustache template here:
https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/JavaJaxRS/pojo.mustache#L39-L44
but not in the JavaJaxRS/spec/pojo.mustache template:
https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/pojo.mustache#L28
(Note that I'm very new to this codebase and doing my best to piece together how this all works, apologies if I'm not linking to the right places in code).
This PR has a very similar discussion and solution for the
java
generator: #3585 (comment)Describe alternatives you've considered
I'm open to ideas for workarounds/alternatives!
Additional context
Steps to recreate my problem from scratch:
docker pull openapitools/openapi-generator-cli:latest
spec.yaml
:docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli:latest generate -i local/spec.yaml -g jaxrs-spec -o /local/out/java
Body.java
, notice that it defaults to anew ArrayList<>()
instead ofnull
:java
generator, for example, which generates thisBody.java
:The text was updated successfully, but these errors were encountered: