Skip to content
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

Illegal characters in enum element names for TypeScript. #27

Open
claudemartin opened this issue Jun 10, 2021 · 0 comments
Open

Illegal characters in enum element names for TypeScript. #27

claudemartin opened this issue Jun 10, 2021 · 0 comments

Comments

@claudemartin
Copy link

Description

Note: I'm only interested in TypeScript, so I didn't test any other languages.

When generating code for TS and there's an enum type (enumeration) it could have illegal characters, such as ".". Those should be replaced by underscore. It doesn't matter because the type uses the exact string as the value of each constant. So the name doesn't really matter as long as it's always generated the same way.
Here's an example of how it would be done using JAX:

@XmlType(name = "exampleEnumType")
@XmlEnum
public enum ExampleEnumType{
    @XmlEnumValue("FOO.BAR")
    FOO_BAR("FOO.BAR"),
    ...

Steps to reproduce the issue:

  1. Use XSD that has enumeration with characters that are illegal in TS (i.e. EcmaScript)
  2. xgen -l TypeScript -i ".\foo.xsd" -o "foo"
  3. Compile the generated code.

You can use this as an example: https://share.ech.ch/xmlns/eCH-0196/2/eCH-0196-2-0.xsd
The enum SecurityTypeType is the problem.

Describe the results you received:

Constant names with ".".

Describe the results you expected:

Constant names with "_" instead of ".".

Output of go version:

go version go1.16.5 windows/amd64

xgen version or commit ID:

xgen version: 0.1.0

Environment details (OS, physical, etc.):

Doesn't matter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant