swagger-api / swagger-api/swagger-codegen

Support interface and implementation classes for API controllers

Open
#5,431 7 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature Feature List: API servers help wanted Server: C-Sharp Server: Ceylon Server: Erlang Server: Go Server: Haskell Server: Java Server: Nodejs Server: Perl Server: PHP Server: Python Server: Ruby Server: Scala Server: Spring
Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the referenced JavaSpring templates, api.mustache and apiController.mustache, to understand how interface and implementation files are separated. Then identify which server generator should be addressed first and inspect its corresponding templates and tests. Done means that generator emits both files while preserving implementation code across regeneration; this issue names no target generator or test.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
api, backend, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.