square / retrofit

A type-safe HTTP client for Android and the JVM

Home Page:https://square.github.io/retrofit/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feature Request] Companion script to parse endpoint output -> codegen the necessary data classes

eddieberklee opened this issue · comments

Feature Request

Problem: Writing the classes is tedious. I want to avoid writing all of those "data class ResponseLines(..." especially for endpoints that are deeply nested with both maps and lists.

Solution: Write a companion script to take in a raw string example of an endpoint output. Script would then use Jackson to parse the string into a map. Script then iterates through the map to output the code for the data classes that I can then simply copy & paste into my project.

I'm currently writing this, it's definitely doable but a little complex so I'm posting this issue in the hopes that someone else has already written this or at least to chat with someone who has thought about this idea before.

So something like this is firmly outside the realm of what we want to support ourselves. Have you seen projects like https://www.jsonschema2pojo.org/? I think that's pretty close to what you are describing.

If you want to discuss solutions for this more I would suggest creating a discussion instead: https://github.com/square/retrofit/discussions