Skip to content

Constant string types result in invalid TypeScript code #1118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
swachter opened this issue May 22, 2023 · 0 comments · Fixed by #1149
Closed

Constant string types result in invalid TypeScript code #1118

swachter opened this issue May 22, 2023 · 0 comments · Fixed by #1149
Labels
openapi-ts Relevant to the openapi-typescript library

Comments

@swachter
Copy link
Contributor

swachter commented May 22, 2023

Description

A property that must have a constant string value

              "name": {
                "const": "local-userpass",
                "description": "The name of the authentication provider. For Email/Password authentication, this value is always `local-userpass`."
              },

yields invalid TypeScript code (the value has to be quoted):

      /**
       * @description The name of the authentication provider. For Email/Password authentication, this value is always `local-userpass`. 
       * @constant
       */
      name?: local-userpass;

Name Version
openapi-typescript 6.2.4

Reproduction

How can this be reproduced / when did the error occur?

This can be reproduced by processing the OpenAPI specification of the MongoDB Atlas App Services Admin API.

@drwpow drwpow added the openapi-ts Relevant to the openapi-typescript library label May 22, 2023
duncanbeevers added a commit to duncanbeevers/openapi-typescript that referenced this issue May 26, 2023
drwpow pushed a commit that referenced this issue Jun 12, 2023
* fix(openapi-typescript): Stringify primitive constant values

Closes #1118

* fixup! fix(openapi-typescript): Stringify primitive constant
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
openapi-ts Relevant to the openapi-typescript library
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants