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

[QUESTION] Need option to shorten model names #361

Closed
skiryuk opened this issue Mar 23, 2022 · 10 comments · Fixed by #363
Closed

[QUESTION] Need option to shorten model names #361

skiryuk opened this issue Mar 23, 2022 · 10 comments · Fixed by #363
Assignees
Labels
question Further information is requested

Comments

@skiryuk
Copy link

skiryuk commented Mar 23, 2022

Now we have long model names on the project after generation. Is there a way to shorten them?
Maybe in the settings specify a prefix that will be deleted?

image

@skiryuk skiryuk added the question Further information is requested label Mar 23, 2022
@Vovanella95
Copy link
Collaborator

Hi @skiryuk , it's interesting case. I think it's really specific, we need another way to avoid it. Possible we can create some kind of regex to modify model names. Need to think about it.

Maybe you have some another ideas?

@Vovanella95
Copy link
Collaborator

@skiryuk For example, you can use separate models with nice names across the app. You just need to create repository, make an API call and parse generated model to domain model with good name.

@skiryuk
Copy link
Author

skiryuk commented Mar 23, 2022

Hi @skiryuk , it's interesting case. I think it's really specific, we need another way to avoid it. Possible we can create some kind of regex to modify model names. Need to think about it.

Maybe you have some another ideas?

Regular expression mean the post processing generated files? We had a similar idea to cut static the name at the beginning of the field, but with a regular expression more interesting.

We have seen here that the name is going from the namespace .NET
image

@Vovanella95
Copy link
Collaborator

@skiryuk not post processing. I can add this change to method, where we generating class name. Possible, it's easy to implement. Let me try to do this. I will let you know soon.

@skiryuk
Copy link
Author

skiryuk commented Mar 23, 2022

@skiryuk not post processing. I can add this change to method, where we generating class name. Possible, it's easy to implement. Let me try to do this. I will let you know soon.

Thank you, it would be very cool

@Vovanella95
Copy link
Collaborator

@skiryuk

you can do the next, to use this feature right now:

pubspec.yaml

swagger_dart_code_generator:
  git: 
    url: git@github.com:epam-cross-platform-lab/swagger-dart-code-generator.git
    ref: version/2.4.6

build.yaml

cutFromModelNames: "V3"

@skiryuk
Copy link
Author

skiryuk commented Mar 24, 2022

@skiryuk

you can do the next, to use this feature right now:

pubspec.yaml

swagger_dart_code_generator:
  git: 
    url: git@github.com:epam-cross-platform-lab/swagger-dart-code-generator.git
    ref: version/2.4.6

build.yaml

cutFromModelNames: "V3"

We tried it did not work, it does not replace the name, maybe we are doing something wrong?
for example
https://github.com/skiryuk/swagger-gen-example

run as fvm flutter packages pub run build_runner build --delete-conflicting-outputs

@Vovanella95
Copy link
Collaborator

@skiryuk Feel free to use latest version to test this feature. In case of issues or improve ideas - let us know.

@skiryuk
Copy link
Author

skiryuk commented Mar 25, 2022

As it turned out, the property is called cut_from_model_names and everything works with it, please add it to the documentation

@Vovanella95
Copy link
Collaborator

@skiryuk already did :)

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

Successfully merging a pull request may close this issue.

3 participants