OpenAPITools / OpenAPITools/openapi-generator

[BUG][JAVA][MICROPROFILE] useRuntimeException is ignored

Open
#14,409 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Bug Report Checklist
  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected
    Actual: The generated API throws an org.openapitools.client.api.ApiException (which extends Exception)
    Expected: org.openapitools.client.ApiException (which extends RuntimeException)
Description

When using the java generator with the microprofile library, the useRuntimeException flag is ignored.

openapi-generator version

openapi-generator-cli-7.0.0-20221012.083708-4.jar

OpenAPI declaration file content or url

sample yaml

Generation Details

java -jar openapi-generator-cli-7.0.0-20221012.083708-4.jar generate -g java -i https://raw.githubusercontent.com/ssaip/openapi-generator-java-useRuntimeException/main/src/main/openapi/example.yaml -o C:\temp\ --additional-properties=useRuntimeException=true --library=microprofile

Steps to reproduce

Use the java generator with the microprofile library

Related issues/PRs
Suggest a fix

Either do throw a RuntimeException as configured or (even preferable in my use-case) give the option do NOT generate ApiException, ApiExceptionMapper, @RegisterProvider(ApiExceptionMapper.class) altogether.

If this is not desired for microprofile clients, this information should be added to the documentation.

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 the Java generator's microprofile library using the provided sample YAML and generation command. Compare the generated api.ApiException with the expected root-package ApiException and verify whether useRuntimeException=true affects the generated exception behavior and related artifacts. No repository file or test is named, so done means reproducing the issue and adding coverage for the corrected output.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.