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

[BUG] [JAVA] GSON client does not accept null in JSON for an optional array #16212

Closed
5 tasks done
MarcMil opened this issue Jul 28, 2023 · 0 comments · Fixed by #16213
Closed
5 tasks done

[BUG] [JAVA] GSON client does not accept null in JSON for an optional array #16212

MarcMil opened this issue Jul 28, 2023 · 0 comments · Fixed by #16213

Comments

@MarcMil
Copy link
Contributor

MarcMil commented Jul 28, 2023

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
    An exception is thrown when the server does return a null for an optional array
Description

The Java GSON client does currently not accept a null for an optional array. Sadly, my server generates nulls instead of omitting the item. The client should accept it instead of throwing an exception

openapi-generator version

master

OpenAPI declaration file content or url
openapi: 3.0.1
info:
  title: Test API
  description: Test API
  version: '0.1'
paths:
  /api/jobs:
    get:
      summary: Gets a job
      operationId: getsJob
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Test'
components:
  schemas:
    Test:
      required:
        - id
      type: object
      properties:
        id:
          type: integer
          description: An id
          format: int64
          example: 1
Generation Details
Steps to reproduce

I'm generating the client with

<generatorName>java</generatorName>
<library>okhttp-gson</library>
Related issues/PRs
Suggest a fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant