OpenAPITools / OpenAPITools/openapi-generator
[BUG][java-vertx-web] operationId beginning with capital letter causes issues
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
If operationId is a string beginning with capital letter, like ListPets instead of listPets, then the generator creates code that mounts the operation with listPets instead of ListPets.
paths:
/pets:
get:
summary: List all pets
operationId: ListPets
tags:
- pets
This generates:
public void mount(RouterBuilder builder) {
builder.operation("createPets").handler(this::createPets);
builder.operation("listPets").handler(this::listPets);
builder.operation("showPetById").handler(this::showPetById);
}
This causes issues when we try to start the server:
$ mvn exec:java
[INFO] Scanning for projects...
[INFO]
[INFO] -----------< org.openapitools:openapi-java-vertx-web-server >-----------
[INFO] Building Swagger Petstore 1.0.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- exec-maven-plugin:1.5.0:java (default-cli) @ openapi-java-vertx-web-server ---
[vert.x-eventloop-thread-1] ERROR com.petstore.HttpServerVerticle - Http verticle failed to deploy
java.lang.IllegalArgumentException: Cannot find the operation createPets
at io.vertx.ext.web.openapi.impl.OpenAPI3RouterBuilderImpl.operation(OpenAPI3RouterBuilderImpl.java:178)
at com.petstore.verticle.PetsApiHandler.mount(PetsApiHandler.java:37)
at com.petstore.HttpServerVerticle.lambda$start$0(HttpServerVerticle.java:33)
at io.vertx.core.impl.future.Mapping.onSuccess(Mapping.java:35)
at io.vertx.core.impl.future.FutureBase.emitSuccess(FutureBase.java:60)
at io.vertx.core.impl.future.FutureImpl.tryComplete(FutureImpl.java:211)
at io.vertx.core.impl.future.PromiseImpl.tryComplete(PromiseImpl.java:23)
at io.vertx.core.Promise.complete(Promise.java:66)
at io.vertx.ext.web.openapi.RouterBuilder.lambda$create$0(RouterBuilder.java:239)
at io.vertx.core.impl.future.FutureImpl$3.onSuccess(FutureImpl.java:141)
at io.vertx.core.impl.future.FutureBase.emitSuccess(FutureBase.java:60)
at io.vertx.core.impl.future.FutureImpl.tryComplete(FutureImpl.java:211)
at io.vertx.core.impl.future.Composition$1.onSuccess(Composition.java:62)
at io.vertx.core.impl.future.FutureBase.emitSuccess(FutureBase.java:60)
at io.vertx.core.impl.future.FutureImpl.addListener(FutureImpl.java:196)
at io.vertx.core.impl.future.Composition.onSuccess(Composition.java:43)
at io.vertx.core.impl.future.FutureBase.emitSuccess(FutureBase.java:60)
at io.vertx.core.impl.future.FutureImpl.tryComplete(FutureImpl.java:211)
at io.vertx.core.impl.future.Composition$1.onSuccess(Composition.java:62)
at io.vertx.core.impl.future.FutureBase.emitSuccess(FutureBase.java:60)
at io.vertx.core.impl.future.FutureImpl.addListener(FutureImpl.java:196)
at io.vertx.core.impl.future.Composition.onSuccess(Composition.java:43)
at io.vertx.core.impl.future.FutureImpl$ListenerArray.onSuccess(FutureImpl.java:262)
at io.vertx.core.impl.future.FutureBase.emitSuccess(FutureBase.java:60)
at io.vertx.core.impl.future.FutureImpl.tryComplete(FutureImpl.java:211)
at io.vertx.core.impl.future.Composition$1.onSuccess(Composition.java:62)
at io.vertx.core.impl.future.FutureBase.emitSuccess(FutureBase.java:60)
at io.vertx.core.impl.future.SucceededFuture.addListener(SucceededFuture.java:88)
at io.vertx.core.impl.future.Composition.onSuccess(Composition.java:43)
at io.vertx.core.impl.future.FutureBase.lambda$emitSuccess$0(FutureBase.java:54)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:469)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:503)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:748)
To fix this, we need to manually change the above java code to correct the operationId as follows:
public void mount(RouterBuilder builder) {
builder.operation("CreatePets").handler(this::createPets);
builder.operation("ListPets").handler(this::listPets);
builder.operation("ShowPetById").handler(this::showPetById);
}
openapi-generator version
5.1.1 to 6.0.1
OpenAPI declaration file content or url
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 the java-vertx-web generator output, especially the generated PetsApiHandler.mount method shown in the report, and reproduce it with the supplied petstore.yaml and generation command. Verify that operationId values such as ListPets remain capitalized in builder.operation calls and that the generated server starts without the reported operation lookup error.
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
- Clearly specified
- Newbie friendliness
- 50/100