WsdlToPhp / PackageGenerator

Generates a PHP SDK based on a WSDL, simple and powerful, WSDL to PHP
https://providr.io
MIT License
426 stars 73 forks source link

Class inheritance possibly misbehaving when having restriction tag #255

Closed Ionsight closed 1 year ago

Ionsight commented 3 years ago

Class inheritance possibly misbehaving when having restriction tag

When generating from
contactPersonFull ->
contactPersonExportBase ->
contactPersonBase


contactPersonFull:

<xs:complexType name="contactPersonFull">
  <xs:complexContent>
    <xs:extension base="exp:contactPersonExportBase">
      <xs:sequence>
        <xs:element name="Person" type="tns:personFull">
          <xs:annotation>
            <xs:documentation>...</xs:documentation>
          </xs:annotation>
        </xs:element>
        <xs:element name="UNILogin" type="trans:uniLoginFull" minOccurs="0">
          <xs:annotation>
            <xs:documentation>...</xs:documentation>
          </xs:annotation>
        </xs:element>
      </xs:sequence>
    </xs:extension>
  </xs:complexContent>
</xs:complexType>

contactPersonExportBase:

<xs:complexType name="contactPersonExportBase">
  <xs:complexContent>
    <xs:restriction base="d:contactPersonBase">
      <xs:attribute name="accessLevel" type="uni:KontaktpersonAdgangsniveau" use="required"/>
    </xs:restriction>
  </xs:complexContent>
</xs:complexType>

contactPersonBase:

<xs:complexType name="contactPersonBase">
  <xs:annotation>
    <xs:documentation>...</xs:documentation>
  </xs:annotation>
  <xs:attribute name="relation" use="required" type="uni:Kontaktpersonsrelation">
    <xs:annotation>
      <xs:documentation>...</xs:documentation>
    </xs:annotation>
  </xs:attribute>
  <xs:attribute name="childCustody" type="xs:boolean" use="required">
    <xs:annotation>
      <xs:documentation>...</xs:documentation>
    </xs:annotation>
  </xs:attribute>
  <xs:attribute name="accessLevel" type="uni:KontaktpersonAdgangsniveau">
    <xs:annotation>
    <xs:documentation>...</xs:documentation>
  </xs:annotation>
</xs:attribute>

Expectation:

Reality:

Additional context:
It seems that the restriction tag is part of the cause.

I'm unsure whether this is considered expected behavior, but I’ve tested with the dotnet-svcutil tool for .NET Core, which is behaving like I expect it to.


Regardless, do you know a way in which I can solve the issue by changing something (be it manually in the generated files, when configuring or otherwise)?

mikaelcom commented 3 years ago

Restriction base attribute is currently not taken into account as a way to declare an inheritance (I was not aware of that).

This is done within the extension parser on the other hand.

To be fixed I presume :wink:

mikaelcom commented 1 year ago

Restriction base attribute is currently not taken into account as a way to declare an inheritance (I was not aware of that).

This is done within the extension parser on the other hand.

To be fixed I presume wink

I think I reviewed the code too fast last time, the inheritance from the base attribute should be handled correctly at https://github.com/WsdlToPhp/PackageGenerator/blob/develop/src/Parser/Wsdl/TagRestriction.php#L82. Any chance to get the WSDL? In the meantime, I'll try to create a local test sample

mikaelcom commented 1 year ago

Regardless, do you know a way in which I can solve the issue by changing something (be it manually in the generated files, when configuring or otherwise)?

Change the generated class manually but it will eb rewritten next time you generate the package.

mikaelcom commented 1 year ago

Issue identified, a fix is coming :crossed_fingers: