grantila / typeconv

Convert between JSON Schema, TypeScript, GraphQL, Open API and SureType
MIT License
421 stars 8 forks source link

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

Open ChrisMBarr opened 4 months ago

ChrisMBarr commented 4 months ago

I have an the interface that has some properties that must be quoted strings

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


"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"
},