Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #5223
Closed
Open
Issue created Feb 06, 2020 by Administrator@rootContributor

[Typescript-angular] Bug generating APIs with Date-Time parameters

Created by: mcpummec

Description

When generating APIs with Date-Time parameters, the generated service returns the error "key may not be null if value is Date".

openapi-generator version

This was introduced by 4.2.3. I'm having no issues running 4.0.1.

OpenAPI declaration file content or url

"parameters": [{ "name": "date", "in": "query", "type": "string", "format": "date-time" } ]

Command line used for generation

openapi-generator generate -g typescript-angular -i [swaggerUri] -o [outputPath] -c scripts/open-api-generator.conf.json

Steps to reproduce
  • Generate API
  • call service with signature "public getData(date?: Date, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json'}): Observable"
  • exception is thrown: "Error: key may not be null if value is Date"
Related issues/PRs

Possibly related to https://github.com/OpenAPITools/openapi-generator/issues/4404

Suggest a fix/enhancement

The problem is addToHttpParams and addToHttpParamsRecursive. For values with 'typeof values ==="object"', addToHttpParamsRecursive is called without the 'key' property. But if 'value instanceof Date', a key is required; otherwise the error is raised.

sample.txt

Assignee
Assign to
Time tracking