springdoc / springdoc-openapi-demos

Demo for OpenAPI 3 with spring-boot
http://springdoc.org
Apache License 2.0
493 stars 267 forks source link

A path parameter declaration inside of an operation leads to wrong api-doc #57

Closed dgiwerzew closed 1 year ago

dgiwerzew commented 1 year ago

Hi,

we use in our project spring boot 3.0.2 and springdoc-openapi (springdoc-openapi-starter-webmvc-ui) 2.0.2.

Since the springdoc-openapi 2.0.1 there is a following issue. This declaration

 @Operation(summary = "test update book",
            parameters = {
                    @Parameter(name = "id", description = "Id of a book", in = ParameterIn.PATH, example = "1" )
            }
    )
@PutMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public BookDto updateBook(
@PathVariable long id,
@RequestBody BookEditDto bookEditDto) {
return new BookDto();
}

Leads to this api-doc result:

"parameters":[
    {
        "name": "id",
        "in": "path",
        "description": "Id of a book",
        "required": true,
        "example": 1
    },
    {
        "name": "arg0",
        "in": "path",
        "required": true,
        "schema": {
            "type": "integer",
            "format": "int64"
        }
    }
]

If a @Parameter declaration will be moved to the method definition like this

@Operation( summary = "test update book  )
@PutMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public BookDto updateBook(
@Parameter(name = "id", description = "Id of a book", in = ParameterIn.PATH, example = "1" )
@PathVariable long id,
@RequestBody BookEditDto bookEditDto) {
return new BookDto();
}

Then the api-doc result is correct:

"parameters":[
    {
        "name": "id",
        "in": "path",
        "description": "Id of a book",
        "required": true,
        "schema": {
            "type": "integer",
            "format": "int64"
        },
        "example": 1
    }
]

The question is: why the @Parameter declaration inside of @Operationdoes not work properly anymore?

Thank you in advance!

Kind regards, Dimitri Giwerzew

dgiwerzew commented 1 year ago

sorry, it was the wrong repositoriry. I have created a new issue in the springdoc-openapi: https://github.com/springdoc/springdoc-openapi/issues/2081

Kind regards, Dimitri Giwerzew