swagger-api / swagger-api/swagger-codegen

Error occurs while build generated typescript

Open
#11,272 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

On use the header menu item: Generate Client/typescript-angular all the definitions... All the definitions types with type:"string" and format: "date-time" returns in the generated models (into the models folder) a model with type "Date" and it should returns "string".

Swagger-codegen version

Version 4.0.1

Swagger declaration file content or url
birthdate:
 properties:
  type: string
  format: date```

Generates a model .ts: 
```ts
birthDate: string; // Well done!
birthdate:
 properties:
  type: string
  format: date-time

Generates a model .ts:

birthDate: Date; // Wrong!

The format property isn't a Json primitive.

Steps to reproduce
  1. Declare a property with type: string and format: date
  2. Declare another property with type: string and format date-time
  3. Go to Menu /Generate Client / typescript-angular
  4. Open zip file and find into the /models folder the generated type is (string for date // Well and Date for date-time // Wrong)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with the two YAML property definitions and inspect the typescript-angular generator path that produces files in the models folder. Compare the generated types for format: date and format: date-time, then verify the corrected output against both cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, openapi, typescript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.