swagger-api / swagger-api/swagger-codegen
Error parsing time with format "Y-m-d H:i:s" in generated go client
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
I'm using swagger-codegen to generate go docs from Laravel project.
When using the generated go client, I keep getting error parsing time "2022-10-11 10:29:16" as "2006-01-02T15:04:05Z07:00" when trying to fill the model after calling an API


In the initial project, the annotation set for this field is
* @OA\Property(property="purchase_date",type="string", format="date-time")
In the generated go client by swagger, the field is
PurchaseDate time.Time json:"purchase_date,omitempty"``
Swagger-codegen version
3.0.34
Swagger declaration file content or url
snippet from yaml file
PurchaseResource:
title: purchase_resource
properties:
id:
type: integer
external_id:
type: string
purchase_date:
type: string
format: date-time
Command line used for generation
swagger-codegen generate -i api-docs.json -l go --api-package SubscriptionsClient -o ./client-go
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the generated Go model's PurchaseDate field and the swagger-codegen generate command, then trace how the YAML date-time schema becomes time.Time. Reproduce the failure using the shown timestamp; done means the generated client handles the documented value consistently or the required input format is clearly documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, laravel
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100