Skip to content

Not nullable Properties are being set nullable #443

@JamesFieldist

Description

@JamesFieldist

Steps to reproduce

Using V3.1 standard

Use the below snippet that has both nullable: false and only type: "boolean" not type: ["boolean", "null"]

IsDefault is made a bool? in dart because it isn't in the required list.

Expected results

It should be bool because it isn't nullable and doesn't have "null" in a type array.

Actual results

@MappableClass()
class EmailAddressDto with EmailAddressDtoMappable {
  const EmailAddressDto({
    required this.address,
    required this.id,
    this.isDefault,
    this.isVerified,
    this.owningContactId,
  });
  final String address;
  final String? id;
  final bool? isDefault;
  final bool? isVerified;
  final String? owningContactId;


  static EmailAddressDto fromJson(Map<String, dynamic> json) => EmailAddressDtoMapper.ensureInitialized().decodeMap<EmailAddressDto>(json);

}

Your OpenApi snippet

      "EmailAddressDto": {
        "required": [
          "address",
          "id"
        ],
        "type": "object",
        "properties": {
          "address": {
            "type": "string",
            "nullable": false
          },
          "isDefault": {
            "type": "boolean",
            "nullable": false
          },
          "isVerified": {
            "type": "boolean",
            "nullable": false
          },
          "owningContactId": {
            "type": [
              "null",
              "string"
            ],
            "format": "uuid",
            "nullable": true
          },
          "id": {
            "type": [
              "null",
              "string"
            ],
            "description": "The unique identifier for the email address.",
            "format": "uuid",
            "nullable": true
          }
        },
        "nullable": false
      },

Code sample

Code sample
@MappableClass()
class EmailAddressDto with EmailAddressDtoMappable {
  const EmailAddressDto({
    required this.address,
    required this.id,
    this.isDefault,
    this.isVerified,
    this.owningContactId,
  });
  final String address;
  final String? id;
  final bool? isDefault;
  final bool? isVerified;
  final String? owningContactId;


  static EmailAddressDto fromJson(Map<String, dynamic> json) => EmailAddressDtoMapper.ensureInitialized().decodeMap<EmailAddressDto>(json);

}

isVerified should also not be null.

Logs

Logs
[Paste your logs here]

Dart version and used packages versions

Dart version
Dart SDK version: 3.11.1 (stable) (Tue Feb 24 00:03:07 2026 -0800) on "macos_arm64"
Packages version
swagger_parser: 1.41.0
(I'm using 1.41.0 becasue streaming binary is broken right now per #432 )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions