Skip to content

Commit

Permalink
Fix usage of ref maxoccurs and minoccurs attributes (#1260)
Browse files Browse the repository at this point in the history
Add test
  • Loading branch information
ydaniju authored Nov 3, 2024
1 parent 9598d8e commit b14d40c
Show file tree
Hide file tree
Showing 7 changed files with 179 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/wsdl/elements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ export class ElementElement extends Element {

const isMany = maxOccurs > 1;

if (isMany) {
if (isMany && name) {
name += '[]';
}

Expand Down Expand Up @@ -287,7 +287,14 @@ export class ElementElement extends Element {
typeStorage[typeName] = elem;
} else {
if (this.$ref) {
element = typeStorage[typeName];
// Differentiate between a ref for an array of elements and a ref for a single element
if (isMany) {
const refTypeName = typeName + '[]';
typeStorage[refTypeName] = typeStorage[typeName];
element[refTypeName] = typeStorage[refTypeName];
} else {
element = typeStorage[typeName];
}
} else {
element[name] = typeStorage[typeName];
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?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>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:EVT="http://ws.gematik.de/conn/EventService/v7.2"
xmlns:EVTW="http://ws.gematik.de/conn/EventService/WSDL/v7.2"
>
<soap:Body>
<EVT:GetSubscription xmlns:EVT="http://ws.gematik.de/conn/EventService/v7.2"
xmlns="http://ws.gematik.de/conn/EventService/v7.2">
</EVT:GetSubscription>
</soap:Body>
</soap:Envelope>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"Status": {
"Result": "OK"
},
"Subscriptions": {
"Subscription": [
{
"SubscriptionID": "a24610ec-4069-4efc-a87e-5ab1d944ec5f",
"TerminationTime": "2024-10-31T20:00:27.567+01:00"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:EVT="http://ws.gematik.de/conn/EventService/v7.2"
xmlns:EVTW="http://ws.gematik.de/conn/EventService/WSDL/v7.2"
targetNamespace="http://ws.gematik.de/conn/EventService/WSDL/v7.2">
<documentation>
Copyright (c) 2014, gematik - Gesellschaft für Telematikanwendungen der Gesundheitskarte mbH.
Alle Rechte
vorbehalten.
Beschreibung: Konnektor Ereignisdienst
version=7.2.0
</documentation>
<types>
<xs:schema>
<xs:import schemaLocation="EventService.xsd"
namespace="http://ws.gematik.de/conn/EventService/v7.2" />
</xs:schema>
</types>
<message name="SubscribeRequestMessage">
<part name="parameter" element="EVT:Subscribe" />
</message>
<message name="SubscribeResponseMessage">
<part name="parameter" element="EVT:SubscribeResponse" />
</message>
<message name="GetSubscriptionRequestMessage">
<part name="parameter" element="EVT:GetSubscription" />
</message>
<message name="GetSubscriptionResponseMessage">
<part name="parameter" element="EVT:GetSubscriptionResponse" />
</message>
<portType name="EventServicePortType">
<operation name="Subscribe">
<input message="EVTW:SubscribeRequestMessage" />
<output message="EVTW:SubscribeResponseMessage" />
<fault name="FaultMessage" message="EVTW:FaultMessage" />
</operation>
<operation name="GetSubscription">
<input message="EVTW:GetSubscriptionRequestMessage" />
<output message="EVTW:GetSubscriptionResponseMessage" />
<fault name="FaultMessage" message="EVTW:FaultMessage" />
</operation>
</portType>
<binding name="EventServiceBinding" type="EVTW:EventServicePortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
<operation name="Subscribe">
<soap:operation soapAction="http://ws.gematik.de/conn/EventService/v7.2#Subscribe" />
<input>
<soap:body use="literal" />
</input>
<output>
<soap:body use="literal" />
</output>
<fault name="FaultMessage">
<soap:fault name="FaultMessage" use="literal" />
</fault>
</operation>
<operation name="GetSubscription">
<soap:operation soapAction="http://ws.gematik.de/conn/EventService/v7.2#GetSubscription" />
<input>
<soap:body use="literal" />
</input>
<output>
<soap:body use="literal" />
</output>
<fault name="FaultMessage">
<soap:fault name="FaultMessage" use="literal" />
</fault>
</operation>
</binding>
<service name="EventService">
<port name="EventServicePort" binding="EVTW:EventServiceBinding">
<soap:address location="http://127.0.0.1:8001/eventservice" />
</port>
</service>
</definitions>

0 comments on commit b14d40c

Please sign in to comment.