grantila / grantila/typeconv

Typescript type "Date" is misrecognized as user-defined type

Open
#17 4 comments 4 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
447
Forks
10
PR merge metrics
No merged PRs in 30d

Description

I have a script running from CLI which transforms typescript definitions to openapi. When having a model like this
```ts
export interface MyObject {
startDate: Date,
otherProp: string
}
```
the output is this
```json
{
"MyObject": {
"type": "object",
"properties": {
"startDate": {
"$ref": "#/definitions/Date",
"title": "myObject.startDate"
},
"otherProp": {
"type": "string",
"title": "myObject.otherProp"
}
},
"required": [
"startDate",
"otherProp"
],
"additionalProperties": false,
"title": "MyObject"
}
}
```

The Date type is being interpreted as a user defined type, but it is not. It's a native type

Expected output is
```json
{
"MyObject": {
"type": "object",
"properties": {
"startDate": {
"type": "string",
"format": "date-time",
"title": "myObject.startDate"
},
"otherProp": {
"type": "string",
"title": "myObject.otherProp"
}
},
"required": [
"startDate",
"otherProp"
],
"additionalProperties": false,
"title": "MyObject"
}
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.