OpenAPITools / OpenAPITools/openapi-generator
[BUG] [Quarkus] [jaxrs-spec] useSwaggerAnnotations=false is being ignored
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 interfaces are ignoring useSwaggerAnnotations=false flag and is generating swagger annotations
openapi-generator version
7.7.0
OpenAPI declaration file content or url
openapi: "3.0.3"
info:
version: 1.0.0
title: Swagger Petstore
paths:
/pets:
get:
responses:
'200':
description: pet response
content:
text/plain:
schema:
type: string
Generation Details
generatorName: jaxrs-spec
outputDir: samples/server/petstore/jaxrs-spec
inputSpec: modules/openapi-generator/src/test/resources/3_0/jaxrs-spec/petstore-with-fake-endpoints-models-for-testing.yaml
templateDir: modules/openapi-generator/src/main/resources/JavaJaxRS/spec
additionalProperties:
library: quarkus
useSwaggerAnnotations: "false"
useMicroProfileOpenAPIAnnotations: "true"
NOTE: The important part is just this: useSwaggerAnnotations: "false"
Steps to reproduce
Run the generator.
You'll see that swagger annotations come through:
@org.eclipse.microprofile.openapi.annotations.OpenAPIDefinition(
info = @org.eclipse.microprofile.openapi.annotations.info.Info(
title = "", version="1.0.0", description=""
),
tags = @org.eclipse.microprofile.openapi.annotations.tags.Tag(name="", description="")
)
@Api(description = "the Default API")
@Path("/pets")
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJAXRSSpecServerCodegen", date = "2024-07-31T15:06:31.576161600-07:00[America/Vancouver]", comments = "Generator version: 7.7.0")
public interface DefaultApi {
@GET
@Produces({ "text/plain" })
@ApiOperation(value = "", notes = "", tags={ })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "pet response", response = String.class) })
@org.eclipse.microprofile.openapi.annotations.Operation(operationId = "petsGet", summary = "", description = "")
@org.eclipse.microprofile.openapi.annotations.responses.APIResponses(value = {
@org.eclipse.microprofile.openapi.annotations.responses.APIResponse(responseCode = "200", description = "pet response", content = {
@org.eclipse.microprofile.openapi.annotations.media.Content(mediaType = "text/plain", schema = @org.eclipse.microprofile.openapi.annotations.media.Schema(implementation = String.class))
})
})
Response petsGet();
}
If you run the same thing with a 7.6.0 generator, the swagger annotations are left out as expected:
@org.eclipse.microprofile.openapi.annotations.OpenAPIDefinition(
info = @org.eclipse.microprofile.openapi.annotations.info.Info(
title = "", version="1.0.0", description=""
),
tags = @org.eclipse.microprofile.openapi.annotations.tags.Tag(name="", description="")
)
@Path("/pets")
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJAXRSSpecServerCodegen", date = "2024-07-31T14:47:37.926229900-07:00[America/Vancouver]", comments = "Generator version: 7.6.0")
public interface DefaultApi {
@GET
@Produces({ "text/plain" })
@org.eclipse.microprofile.openapi.annotations.Operation(operationId = "petsGet", summary = "", description = "")
@org.eclipse.microprofile.openapi.annotations.responses.APIResponses(value = {
@org.eclipse.microprofile.openapi.annotations.responses.APIResponse(responseCode = "200", description = "pet response", content = {
@org.eclipse.microprofile.openapi.annotations.media.Content(mediaType = "text/plain", schema = @org.eclipse.microprofile.openapi.annotations.media.Schema(implementation = String.class))
})
})
Response petsGet();
}
Related issues/PRs
Suggest a fix
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 by reproducing the jaxrs-spec generation described in the issue with library=quarkus and useSwaggerAnnotations=false, then inspect templates under modules/openapi-generator/src/main/resources/JavaJaxRS/spec. Compare the generated interface with the 7.6.0 and 7.7.0 examples. Done means the flag again prevents Swagger annotations while MicroProfile OpenAPI annotations remain.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100