Skip to content

Spec for @ParameterObject disappears if building native-images #2312

Closed
@mykhailokulakov

Description

@mykhailokulakov

Describe the bug

Hey
I'm using spring-boot 3.1.1 and springdoc-openapi 2.1.0
When annotating the Pageable interface with @ParameterObject, everything works smoothly for a traditional build, with parameters being generated as expected:

"parameters": [
  {
	"name": "productId",
	...
  },
  {
	"name": "userId",
	...
  },
  {
	"name": "page",
	"in": "query",
	"description": "Zero-based page index (0..N)",
	"required": false,
	"schema": {
	  "minimum": 0,
	  "type": "integer",
	  "default": 0
	}
  },
  {
	"name": "size",
	"in": "query",
	"description": "The size of the page to be returned",
	"required": false,
	"schema": {
	  "minimum": 1,
	  "type": "integer",
	  "default": 20
	}
  },
  {
	"name": "sort",
	"in": "query",
	"description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.",
	"required": false,
	"schema": {
	  "type": "array",
	  "items": {
		"type": "string"
	  }
	}
  }
],

But if running a native image, this part is missing from the generated spec:

"parameters": [
  {
    "name": "productId",
    ...
  },
  {
    "name": "userId",
    ...
  }
],

To Reproduce

spring-boot-starter-parent 3.1.1
springdoc-openapi-starter-webmvc-ui 2.1.0

@RestController
@RequestMapping("/tickets")
@RequiredArgsConstructor
@FieldDefaults(level = AccessLevel.PRIVATE, makeFinal = true)
@Tag(name = "Tickets API")
public class TicketController  {
    TicketService service;

    @GetMapping
    @Operation(summary = "Search tickets")
    @PageableAsQueryParam
    ResponsePage<Ticket> search(
            @RequestParam(value = "productId", required = false) UUID productId,
            @RequestParam(value = "userId", required = false) UUID userId,
            @Parameter(hidden = true) Pageable page) {
        return service.search(productId, userId, page);
    }
}

mvn -Pnative spring-boot:build-image

Expected behavior

It should work on a native-image

Screenshots

regular build:

Screenshot 2023-07-18 002054

native:
Screenshot 2023-07-18 004252

Additional context
I've tried to add ParameterObject in reflection and serialization configs but no luck

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions