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

Enums generations issue #113

Closed
Achraf-cyber opened this issue Dec 15, 2024 · 7 comments
Closed

Enums generations issue #113

Achraf-cyber opened this issue Dec 15, 2024 · 7 comments

Comments

@Achraf-cyber
Copy link

Since the last update, enums aren't generated at all. But other generated classes still depend on them.

@mmvergara
Copy link
Owner

Since the last update, enums aren't generated at all. But other generated classes still depend on them.

@Achraf-cyber You might need to specify your enums on supadart.yaml config file, i recommend trying to generate the supadart.yaml again. let me know if you already have it set and still doesn't work

The reason #108

tldr: there was an issue about enum array type generation enum[] and due to the swagger api limitations we need to specify them, you can read the issue for more info.

Im gonna keep this issue open and reimplement the functionality of generating the enums if the schema doesn't use enum[]

I recommend specifying them in the yaml file for future proofing

@Achraf-cyber
Copy link
Author

How do I specify the enums in the supadart.yaml file ?

@mmvergara
Copy link
Owner

How do I specify the enums in the supadart.yaml file ?

ahh year sry, you can do it like this. it's case sensitve.

# Do you have enums in your database? map them here
enums:
  # mood: [happy, sad, neutral, excited, angry]
  # usergroup: [USERS, ADMIN, MODERATOR]

i recommend also to lowercase the enum values to follow dart conventios

@BeezBeez
Copy link

Hey ! Thank you for this update !
Can we add this part about how to configure enum in the readme file ?

@mmvergara
Copy link
Owner

Hey ! Thank you for this update ! Can we add this part about how to configure enum in the readme file ?

Will do!, thanks

@mmvergara
Copy link
Owner

mmvergara commented Dec 20, 2024

Im gonna keep this issue open and reimplement the functionality of generating the enums if the schema doesn't use enum[]

I did a lot of thinking and just decided to not implement this, i think it's better to just be explicit about the enums, it's safer that way when it comes to generation and future proofing and it's not like we always add/change database enum for it to become cumbersome. instead i just improve the documentation for it.

  • You need to specify your enums on supadart.yaml config file
  • Enum names are converted to UPPERCASE to follow dart enum naming conventions
  • enum values are case-sensitive in postgres, so you need to specify them as they are in the database

@mmvergara
Copy link
Owner

Closing this if no further queries

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

No branches or pull requests

3 participants