I am using the OpenAPI generator to generate the server side implementation for spring-boot starting from an OAI specification.
I noticed that with the configuration that I was using, the generator was not using the delegate pattern in the controller. For example, a controller looked like:
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.context.request.NativeWebRequest;
import java.util.Optional;
@Controller
@RequestMapping("${openapi.someresourceLibrary.base-path:/some-resource/v1}")
public class SomeResourcesApiController implements SomeResourcesApi {
private final NativeWebRequest request;
@org.springframework.beans.factory.annotation.Autowired
public SomeResourcesApiController(NativeWebRequest request) {
this.request = request;
}
@Override
public Optional<NativeWebRequest> getRequest() {
return Optional.ofNullable(request);
}
}
I know that I can, in my pom.xml file, set the configuration delegatePattern
to true
to enable the use of the delegate pattern.
I am wondering if someone knows why by default the tool is not using the delegate pattern that seems the most natural for this use case.
If I decide to use the default pattern, how am I supposed to provide my implementation? Should I extend the controller ?