lukeautry / tsoa

Build OpenAPI-compliant REST APIs using TypeScript and Node
MIT License
3.42k stars 489 forks source link

Key of schema with `$` are generated, but `$` is invalid character. #1507

Closed bigen1925 closed 9 months ago

bigen1925 commented 9 months ago

Key of schema with $ is generated when $ is in type name, but $ is invalid in schema name.

refs) https://swagger.io/specification/#:~:text=All%20the%20fixed%20fields%20declared%20above%20are%20objects%20that%20MUST%20use%20keys%20that%20match%20the%20regular%20expression%3A%20%5E%5Ba%2DzA%2DZ0%2D9%5C.%5C%2D_%5D%2B%24.

Sorting

Expected Behavior

$ (the only character that can be used in ES identifier and invalid in openapi key ) should be replaced with _ or . or -

When type definition is

type $DollarType = string;

, generated spec is expected like

{
  "components": {
    "schemas": {
      "_DollarType": {
        "type": "string"
      }
    }
  }
}

Current Behavior

When type definition is

type $DollarType = string;

, generated spec is

{
  "components": {
    "schemas": {
      "$DollarType": {
        "type": "string"
      }
    }
  }
}

Possible Solution

replace $

Steps to Reproduce

https://github.com/bigen1925/tsoa-schema-key-with-dollar

Context (Environment)

Version of the library: 6.0.0-rc.4 Version of NodeJS: v18.15.0

Detailed Description

nothing

Breaking change?

may be NO.

github-actions[bot] commented 9 months ago

Hello there bigen1925 👋

Thank you for opening your very first issue in this project.

We will try to get back to you as soon as we can.👀

bigen1925 commented 9 months ago

This is relevant to #1468

WoH commented 9 months ago

Can you check with tsoa@next? This should be solved

bigen1925 commented 9 months ago

@WoH I confirmed this is solved in tsoa@next !

Thank you so much!