Skip to content

[dart-dio] Fix compile error in enum properties with "default" values (#20495) #21355

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

chizhanov
Copy link
Contributor

This PR solves the problem described in #20495.

I made this fix locally and on my openapi the issue was fixed and no new issues were found.

@jaumard (2018/09) @josh-burton (2019/12) @amondnet (2019/12) @sbu-WBT (2020/12) @kuhnroyal (2020/12) @agilob (2020/12) @ahmednfwela (2021/08)

@kuhnroyal
Copy link
Contributor

kuhnroyal commented Jun 3, 2025

Do we have this in one of the samples? Probably not...

@chizhanov
Copy link
Contributor Author

Do we have this in one of the samples? Probably not...

I didn't see it, but we can try to add it:

OpenAPI spec:

{
  "openapi": "3.1.0",
  "info": {
    "title": "Simple",
    "version": "0.0.1"
  },
  "paths": {},
  "components": {
    "schemas": {
      "TestEnum": {
        "type": "string",
        "enum": [
          "",
          "1",
          "2"
        ],
        "title": "TestEnum"
      },
      "TestItem": {
        "properties": {
          "test": {
            "type": "integer",
            "title": "test"
          },
          "testEmum": {
            "$ref": "#/components/schemas/TestEnum",
            "default": ""
          }
        },
        "type": "object",
        "required": [
          "test"
        ],
        "title": "TestItem"
      }
    }
  },
  "tags": []
}

And problem will be here:

@BuiltValueHook(initializeBuilder: true)
  static void _defaults(TestItemBuilder b) => b
      ..testEmum = const ._(TestEnum.empty);

@barryguvenkaya
Copy link

@ahmednfwela would be great to get this reviewed ASAP please because it affects us too.

@ahmednfwela
Copy link
Contributor

@wing328 can this case be added to any of the samples we use? unfortunately they are all shared with other generators

@wing328
Copy link
Member

wing328 commented Jul 3, 2025

@chizhanov did you test it locally to confirm it works for you?

i can add a test or 2 later using a dedicated for dart client tests.

@wing328
Copy link
Member

wing328 commented Jul 3, 2025

i just merged #21516 to the master to have dart dedicated test spec (fake petstore)

can you please merge the latest master into your branch and add a test schema with enum properties (with default values) and regenerate the samples (step 3 in pr checklist) when you've time?

dart test spec: modules/openapi-generator/src/test/resources/3_0/dart/petstore-with-fake-endpoints-models-for-testing.yaml

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

Successfully merging this pull request may close these issues.

5 participants