-
Notifications
You must be signed in to change notification settings - Fork 57
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
Output is invalid #5
Comments
Hello @phackwer, thanks for this issue.
dependencies:
dio: ^4.0.0
json_annotation: ^4.7.0
retrofit: ^3.3.0
dev_dependencies:
build_runner: ^2.3.0
json_serializable: ^6.5.0
retrofit_generator: ^4.2.0
swagger_parser: ^0.3.0
flutter pub run build_runner build And for type |
Try to run step-by-step If this doesn't work try to restart dart analysis server. |
Can you show output what it gives out when generating build_runner code? |
Same result. :-( No generated file 'translation_controller.g.dart'. |
I had some errors in output, could they be causing the problem? [SEVERE] retrofit_generator:retrofit on lib/generated/clients/user_controller_api_client.dart (cached): This builder requires Dart inputs without syntax errors. Try fixing the errors and re-running the build. [SEVERE] retrofit_generator:retrofit on lib/generated/clients/translation_controller_api_client.dart (cached): Exception: toJson() method have to add to MultipartFile This builder requires Dart inputs without syntax errors. |
Show how your translation_controller.dart file looks like. |
Try to replace all |
We found some issues here related to oneOf, allOf lists of types for arrays. Regarding the MultipartFile problem is that this class was not generated (body it had body type string and format binary, so, we removed it from the open api definition and it stopped causing an error. This error with the List being created could be solved by simple making type "List" whenever oneOf or allOf (or anything like this) was presented. A better solution would be to create a bogus interface for the list "List" that would be implemented by the classes that are part of the lists. |
I've never met oneOf, I don't know if it's supported in Dart. If there was a complete example and a version, maybe something would have been done. And so I don't even have a clue how to fix it. |
I will try in my free time to look at |
Here is documentation about it: https://swagger.io/docs/specification/data-models/oneof-anyof-allof-not/ It basically allows you to define a property on complex class as array and say that items on that array can be one of, all of or any of certain types. Dart doesn't support it, this is why it would be better either to have those cases with no type, or create an empty interface forcing all classes to implement. Ex: ShoppingCart has property items, so, you would have
If items has anyOf SomeItem or SomeItem2, you would have
If items has oneOf, you would have
and so on. |
Also a tiny bug we found: type: object It should revert to Object on code generated. We had
and that caused errors too. |
It looks great, you can try to implement it in the next version
Can you throw off a piece of this json file with this field, perhaps there is also one of the moments unknown to the program? |
Take a look at this, it might come in handy: |
Already know it, thanks. :-) |
If you had shown a little lower, because there may be different variables in the
|
Without any properties? |
If you change object to Object will it work? |
JSON that generated this is close to this:
|
What version of swagger is used? |
Open API ^3.0 |
Hi,
The output we had with your code became a bit invalid.
It's missing a .g.dart file and also missing the a private class:
Also the dependencies are not totally clear, could you map them? The output however, seems quite nice.
The text was updated successfully, but these errors were encountered: