dderevjanik / wsdl-tsclient

:page_facing_up: Generate typescript client from wsdl
MIT License
95 stars 68 forks source link

Enumerable strings to unions #86

Open johngeorgewright opened 2 months ago

johngeorgewright commented 2 months ago

I'd like to suggest that enumerable strings be converted to unions.

For example:

<!-- ... -->
<element maxOccurs="1" minOccurs="0" name="adUnitView" type="tns:AdUnitView"/>
<!-- ... -->
<simpleType name="AdUnitView">
  <restriction base="xsd:string">
    <enumeration value="TOP_LEVEL"/>
    <enumeration value="FLAT"/>
    <enumeration value="HIERARCHICAL"/>
  </restriction>
</simpleType>

Would become:

  /** AdUnitView|xsd:string */
  adUnitView?: 'TOP_LEVEL' | 'FLAT' | 'HIERARCHICAL'

Rather than the current implementation:

  /** AdUnitView|xsd:string|TOP_LEVEL,FLAT,HIERARCHICAL */
  adUnitView?: string
johngeorgewright commented 1 month ago

... or even better having the values available as an enum or object too.

export enum AdUnitView {
  TOP_LEVEL = 'TOP_LEVEL',
  FLAT = 'FLAT',
  HIERARCHICAL = 'HIERARCHICAL'
}

...

  /** AdUnitView|xsd:string */
  adUnitView?: AdUnitView | keyof typeof AdUnitView