openapi-typescript-codegen icon indicating copy to clipboard operation
openapi-typescript-codegen copied to clipboard

Enum name on OpenAPI v3 takes the wrong name from schema description

Open tiberiuzuld opened this issue 2 years ago • 0 comments

We updated our OpenAPI v1 to v3 and we encountered this issue with a description of the model: Java Code

public abstract class MyClass implements Serializable {
    @NotNull
    @Schema(description = "MY string with spaces")
    private MySource source;
}

OpenAPI Schema part

"MyClass": {
 "properties": 
    {
      "source": {
        "type": "string",
        "description": "MY string with spaces",
        "enum": [
          "value",
        ]
      }
    }
}

Typescript

  export type MyClass = {
      'MY string with spaces': MyClass.'MY string with spaces'
  }

  export namespace MyClass {
      export enum 'MY string with spaces'; {
          value = 'value'
      }
  }

The enum with spaces is not supported in the Typescript output.

Probably the cod that creates the issue: https://github.com/ferdikoomen/openapi-typescript-codegen/blob/e1268b197a3924a58cbacea3c3c9e781400ab304/src/openApi/v3/parser/getEnumFromDescription.ts

tiberiuzuld avatar Mar 21 '22 11:03 tiberiuzuld