-
Notifications
You must be signed in to change notification settings - Fork 124
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
[feature] Ability to generate mutable models #247
[feature] Ability to generate mutable models #247
Conversation
Codecov Report
@@ Coverage Diff @@
## master #247 +/- ##
==========================================
- Coverage 77.23% 76.86% -0.37%
==========================================
Files 9 9
Lines 751 765 +14
==========================================
+ Hits 580 588 +8
- Misses 171 177 +6
Continue to review full report at Codecov.
|
Why do you need mutable models? Also using data models in UI is strongly not recommended. Better to have Domain models for that puprpuse. |
Yes I'm aware of Sure, not recommended for certain situations, quite useful for other situations. A codegen library can give you the option, it doesn't have to dictate. (The |
I actually found this project via this thread in the openapi-generator-dart project, and was inspired by this relevant feature request: gibahjoe/openapi-generator-dart#41 (comment)
|
Hi @rockgecko-development , It's very good idea to have mutable objects. Unfortunately it contradicts our main idea. Feel free to fork out library and modify it, but we're not going to support mutable models. |
What about the other 2 features in this PR? |
I needed the ability to generate mutable, non-final models, so I went ahead and added it.
Offering this PR if you'd like the option as well.
Usage:
new option
models_immutable
, default isfalse
. Whentrue
, thefinal
keyword is omitted from model properties.I also restored (#204 ) the functionality of the
use_path_for_request_names
option, because it wasn't working and I needed it. Default is nowtrue
. Whenfalse
, the swaggeroperationId
is used as the method name (but converted to lowerCamelCase). The path-generated method names looked particularly ugly for me, whereas in my C# Azure Function I have declared the operationId as the same as the Azure Function (& C# method) name, so this lines up perfectly for me. (I'm using this project in the backend: https://github.com/Azure/azure-functions-openapi-extension )I also added swagger method
description
fields as comments, in addition to the existingsummary
. Theazure-functions-openapi-extension
only seems to generatedescription
s.Finally, I added unit tests for the codegen output with
models_immutable
both true and false.