openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

[BUG][DART] Non-required non-nullable field is always assigned null value if value not present

Open alexpyc opened this issue 1 year ago • 0 comments

Bug Report Checklist

  • [x] Have you provided a full/minimal spec to reproduce the issue?
  • [x] Have you validated the input using an OpenAPI validator (example)?
  • [x] Have you tested with the latest master to confirm the issue still exists?
  • [x] Have you searched for related issues/PRs?
  • [x] What's the actual output vs expected output?
  • [ ] [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

Dart generator always insert null for non-required non-nullable field if a value is not provided. However, it seems not the specified behaviour.

openapi-generator version

7.5.0

OpenAPI declaration file content or url
    UpdateUser:
      type: object
      required: []
      properties:
        name:
          type: string
          example: testName
          nullable: false
        (...)
Generation Details

java -jar openapi-generator-cli.jar generate -i {input filename} -g dart -o {output directory name}

Steps to reproduce

Generate output with the above code snippet

Related issues/PRs

https://github.com/OpenAPITools/openapi-generator/pull/12569/commits/8002e558858e252d78248bd9db51a24498780360

Suggest a fix

This PR comment should point out the issue. Non-required, non-nullable field should not by default assign a null value which should be contradictory to how JSON schema treats non-required field.

alexpyc avatar May 12 '24 12:05 alexpyc