OpenAPITools / OpenAPITools/openapi-generator
[BUG][Go] Missing import of 'time' package when model contains object(map) of dates
Open
Nobody has claimed this yet.
Issue: Bug
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
The Go module generated from a schema property like this:
"schema": {
"type": "object",
"additionalProperties": {
"type": "string",
"format": "date-time"
}
}
is missing the import time statement and won't compile.
openapi-generator version
OpenAPI declaration file content or url
"/api/v2/Configuration/LatestConfigDates": {
"get": {
"tags": [
"Configuration"
],
"summary": "Get the latest config update times for each application running on a role.",
"parameters": [
{
"name": "roleId",
"in": "query",
"description": "The role to get latest config dates for",
"schema": {
"type": "integer",
"format": "int32"
}
}
],
"responses": {
"200": {
"description": "Success",
"content": {
"text/plain": {
"schema": {
"type": "object",
"additionalProperties": {
"type": "string",
"format": "date-time"
}
}
},
"application/json": {
"schema": {
"type": "object",
"additionalProperties": {
"type": "string",
"format": "date-time"
}
}
},
"text/json": {
"schema": {
"type": "object",
"additionalProperties": {
"type": "string",
"format": "date-time"
}
}
}
}
},
"500": {
"description": "Server Error"
}
}
}
},
-->
Generation Details
openapi-generator generate -g go -i api.yaml -o go/
Steps to reproduce
Related issues/PRs
https://github.com/OpenAPITools/openapi-generator/issues/3972
Suggest a fix
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
Run the provided openapi-generator generate -g go -i api.yaml -o go/ command with the object-of-date-times schema. Inspect the generated Go model and imports, then compile the generated package to reproduce the missing time import. Done means the generated module compiles for this schema.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100