Best approach for api rest in java?

Hi everyone, I would need some advice on the architectural approach to use for the development of API rest in java. In particular, I noticed from the examples play-java-rest-api-example that a pattern consisting for each models/object managed of a lot of classes:

  • jpaRepository
  • Action
  • Controller
  • Data
  • ExecutionContext
  • Implementation of repository
  • Resource
  • HandlerResource
    This is a nice approach if are used few object, but for more object, with a lot of models to use is very expensive manage with this architectures.
    Does anyone know an approach, perhaps with some examples in which portability and maintenance are also favored?

You can use the OpenApi generator for play: openapi-generator/java-play-framework.md at master · OpenAPITools/openapi-generator · GitHub
That way you describe your REST API as a OpenApi specification and let the generator create the necessary play code. You then “only” need to implement the business logic behind the API.

1 Like