You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have detected an issue related to the openapi-generator client and the spring-web 6 Observation API introduced in spring-boot 3.
The problem is that the generated ApiClient class, in the invokeAPI method when creating the BodyBuilder with the RequestEntity.method(method, uri) method, without params overloading, so that the uriTemplate field of the BodyBuilder object is always null.
On the other hand, the spring-web 6 Observation API gets the keyValue URI, with which the uri TAG of the http_client_requests metric is given value, for the uriTemplate value of the response. As the uriTemplate is null, the uri TAG always has the value NONE.
Modifying the original ApiClient.mustache template so that the requestBuilder is created based on the URI passing the arguments to resolve with the method:
final BodyBuilder requestBuilder requestBuilder = RequestEntity.method(method, UriComponentsBuilder.fromHttpUrl(basePath).toUriString() + finalUri, uriParams);
with this method if the TemplateURI fields are set and therefore from the Observation API if it is able to retrieve it and add it with TAG to the http.client.request metrics.
Currently the ApiClient generated with openapi-generator always uses the method:
final BodyBuilder requestBuilder requestBuilder = RequestEntity.method(method, uri);
where uri is the URL already resolved with the arguments and the request will never report the TemplateUri field.
Steps to reproduce
I have left a demo here where you can reproduce it with the following steps:
As can be seen, the generated http_client_requests metrics always have the tag uri="none", when they should have the request path: /pet2/{petId}.
HELP http_client_client_requests_seconds
# TYPE http_client_requests_seconds summary
http_client_requests_seconds_count{client_name="localhost",error="none",exception="none",method="GET",outcome="SUCCESS",status="200",uri="none",} 1.0
http_client_requests_seconds_sum{client_name="localhost",error="none",exception="none",method="GET",outcome="SUCCESS",status="200",uri="none",} 0.139118975
# HELP http_client_requests_seconds_max
# TYPE http_client_requests_seconds_max gauge
http_client_requests_seconds_max{client_name="localhost",error="none",exception="none",method="GET",outcome="SUCCESS",status="200",uri="none",} 0.139118975
This change makes the v6.6.0 incompatible with Spring 5.x. What's the recommendation if a Spring upgrade isn't viable — fall back to a previous version of the generator or use a custom template? Are there any other options?
Description
We have detected an issue related to the openapi-generator client and the spring-web 6 Observation API introduced in spring-boot 3.
The problem is that the generated
ApiClient
class, in theinvokeAPI
method when creating theBodyBuilder
with theRequestEntity.method(method, uri)
method, without params overloading, so that theuriTemplate
field of the BodyBuilder object is always null.On the other hand, the spring-web 6 Observation API gets the keyValue URI, with which the
uri
TAG of thehttp_client_requests
metric is given value, for theuriTemplate
value of the response. As theuriTemplate
is null, theuri
TAG always has the valueNONE
.openapi-generator version
OpenAPI declaration file content or url
Generation Details
Modifying the original ApiClient.mustache template so that the requestBuilder is created based on the URI passing the arguments to resolve with the method:
with this method if the TemplateURI fields are set and therefore from the Observation API if it is able to retrieve it and add it with TAG to the
http.client.request
metrics.Currently the ApiClient generated with openapi-generator always uses the method:
where uri is the URL already resolved with the arguments and the request will never report the TemplateUri field.
Steps to reproduce
I have left a demo here where you can reproduce it with the following steps:
As can be seen, the generated
http_client_requests
metrics always have the taguri="none"
, when they should have the request path:/pet2/{petId}
.Related issues/PRs
Suggest a fix
Modify the original ApiClient.mustache template with:
instead:
The text was updated successfully, but these errors were encountered: