jsonschema2pojo icon indicating copy to clipboard operation
jsonschema2pojo copied to clipboard

Feature - Support for Java17 record syntax

Open maximus321 opened this issue 2 years ago • 6 comments

It would be nice if the GenerationConfig could support the output as "Record" instead of old school Pojo

public record DataRecord(List<String> types, String test) { }

Thanks for the project!

maximus321 avatar May 13 '22 15:05 maximus321

There are several things that would have to be solved first:

  1. migrating code & build pipeline to Java 17, so that tests requiring compilation of generated code would work
  2. fork/extend/replace codemodel to support(ing) records

It would have to be noted that there will be limitations due to "nature" of records eg.:

  • https://github.com/joelittlejohn/jsonschema2pojo/wiki/Reference#extends
  • enum's defined within record
  • ...

unkish avatar Nov 26 '22 19:11 unkish

This would be an awesome addition! Another solution would be to generate interfaces using immutables.org library.

KangoV avatar Dec 28 '22 16:12 KangoV

Any plans to support this ?

akil-rails avatar Sep 27 '23 07:09 akil-rails

Is there a code generator that supports this syntax that anyone knows about? I agree this would be an excellent feature.

joelittlejohn avatar Sep 27 '23 07:09 joelittlejohn

Looking for this also - but already making gains with your project, so thank you :)

apbleonard1971 avatar Oct 19 '23 09:10 apbleonard1971

Java 21 has increased the the applications of records and would make this feature even better

Jaruso avatar Dec 01 '23 18:12 Jaruso