-1

We have requirement that the DTOs should be generated from an document where we can define the fieldName & fieldType that may be Json or Yaml. We are going to use these DTOs in Rest controller as request dto and response dto. So, Requirement is that we can define our request & response fields as per client requirements and configure it in some documents and that are automatically taken in code. How can I achieve this in Spring boot java?

Nilesh
  • 2,054
  • 3
  • 23
  • 43

1 Answers1

0

If you are bound to use only JSON format, you can try and use Avro. With it you can define the schema using JSON format and later generate Java code (& some other languages too) using Maven/Gradle plugins.

If using OpenAPI/Swagger specification you can use swagger-codegen to generate server stubs in Java.

If you are free to choose message format, you can also look in to other specifications like Thrift, Protocol Buffers.

Akhil Bojedla
  • 1,968
  • 12
  • 19