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

Fix: Usage of ref maxoccurs and minoccurs attributes #1260

Merged
merged 10 commits into from
Nov 3, 2024

Conversation

ydaniju
Copy link
Contributor

@ydaniju ydaniju commented Oct 29, 2024

Consider this XSD:

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
  xmlns:EVT="http://ws.gematik.de/conn/EventService/v7.2"
  targetNamespace="http://ws.gematik.de/conn/EventService/v7.2" elementFormDefault="qualified"
  attributeFormDefault="unqualified" version="7.2.1">
  <simpleType name="SubscriptionIDType">
    <restriction base="string">
      <maxLength value="64" />
    </restriction>
  </simpleType>
  <element name="SubscriptionID" type="EVT:SubscriptionIDType"/>
  <element name="Subscribe">
    <complexType>
      <sequence>
        <element ref="EVT:Subscription" /> <!--Reference to Subscription without minOccurs or maxOccurs-->
      </sequence>
    </complexType>
  </element>
  <element name="GetSubscription">
    <complexType>
      <sequence>
        <element ref="EVT:SubscriptionID" minOccurs="0" />
      </sequence>
      <attribute name="mandant-wide" type="boolean" use="optional" default="false" />
    </complexType>
  </element>
  <element name="GetSubscriptionResponse">
    <complexType>
      <sequence>
        <element name="Subscriptions">
          <complexType>
            <sequence>
              <element ref="EVT:Subscription" minOccurs="0" maxOccurs="unbounded" /> <!--Reference to Subscription with minOccurs or maxOccurs-->
            </sequence>
          </complexType>
        </element>
      </sequence>
    </complexType>
  </element>
  <complexType name="SubscriptionType">
    <sequence>
      <element ref="EVT:SubscriptionID" minOccurs="0" />
      <element ref="EVT:TerminationTime" minOccurs="0" />
    </sequence>
  </complexType>
  <element name="Subscription" type="EVT:SubscriptionType" />
  <element name="TerminationTime" type="dateTime" />
</schema>

I expected Subscriptions to be returned as a List Subscription.

Sample response SOAP:

<?xml version='1.0' encoding='UTF-8'?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
    <S:Body>
        <ns11:GetSubscriptionResponse xmlns:ns2="http://ws.gematik.de/conn/ConnectorCommon/v5.0"
            xmlns:ns11="http://ws.gematik.de/conn/EventService/v7.2"
        >
            <ns2:Status>
                <ns2:Result>OK</ns2:Result>
            </ns2:Status>
            <ns11:Subscriptions>
                <ns11:Subscription>
                    <ns11:SubscriptionID>a24610ec-4069-4efc-a87e-5ab1d944ec5f</ns11:SubscriptionID>
                    <ns11:TerminationTime>2024-10-31T20:00:27.567+01:00</ns11:TerminationTime>
                </ns11:Subscription>
            </ns11:Subscriptions>
        </ns11:GetSubscriptionResponse>
    </S:Body>
</S:Envelope>

The current value being returned if there is only one subscription

{
  "Status": {
    "Result": "OK"
  },
  "Subscriptions": {
    "Subscription": {
        "SubscriptionID": "a24610ec-4069-4efc-a87e-5ab1d944ec5f",
        "TerminationTime": "2024-10-31T20:00:27.567+01:00"
     }
  }
}

When ref is used to set maxoccurs, if the returned value is a single value, it will not be converted to an array.

Response I'm expecting.

{
  "Status": {
    "Result": "OK"
  },
  "Subscriptions": {
    "Subscription": [
      {
        "SubscriptionID": "a24610ec-4069-4efc-a87e-5ab1d944ec5f",
        "TerminationTime": "2024-10-31T20:00:27.567+01:00"
      }
    ]
  }
}

@w666
Copy link
Collaborator

w666 commented Oct 30, 2024

Hi @ydaniju, I assume this PR is not ready for review yet?

@ydaniju
Copy link
Contributor Author

ydaniju commented Oct 30, 2024

Hi @ydaniju, I assume this PR is not ready for review yet?

Hey @w666 It's not ready yet. I have one failing test to fix right now

@ydaniju ydaniju marked this pull request as ready for review November 1, 2024 21:30
@ydaniju
Copy link
Contributor Author

ydaniju commented Nov 1, 2024

Now ready for review @w666

@w666
Copy link
Collaborator

w666 commented Nov 3, 2024

@ydaniju is this fix urgent for you?

There is another PR in progress that I would like to include into next release.
But if you need this ASAP, I can build a release earlier.

@ydaniju
Copy link
Contributor Author

ydaniju commented Nov 3, 2024

@ydaniju is this fix urgent for you?

There is another PR in progress that I would like to include into next release. But if you need this ASAP, I can build a release earlier.

@w666 This is quite urgent. Would be great to have it sooner if it is not an inconvenience. Thank you.

@w666 w666 merged commit b14d40c into vpulim:master Nov 3, 2024
1 check passed
@w666
Copy link
Collaborator

w666 commented Nov 3, 2024

@ydaniju version 1.1.6 has been released

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

Successfully merging this pull request may close these issues.

2 participants