OpenAPITools / OpenAPITools/openapi-generator

[Java][jaxrs 2.1/resteasy] compilation error because of @PATCH

Open
#2,018 10 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug Server: Java
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)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

By default, @PATCH annotation is resolved to package io.swagger.jaxrs.* .
PATCH annotation was not part of jaxrs 2.0 specifications ( https://jax-rs.github.io/apidocs/2.1/ ) but it is now part of jaxrs 2.1 specifications (https://jax-rs.github.io/apidocs/2.1/).

Compilation with jaxrs 2.1 leads to a compilation failure because of imports with wild cards for both packages io.swagger.jaxrs.* and javax.ws.rs.* .

openapi-generator version

3.3.3

OpenAPI declaration file content or url
Command line used for generation
Steps to reproduce

The issue occurs when we upgrade our thorntail dependency from 2.2.0 (2.2.0) to 2.3.0 (jarxrs 2.1).

Related issues/PRs
Suggest a fix

The suggested fix is to replace @PATCH in the generated source code by @io.swagger.jaxrs.PATCH.
By the way, the generated source will compile for any jaxrs version.

As a work around, we use the com.google.code.maven-replacer-plugin:replacer maven plugin in order to update the generated source code on the fly. Of course we have to apply it everywhere @PATCH is generated.

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 locating the Java JAX-RS generator templates or import-generation entry points that emit @PATCH, then reproduce generation with JAX-RS 2.1 as described. Done means the generated source uses an unambiguous PATCH annotation and compiles without conflicting wildcard imports.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.