micronaut-projects / micronaut-projects/micronaut-openapi
DuplicateRouteException thrown from Micronaut OpenAPI-generated server
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 114
- Forks
- 121
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 25
Description
### Expected Behavior
My service should return success responses on all endpoints
### Actual Behaviour
```
$ curl localhost:8080/pets | jq .
{
"_links": {
"self": [
{
"href": "/pets",
"templated": false
}
]
},
"_embedded": {
"errors": [
{
"message": "More than 1 route matched the incoming request. The following routes matched /pets: GET - /pets, GET - /pets"
}
]
},
"message": "Bad Request"
}
```
Note: I also added a "hello world" endpoint that is not generated from the OpenAPI spec and the service responds successfully to requests on that endpoint
```
$ curl localhost:8080/
Hello World%
```
### Steps To Reproduce
1. Follow [this official guide](https://guides.micronaut.io/latest/micronaut-openapi-generator-server.html) to generate micronaut java server code from an openapi spec
2. Implement the `PetsApi` interface with stubbed success responses using Kotlin
3. `./gradlew run`
4. `$ curl localhost:8080/pets`
5. Observe the error message for duplicate routes
The output of (1) and (2) is linked as an example application
### Environment Information
Operating System: OSX Version 13.2.1 (22D68)
JDK Version
```
$ javac --version
javac 17.0.4.1
```
JRE Version
```
$ java --version
openjdk 17.0.4.1 2022-08-12
OpenJDK Runtime Environment Temurin-17.0.4.1+1 (build 17.0.4.1+1)
OpenJDK 64-Bit Server VM Temurin-17.0.4.1+1 (build 17.0.4.1+1, mixed mode)
```
### Example Application
https://github.com/lyonssp/petstore-service
### Version
4.0.2
Contributor guide
No contributing guide indexed for this repository
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 linked petstore-service example and the generated PetsApi implementation described in the reproduction, then trace how the OpenAPI server generator registers the GET /pets route. Reproduce the request with ./gradlew run and curl; done means the generated endpoint has only one matching route and returns its success response.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, kotlin, openapi
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100