swagger-api / swagger-api/swagger-codegen

[JAVA] jaxrs-spec: Remove throws Exception from generated interfaces

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

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

Issue#6659 introduced a horrible design bug by declaring "throws Exception" in the generated api model for jaxrs-spec interfaces. For instance

String foo() throws Exception;

instead of just

String foo();

Forcing users of this api to always catch Exception or declare it, even though proper code never will throw an Exception. The "throws Exception" should never be there.

Swagger-codegen version

2.3.0, 2.3.1

Swagger declaration file content or url

The file involved is:

  • JavaJaxRS/spec/apiInterface.mustache
Suggest a fix/enhancement

Remove "throws Exception"

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 with JavaJaxRS/spec/apiInterface.mustache, the file identified in the issue, and inspect how the generated interface method declaration includes the exception clause. Generate a jaxrs-spec interface using the affected Swagger Codegen version and verify that the resulting methods no longer declare throws Exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.