acacode / acacode/swagger-typescript-api

Non nullable properties are generated as possibly undefined

未關閉
#396 14 則留言 23 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
TypeScript
星號
4.1k
分支
436
PR 合併指標
30 天內沒有已合併 PR

描述

I have an object of a product that has some non nullable properties such as ProductId and price with the following schema generated by swagger
```
"ProductBasicInfo": {
"type": "object",
"properties": {
"productId": {
"type": "integer",
"format": "int32"
},
"brand": {
"type": "string",
"nullable": true
},
"description": {
"type": "string",
"nullable": true
},
"name": {
"type": "string",
"nullable": true
},
"price": {
"type": "number",
"format": "double"
}
},
"additionalProperties": false
}
```

This is the generated contract
```
export interface ProductBasicInfo {
/** @format int32 */
productId?: number;
brand?: string | null;
description?: string | null;
name?: string | null;

/** @format double */
price?: number;
}
```
As you can see, in the generated contract a `?` was added to the non nullable properties making their type effectively `number | undefined
`

Is it possible to omit the `?` mark for non nullable types?

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。