Skip to content

Conversation

@zbarbuto
Copy link

Added some test projects and fixed some issues in generation related to null safety:

  • Classes are a bit more careful about when to use ? in conjunction with required in the constructor
  • There was an incorrect path to enum template which has been fixed
  • Enums were generating without names (I used classname as a fallback which some of the other templates had done)
  • Binary files were required but JSONSerializable wasn't happy with that so I've just made binaries always optional as a stopgap solution

I've generated a json_serializable project in dart-dio-next samples and copied the tests project as well. There are a couple of test failures in the latter project but I'm unsure if they are relevant or false positives as the test project was copied as a combination of both the old Dart2+JsonSerializable and the Dart-Dio+BuiltValue test cases.

I'm also not very good with Java so not 100% sure how to setup the .pom files for automatic testing.

@zbarbuto
Copy link
Author

zbarbuto commented Aug 12, 2021

FTR current test failures in petstore_json_serializable_client_lib_fake_tests are potentially actual issues with the generated code:

  • The type used for targetType in deserialize in one of the samples has leading whitespace which causes it to throw 'Cannot deserialize' - this could be fixed by trimming but seems hacky?
  • Deserialize is failing on some of the maps: type '_InternalLinkedHashMap<dynamic, int>' is not a subtype of type 'Map<String, int>' in type cast
  • The date formatter test is throwing an error but I don't think that test is required as this isn't using a custom date serializer like built_value was
  • posting files be attaching the file (the try block is empty?) - it seems to be related to multipart/formdata type parameters?:
    image

@zbarbuto
Copy link
Author

Have fixed the form data issues and deleted that superfluous date test.

Thee remaining test failures I'm stuck if you maybe want to checkout for yourself and run (pub get and build_runner in samples/openapi3/client/petstore/dart-dio-next/petstore_json_serializable_client_lib_fake and then pub get and flutter test in petstore_json_serializable_client_lib_fake_tests):

  • The map issue mentioned above which can be solved by: value.keys.map((key) => key as String), in deserializer.dart but that seems a bit hacky?
  • A couple of mismatched requests

@zbarbuto
Copy link
Author

Closing as too stale - will PR my minor fixups separately

@zbarbuto zbarbuto closed this Oct 26, 2021
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

Successfully merging this pull request may close these issues.

1 participant