8000 @RepositoryRestResource -- ApiParam definition for the JPA methods always defines the @Param as "body" type parameter · Issue #1882 · springfox/springfox · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
@RepositoryRestResource -- ApiParam definition for the JPA methods always defines the @Param as "body" type parameter #1882
Closed
@aniruthmp

Description

@aniruthmp
  • swagger-ui version 2.7.0

I have used spring-data-rest. Sample code snippet below

@RepositoryRestResource
public interface ReservationRepository extends PagingAndSortingRepository<Reservation, Long> {
    @ApiOperation(
            value = "Find Reservation by LastName",
            notes = "Returns a record of Reservation",
            response = Reservation.class)
    @ApiResponses(value = {@ApiResponse(code = 404, message = "Invalid LastName")})
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "Bearer eyJhbGciOiJSUzI1NiI...",
                    required = true, dataType = "string", paramType = "header")})
    List<Reservation> findByLastNameIgnoreCase(
            @ApiParam(name = "ln", type = "query", value = "Last Name", required = true) @Param("ln") String name);
}

The generated swagger doc snippet at http://localhost:8080/v2/api-docs is as follows. As you can see below, the parameter has the value in: "body", while I expect in: "query"

{
    "/reservations/search/findByLastNameIgnoreCase": {
        "get": {
            "consumes": [
                "application/json"
            ],
            "description": "Returns a record of Reservation",
            "operationId": "findByLastNameIgnoreCaseReservationUsingGET",
            "parameters": [
                {
                    "in": "body",
                    "name": "ln",
                    "description": "Last Name",
                    "required": true,
                    "schema": {
                        "type": "string"
                    }
                },
                {
                    "name": "Authorization",
                    "in": "header",
                    "description": "Bearer eyJhbGciOiJSUzI1NiI...",
                    "required": true,
                    "type": "string"
                }
            ],
            "produces": [
                "*/*"
            ],
            "responses": {
                "200": {
                    "description": "OK",
                    "schema": {
                        "$ref": "#/definitions/Reservation"
                    }
                },
                "401": {
                    "description": "Unauthorized"
                },
                "403": {
                    "description": "Forbidden"
                },
                "404": {
                    "description": "Invalid LastName"
                }
            },
            "summary": "Find Reservation by LastName",
            "tags": [
                "Reservation Entity"
            ]
        }
    }
}

This is my dependency

<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger2</artifactId>
    <version>2.7.0</version>
</dependency>

And this points gets ApiParam.class from

<dependency>
   <groupId>io.swagger</groupId>
   <artifactId>swagger-annotations</artifactId>
   <version>1.5.13</version>
</dependency>
< 5279 div>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0