Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 7, 2025

Implements Parser.DartMappable to support dart_mappable as an alternative to json_serializable for type conversion, addressing the feature request in the issue.

Changes

Core (retrofit/lib/http.dart)

  • Added Parser.DartMappable enum value

Generator (generator/lib/src/generator.dart)

  • Deserialization: uses <ClassName>Mapper.fromMap(data)
  • Serialization: uses object.toMap()
  • Handles single objects, lists, maps, nullable types, and extension types

Documentation & Example

  • Added usage section to README with setup instructions
  • Created example_dartmappable/ with working example

Usage

@RestApi(
  baseUrl: 'https://api.example.com',
  parser: Parser.DartMappable,
)
abstract class ApiService {
  factory ApiService(Dio dio) = _ApiService;

  @GET('/tasks')
  Future<List<Task>> getTasks();
}

@MappableClass()
class Task with TaskMappable {
  const Task({this.id, this.name});
  final String? id;
  final String? name;
}

Generated code uses TaskMapper.fromMap() for responses and task.toMap() for request bodies.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • dl-ssl.google.com
    • Triggering command: wget -qO- REDACTED (dns block)
  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https (dns block)
  • https://storage.googleapis.com/download.dartlang.org/linux/debian/dists/stable/InRelease
    • Triggering command: /usr/lib/apt/methods/https (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>dart_mappable for type conversion</issue_title>
<issue_description>Can I use dart_mappable for type conversion?</issue_description>

<agent_instructions>dart_mappable support</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@trevorwang Not yet.

PRs are appreciated. </comment_new>


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI self-assigned this Nov 7, 2025
Copilot AI and others added 4 commits November 7, 2025 06:15
Co-authored-by: trevorwang <121966+trevorwang@users.noreply.github.com>
Co-authored-by: trevorwang <121966+trevorwang@users.noreply.github.com>
Co-authored-by: trevorwang <121966+trevorwang@users.noreply.github.com>
Co-authored-by: trevorwang <121966+trevorwang@users.noreply.github.com>
Copilot AI changed the title [WIP] Add dart_mappable support for type conversion Add dart_mappable parser support for type conversion Nov 7, 2025
Copilot AI requested a review from trevorwang November 7, 2025 06:24
Copilot finished work on behalf of trevorwang November 7, 2025 06:24
@trevorwang trevorwang marked this pull request as ready for review November 7, 2025 09:35
@trevorwang trevorwang merged commit 3fab74d into master Nov 20, 2025
6 checks passed
@trevorwang trevorwang deleted the copilot/add-dart-mappable-support branch November 20, 2025 01:27
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.

dart_mappable for type conversion

2 participants