Skip to content

[BUG] isNullable set for object properties #21351

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

Closed
allComputableThings opened this issue May 29, 2025 · 1 comment
Closed

[BUG] isNullable set for object properties #21351

allComputableThings opened this issue May 29, 2025 · 1 comment

Comments

@allComputableThings
Copy link

allComputableThings commented May 29, 2025

I'm doing some work on the Dart generator. I'm trying to add polymorphism to it (I already have a lot of code using the output of this generator), but I am running into another issue with nullable.

components:
   schemas:

    UserProfile:
      properties:
        family_name:
          default: null
          nullable: true
          type: string
        given_name:
          default: null
          nullable: true
          type: string
        locale:
          default: null
          nullable: true
          type: string
        profile_image:
          $ref: '#/components/schemas/Image'
          default: null         
          nullable: true         #   isNullable                <<<<<
        roles:
          items:
            enum:
            - child
            - teacher
            - student
            - admin
            - parent
            type: string
          nullable: true
          type: array
        source:
          default: null
          enum:
          - facebook
          - apple
          - user
          - google
          nullable: true
          type: string
        user_id:
          default: null
          nullable: true
          type: string
        user_profile_id:
          default: null
          nullable: true
          type: string
      type: object

Debugging what is parsed...

public class DartClientCodegen extends AbstractDartCodegen {
...
    @Override
    public ModelsMap postProcessModels(ModelsMap objs) {
        for (ModelMap mo :  objs.getModels()) {
            CodegenModel cm = mo.getModel();

            // Debug info - identify the models we're processing
            System.out.println("[1]Processing model: " + cm.name);

            if ("UserProfile".equals(cm.name)) {
                System.out.println("\n[1]FOUND UserProfile model - examining properties");
                // Directly examine the model's vars
                for (CodegenProperty prop : cm.vars) {
                    if ("profileImage".equals(prop.name)) {
                        System.out.println("[1]FOUND profileImage property in UserProfile:");
                        System.out.println("  - Property name: " + prop.name);
                        System.out.println("  - DataType: " + prop.dataType);
                        System.out.println("  - ComplexType: " + prop.complexType);
                        System.out.println("  - IsNullable: " + prop.isNullable);
                        System.out.println("  - IsModel: " + prop.isModel);
                    }
                }
            }
        }

I get ....

% java -jar ../../openapi-generator/modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -i swagger.yaml -g dart -o ./_swagger --additional-properties=pubLibrary=flutter_common_openapi,pubName=flutter_common_openapi --openapi-normalizer REF_AS_PARENT_IN_ALLOF=true,REMOVE_ANYOF_ONEOF_AND_KEEP_PROPERTIES_ONLY=true,DISABLE_ALL=false)

[1]Processing model: UserProfile

[1]FOUND UserProfile model - examining properties
[1]FOUND profileImage property in UserProfile:
  - Property name: profileImage
  - DataType: Image
  - ComplexType: Image
  - IsNullable: false                     << ????? not isNullable
  - IsModel: true
Processing model: UserProfile

Also tried removing profile_image.default and adding required: []. Results seemed the same.

The nullable fields that are basic types seem correctly parsed and have isNullable set.

@allComputableThings allComputableThings changed the title [BUG] Why not isNullable [BUG] isNullable set for object properties May 29, 2025
@allComputableThings
Copy link
Author

allComputableThings commented May 29, 2025

Nothingburger. Seems caused by other local changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant