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

Use type names instead of attribute names for types #58

Open
anka-213 opened this issue Mar 6, 2023 · 0 comments
Open

Use type names instead of attribute names for types #58

anka-213 opened this issue Mar 6, 2023 · 0 comments

Comments

@anka-213
Copy link

anka-213 commented Mar 6, 2023

Currently the place where a type is used determines what name it should have instead of the actual name of the type, which i think would be more helpful.

For example, if we have a wsdl file like this:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:wsdlauthority="http://minameddelanden.gov.se/Authority"
                  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
                  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
                  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                  name="Authority"
                  targetNamespace="http://minameddelanden.gov.se/Authority">
    <wsdl:types>
        <xsd:schema targetNamespace="http://minameddelanden.gov.se/Authority"
                    xmlns:dispatcher="http://minameddelanden.gov.se/schema/Dispatcher">

            <xsd:import schemaLocation="schema/Dispatcher.xsd" namespace="http://minameddelanden.gov.se/schema/Dispatcher"/>

            <xsd:element name="getDispatchers">
                <xsd:complexType>
                    <xsd:sequence/>
                </xsd:complexType>
            </xsd:element>
            <xsd:element name="getDispatchersResponse">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element name="return" type="dispatcher:Dispatcher" minOccurs="0" maxOccurs="unbounded"/>
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>
            <xsd:element name="getDispatchersFault" >
                <xsd:complexType>
                    <xsd:sequence/>
                </xsd:complexType>
            </xsd:element>
        </xsd:schema>
    </wsdl:types>

    <wsdl:message name="getDispatchersRequest">
        <wsdl:part name="parameters" element="wsdlauthority:getDispatchers"/>
    </wsdl:message>
    <wsdl:message name="getDispatchersResponse">
        <wsdl:part name="parameters" element="wsdlauthority:getDispatchersResponse"/>
    </wsdl:message>
    <wsdl:message name="getDispatchersFault">
        <wsdl:part name="fault" element="wsdlauthority:getDispatchersFault"/>
    </wsdl:message>

    <wsdl:portType name="AuthorityPort">
        <wsdl:operation name="getDispatchers">
            <wsdl:input message="wsdlauthority:getDispatchersRequest"/>
            <wsdl:output message="wsdlauthority:getDispatchersResponse"/>
            <wsdl:fault name="fault" message="wsdlauthority:getDispatchersFault"/>
        </wsdl:operation>
    </wsdl:portType>
</wsdl:definitions>

with schema/Dispatcher.xsd containing

<?xml version="1.0" encoding="UTF-8"?>
<schema targetNamespace="http://minameddelanden.gov.se/schema/Dispatcher"
  elementFormDefault="qualified"
  xmlns="http://www.w3.org/2001/XMLSchema">

  <complexType name="Dispatcher">
    <sequence>
      <element name="Id" type="string" minOccurs="1" maxOccurs="1" />
      <element name="Name" type="string minOccurs="1" maxOccurs="1"/>
    </sequence>
  </complexType>

</schema>

then the type dispatcher:Dispatcher, which is used by getDispatchersResponse will be generated under the name return instead of as the name Dispatcher which would be way more accurate and informative.

Current output

/**
 * return
 * @targetNSAlias `dispatcher`
 * @targetNamespace `http://minameddelanden.gov.se/schema/Dispatcher`
 */
export interface Return {
    Id?: string;
    Name?: string;
}

 /** getDispatchersResponse */
 export interface GetDispatchersResponse {
     /** return[] */
     return?: Array<Return>;
 }

Desired output

/**
 * Dispatcher
 * @targetNSAlias `dispatcher`
 * @targetNamespace `http://minameddelanden.gov.se/schema/Dispatcher`
 */
export interface Dispatcher {
    Id?: string;
    Name?: string;
}

 /** getDispatchersResponse */
 export interface GetDispatchersResponse {
     /** return[] */
     return?: Array<Dispatcher>;
 }

Here the attribute still has the correct name return, but the interface mirrors the original name of the type.

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