-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
Fix dart2 custom templates #3656
Fix dart2 custom templates #3656
Conversation
just pushed another commit which finally fixes parsing json to dart enums. I've also fixed parsing a map property with a list as value since the complexType is List and List.mapFromJson doesn't exist. I've added a mapListFromJson to each model class which is used when the complexType is a List. |
c8b7299
to
32edf79
Compare
just fixed your discussions :) |
Can you please resolve the merge conflicts when you've time as I just merged another Dart PR into master? |
* fix decoding a map with a list of some objects as value since the complexType is a List and List.mapFromJson doesn't exist.
* fix file permissions
32edf79
to
fb80a56
Compare
rebased |
// check to not overwrite a custom templateDir | ||
if (templateDir == null) { | ||
embeddedTemplateDir = templateDir = "dart2"; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this may be causing issues. I ran ./bin/dart2-petstore.sh
and got the following diff (partial):
--- a/samples/client/petstore/dart2/flutter_petstore/openapi/.travis.yml
+++ b/samples/client/petstore/dart2/flutter_petstore/openapi/.travis.yml
@@ -3,7 +3,7 @@
language: dart
dart:
# Install a specific stable release
-- "2.2.0"
+- "1.24.3"
install:
- pub get
diff --git a/samples/client/petstore/dart2/flutter_petstore/openapi/README.md b/samples/client/petstore/dart2/flutter_petstore/openapi/README.md
index e78e0e3e69..8520a219f8 100644
--- a/samples/client/petstore/dart2/flutter_petstore/openapi/README.md
+++ b/samples/client/petstore/dart2/flutter_petstore/openapi/README.md
@@ -44,10 +44,10 @@ Please follow the [installation procedure](#installation--usage) and then run th
import 'package:openapi/api.dart';
// TODO Configure OAuth2 access token for authorization: petstore_auth
-//defaultApiClient.getAuthentication<OAuth>('petstore_auth').accessToken = 'YOUR_ACCESS_TOKEN';
+//openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN';
-var api_instance = PetApi();
-var body = Pet(); // Pet | Pet object that needs to be added to the store
+var api_instance = new PetApi();
+var body = new Pet(); // Pet | Pet object that needs to be added to the store
try {
so dart 2 seems to be using dart 1.x template instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and undo these changes (line 205 to 208) seem to have fixed the issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest you remove these changes so that we can merge the remaining changes into master to give us more time reviewing this particular issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I know what the problem is and will file another PR to fix it after merging your PR
@alexnavratil thanks for the PR, which has been included in the v4.1.2 release: https://twitter.com/oas_generator/status/1172068944355528705 |
PR checklist
./bin/
to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.sh
,./bin/openapi3/{LANG}-petstore.sh
if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in.\bin\windows\
. If contributing template-only or documentation-only changes which will change sample output, be sure to build the project first.master
,4.1.x
,5.0.x
. Default:master
.@ircecho (2017/07) @swipesight (2018/09) @jaumard (2018/09)
Description of the PR
setting a custom template directory using the dart client generator didn't work for dart 2.x since the templateDir gets overwritten by "dart2". Since the dart2 templates were outdated and still based on dartson (which isn't defined as dependency and also not working anymore), I've decided to fix them too (copied and fixed formatting from #3048).
fixes #3655
UPDATE: also fixes #2830