grantila / grantila/typeconv

Typescript: string quoted properties get double quoted when converted to OpenAPI

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

Description

I have an the interface that has some properties that must be quoted strings
```ts
export interface IHttpResponseSharePointFile {
'@odata.context': string;
'@content.downloadUrl': string;
'@deprecated.Decorator': string;
createdBy: string;
createdDateTime: string;
}
```

When I generate OpenAPI references from these the key/property name is wrapped in quotes again. It becomes `"'@content.downloadUrl'"` and I would instead expect it to be `"@content.downloadUrl"` with just a single level of quote marks.

I ran this on the CLI
```
typeconv --from-type ts --to-type oapi --output-directory swagger-schemas --oapi-format json --oapi-version 3 \"interfaces/**/*.ts\"
```

Here's the JSON output
```json
"IHttpResponseSharePointFile": {
"properties": {
"'@odata.context'": {
"title": "IHttpResponseSharePointFile.'@odata.context'",
"type": "string"
},
"'@content.downloadUrl'": {
"title": "IHttpResponseSharePointFile.'@content.downloadUrl'",
"type": "string"
},
"'@deprecated.Decorator'": {
"title": "IHttpResponseSharePointFile.'@deprecated.Decorator'",
"type": "string"
},
"createdBy": {
"$ref": "#/components/schemas/ISharePointFileCreatedBy",
"title": "string"
},
"createdDateTime": {
"title": "IHttpResponseSharePointFile.createdDateTime",
"type": "string"
},
},
"required": [
"'@odata.context'",
"'@content.downloadUrl'",
"'@deprecated.Decorator'",
"createdBy",
"createdDateTime",
],
"additionalProperties": false,
"title": "IHttpResponseSharePointFile",
"type": "object"
},

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.