OpenAPITools / OpenAPITools/openapi-generator
[BUG][JAVA][jaxrs-spec] Path Parameter is in Class "Path" Annotation --> Response is 404
Nobody has claimed this yet.
- 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 output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Generated Class has a Path Parameter in Class @Path("/profile/{userId}"). REST-Call Response is 404.
openapi-generator version
6.0.1
OpenAPI declaration file content or url
openapi: 3.0.3
info:
version: 1.0.0
title: Test Resource
description: Diese TEST API
servers:
- url: /
paths:
/profile/{userId}/email:
get:
operationId: getEmail
tags:
- Email
parameters:
- name: userId
in: path
description: The userId.
required: true
schema:
type: string
responses:
200:
description: The Email
content:
text/plain:
schema:
type: string
/profile/{userId}/mobilenr:
get:
operationId: getMobileNr
tags:
- MobileNr
parameters:
- name: userId
in: path
description: The userId.
required: true
schema:
type: string
responses:
200:
description: The MobileNr
content:
text/plain:
schema:
type: string
/profile/{userId}/username:
get:
operationId: getUsername
tags:
- Username
parameters:
- name: userId
in: path
description: The userId.
required: true
schema:
type: string
responses:
200:
description: The Username
content:
text/plain:
schema:
type: string
Generation Details
Java
Steps to reproduce
Example
Generate Class with
test/{pathParameter}/foo
test/{pathParameter}/bar
Related issues/PRs
Suggest a fix
Here are the CodeLines from Class AbstractJavaJAXRSServerCodegen. The Common Path is on the class Annotation.
private static String getCommonPath(String path1, String path2) {
final String[] parts1 = StringUtils.split(path1, "/");
final String[] parts2 = StringUtils.split(path2, "/");
StringBuilder builder = new StringBuilder();
for (int i = 0; i < Math.min(parts1.length, parts2.length); i++) {
if (!parts1[i].equals(parts2[i])) {
break;
}
builder.append("/").append(parts1[i]);
}
return builder.toString();
}
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
Start with AbstractJavaJAXRSServerCodegen and its getCommonPath method, then generate the Java JAX-RS server from the provided OpenAPI declaration. Inspect how the shared @Path("/profile/{userId}") class annotation combines with the generated operation paths. Done means the generated endpoints containing the path parameter resolve successfully instead of returning 404.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100