Skip to content

Support interface and implementation classes for API controllers #5431

@wing328

Description

@wing328
Description

For auto-generated server code, we want to generated 2 files for each API controller file:

  1. an interface, which will be overwritten by code generation
  2. an implementation class, which will not be overwritten by code generation

Java Spring has already implemented this:
https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/main/resources/JavaSpring/api.mustache
https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/main/resources/JavaSpring/apiController.mustache

The goal is to avoid application/business logic being overwritten by code generation so that there's less overhead when adding/deleting/updating endpoint definition.

Other server generators should leverage similar design.

Swagger-codegen version

Latest master

Suggest a Fix

If anyone has suggestions for better design or want to work on this enhancement for a particular server generator, please reply to let us know. Thank you.

Metadata

Metadata