Skip to content

[BUG][Go] Missing import of 'time' package when model contains object(map) of dates #14403

@mohakkataria

Description

@mohakkataria

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

#3972

Suggest a fix

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions