highsource/jsonix-schema-compiler

[feature-request] Add option to allow unchanged localName properties while generating mappings.

Opened this issue · 6 comments

Allowing unchanged localName names (exactly the same as in XML eg <Element_With_Underscore> makes JSON prop Element_With_Underscore) would help to use library like cxsd. One could generate TypeScript types for intellisense and use it to compose JSON to generate XML using Jsonix mappings

I would also appreciate an option to keep the original localNames and property names. That would be very cool and would make our work a lot easier.

Thank you :)

@AndreasBrie

to keep the original localNames and property names

You mean JSON property names should be exactly as local names of respective attributes/elements?

There are some properties which may contain several elements. Won't work in that case, but for other cases should be quite doable.

Thanks for your fast reply.
Yes. For Example, this is an extract of a XSD-File
<xsd:element name="STABE_BEZ" minOccurs="0"> <xsd:annotation> <xsd:documentation>Cntry of affil. of means of transport at departure of goods</xsd:documentation> </xsd:annotation> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:maxLength value="15"/> </xsd:restriction> </xsd:simpleType> </xsd:element>

and i would like to keep the underscore and perhaps also the uppercase (but thats not necessarily required). So instead of being converted to:

{ name: 'stabebez', elementName: { localPart: 'STABE_BEZ' } }
i would like to have:
{ name: 'STABE_BEZ', elementName: { localPart: 'STABE_BEZ' } }

Would this be possible?

fyi reason for my request: We use this for converting SAP Idoc Schema files to typescript types via this project's json schema generation. And for SAP Idoc Files it is very common to use underscores in field names. And to easily find the usage of a certain SAP Idoc field it would be very helpful to search with the original field names. So this would be mainly for keeping a kind of type description consistency. Therefore it wouldn't be a must-have but a cool nice-to-have feature :)

Ok, this can be quite easily implemented for "simple" property types like attribute property and element property.

This won't work for other properties (value, elements, element reference, elements reference, any attribute, any element).

...so will it be implemented for simple types at least?

Any progress on this topic?