Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
3 of 6 tasks
mohakkataria opened this issue Jan 9, 2023 · 4 comments
Open
3 of 6 tasks

Comments

@mohakkataria
Copy link

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
@philip-ellis-sp
Copy link

I think this is a duplicate of #14057

@christerswahn
Copy link

I'm having this problem as well (and it does not seem to have been fixed by #14057).

@madpah
Copy link
Contributor

madpah commented Dec 21, 2023

Same here - the OpenAPI Schema (in YAML) that is choking the generator is:

   MyUserDTO:
      properties:
        emailAndCommitDateMap:
          additionalProperties:
            items:
              format: date-time
              type: string
            type: array
          type: object
      type: object

Generated model is missing the import for time.

@madpah
Copy link
Contributor

madpah commented Dec 21, 2023

I can confirm I have tested with the latest master and the issue still exists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants