micronaut-openapi icon indicating copy to clipboard operation
micronaut-openapi copied to clipboard

micronaut openapi/swagger component cannot handle @Version

Open hittlle opened this issue 3 years ago • 1 comments

Expected Behavior

I created two endpoints, and enabled OpenAPI and swagger UI.

@ApiResponses(
        value = [
            ApiResponse(
                responseCode = "200", description = "v1",
                content = [
                    (
                            Content(
                                mediaType = "plain/text"
                            )
                            )
                ]
            ),
            ApiResponse(responseCode = "500", description = "Internal Server Error"),
        ]
    )
    @Version("1")
    @Get("/hello")
    fun helloV1(req: String): String {
        return "HelloV1"
    }

    @ApiResponses(
        value = [
            ApiResponse(
                responseCode = "200", description = "v2",
                content = [
                    (
                            Content(
                                mediaType = "application/json",
                                array = (ArraySchema(schema = Schema(implementation = Map::class)))
                            )
                            )
                ]
            ),
            ApiResponse(responseCode = "500", description = "Internal Server Error"),
        ]
    )
    @Version("2")
    @Get("hello")
    fun helloV2(req: Map): Map {
        return req;
    }

I hope to see two endpoints or one endpoint but different header X-API-VERSION values should go with different request structure and response payload

Actual Behaviour

Only one endpoint /hello with request parameter and response descriptions of @Version("1")

Steps To Reproduce

No response

Environment Information

No response

Example Application

No response

Version

3.4.2

hittlle avatar Aug 04 '22 03:08 hittlle

@hittlle Hi! I'm sorry, but I didn't understand what you are trying to do with your example. Not sure if this code can work, most likely you will get an error: More than 1 route matched the incoming request. The following routes matched /hello: GET - /hello, GET - /hello . To understand what the problem is, please create a full-fledged example that reproduces the problem

altro3 avatar Aug 07 '22 09:08 altro3

Fixed in micronaut-openapi 4.10.0

altro3 avatar Jul 02 '23 13:07 altro3