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

[typescript-fetch] (4.0.X) Model parameter uses string type when format: date #1546

Closed
someone1 opened this issue Nov 26, 2018 · 1 comment
Closed

Comments

@someone1
Copy link
Contributor

someone1 commented Nov 26, 2018

Description

The typescript-fetch generator defines models with type: string/format: date as type string, but serializes/deserializes the value as a Date

openapi-generator version

openapi-generator-cli-4.0.0-20181126.024631-44

OpenAPI declaration file content or url
swagger: "2.0"

paths:
  "/config":
    get:
      operationId: "config.get"
      responses:
        200:
          description: Success
          schema:
            $ref: "#/definitions/SiteConfiguration"

definitions:
  SiteConfiguration:
    description: "Site configuration"
    type: object
    properties:
      maxReportingDate:
        type: string
        format: date
      minReportingDate:
        type: string
        format: date

Generated Code (excerpt):

export interface SiteConfiguration {
    /**
     * 
     * @type {string}
     * @memberof SiteConfiguration
     */
    maxReportingDate?: string;
    /**
     * 
     * @type {string}
     * @memberof SiteConfiguration
     */
    minReportingDate?: string;
}

export function SiteConfigurationFromJSON(json: any): SiteConfiguration {
    return {
        'maxReportingDate': !exists(json, 'maxReportingDate') ? undefined : new Date(json['maxReportingDate']),
        'minReportingDate': !exists(json, 'minReportingDate') ? undefined : new Date(json['minReportingDate']),
    };
}
Command line used for generation

openapi-generator generate -i openapi.yaml -l typescript-fetch -c es6.json -o ./typescript-api/

Steps to reproduce
  1. Use the provided yaml excerpt above to generate a client with the provided command line
  2. Buggy code generated
Related issues/PRs

PR #569

Suggest a fix/enhancement

Add additional resolution for Date or DateTime formatted strings in getTypeDeclaration here

@macjohnny
Copy link
Member

cc @Place1

@someone1 someone1 closed this as completed Dec 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants