openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

[BUG][GO][Client] Generated GO Client Looses Millisecond Resolution With Time URL Query Params

Open gonzogomez opened this issue 1 year ago • 0 comments

Description

Generated Go Client code will use t.Format(time.RFC3339) in the function parameterAddToHeaderOrQuery. This call will cause the time object to loose millisecond resolution when adding the query param to the request.

Time object that has the following timestamp 2024-05-14 02:43:39.7551 will be converted to 2024-05-14T02:43:39Z instead of 2024-05-14T02:43:39.7551Z

openapi-generator version

7.5.0

OpenAPI declaration file content or url

https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml

Command line used for generation

./run-in-docker.sh generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g go -o /gen/out/go-petstore -p packageName=petstore

Steps to reproduce

Generate the go code with petstore.yaml ./run-in-docker.sh generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g go -o /gen/out/go-petstore -p packageName=petstore

Suggest a fix

In file modules/openapi-generator/src/main/resources/go/client.mustache function parameterAddToHeaderOrQuery.

parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, t.Format(time.RFC3339Nano), collectionType)

Using t.Format(time.RFC3339Nano) instead of t.Format(time.RFC3339) will keep the millisecond resolution.

Pull Request: https://github.com/OpenAPITools/openapi-generator/pull/18673

gonzogomez avatar May 14 '24 19:05 gonzogomez