swagger-api / swagger-api/swagger-codegen
[JAVA] Feature request: Introduce API client interface
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
At the moment Swagger generates concrete implementation of ApiClient which is then passed to my actual API client. It would be beneficial to introduce ApiClientInterface that the custom client then accepts, which would allow the developer to write integration tests against Mock APIs.
At the moment, the only option is to generate stub server with dummy data and change the endpoint when doing integration tests.
Suggest a fix/enhancement
public class ApiClient implements ApiInterface {
/** same as now **/
}
public class DefaultApi {
private ApiInterface apiClient;
public DefaultApi(ApiInterface apiClient) {
this.apiClient = apiClient;
}
/** same as now **/
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No files or tests are named. Start by locating the Java generator entry points and the templates that produce ApiClient and DefaultApi, then check how generated clients are wired together. Done means generated Java clients can accept an API client interface so integration tests can substitute mock APIs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, backend-api-design
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100