I have the following @RestController:
package io.github.paulmarcelinbejan.coandaairlines.reservationsystem.adapters.inbound.controller.rest;
import java.util.List;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.github.paulmarcelinbejan.coandaairlines.reservationsystem.adapters.inbound.impl.rest.CurrencyInboundAdapterRestImpl;
import io.github.paulmarcelinbejan.coandaairlines.reservationsystem.ports.currency.domain.CurrencyDTO;
import io.github.paulmarcelinbejan.davinci.adapters.api.DavinciApiResponse;
import lombok.RequiredArgsConstructor;
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/currency")
public class CurrencyRestController {
private final CurrencyInboundAdapterRestImpl currencyInboundAdapterRestImpl;
@GetMapping(value = "/id/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
public DavinciApiResponse<CurrencyDTO> findById(@PathVariable Integer id) {
return currencyInboundAdapterRestImpl.findById(id);
}
@GetMapping(value = "/code/{code}", produces = MediaType.APPLICATION_JSON_VALUE)
public DavinciApiResponse<CurrencyDTO> findByCode(@PathVariable String code) {
return currencyInboundAdapterRestImpl.findByCode(code);
}
@GetMapping(value = "/", produces = MediaType.APPLICATION_JSON_VALUE)
public DavinciApiResponse<List<CurrencyDTO>> findAll() {
return currencyInboundAdapterRestImpl.findAll();
}
}
but when I access Swagger, it doesn't show me the space to insert the pathVariable:
If I try to execute I have the following exception:
{
"status": "KO",
"errors": {
"timestampUTC": "2024-04-02T11:24:45.416132Z",
"exceptionType": "IllegalArgumentException",
"message": "Name for argument of type [java.lang.Integer] not specified, and parameter name information not available via reflection. Ensure that the compiler uses the '-parameters' flag."
}
}
same issue also from postman:
If I remove the @PathVariable then on swagger I can see it:
but still same error:
{
"status": "KO",
"errors": {
"timestampUTC": "2024-04-02T11:26:56.186060Z",
"exceptionType": "IllegalArgumentException",
"message": "Name for argument of type [java.lang.Integer] not specified, and parameter name information not available via reflection. Ensure that the compiler uses the '-parameters' flag."
}
}
On another project, I have similar @RestController:
package com.hyperbank.types.currency.controller;
import java.util.List;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.hyperbank.types.currency.dto.CurrencyResponse;
import com.hyperbank.types.currency.dto.CurrencySaveRequest;
import com.hyperbank.types.currency.dto.CurrencyUpdateRequest;
import com.hyperbank.types.currency.mapper.CurrencyMapper;
import com.hyperbank.types.currency.service.CurrencyService;
import io.github.paulmarcelinbejan.toolbox.exception.functional.FunctionalException;
import io.github.paulmarcelinbejan.toolbox.utils.validation.ValidatorUtils;
import io.github.paulmarcelinbejan.toolbox.web.response.OkResponse;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/currency")
public class CurrencyRestController {
private final CurrencyService currencyService;
private final CurrencyMapper currencyMapper;
@GetMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody CurrencyResponse findById(@PathVariable Integer id) throws FunctionalException {
return currencyMapper.toResponse(currencyService.findById(id));
}
@GetMapping(value = "/", produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody List<CurrencyResponse> findAll() {
return currencyMapper.toResponses(currencyService.findAll());
}
}
and on that one, there are no issue:
any idea ?




Ensure that the compiler uses the '-parameters' flag.if you want to infer the name or explicitly declare the name in the@PathVariablelike@PathVariable("id").-parameters(unless using the spring boot starter parent with maven then it is always on already). If you use Gradle you need to add it, and on earlier versions there was a fallback option with reflection which has been removed as it didn't work reliably in native images.