Skip to main content

Response Information Now Better Represented In Exported WADL

· 2 min read

Information about array responses or primitive type responses was being incorrectly represented or entirely missed. We have released some fixes to improve on this.

Details​

Previously, the response type was linked directly with the response representation. These created two major problems discussed below:

No Support for Response Arrays​

A response returning a Pet array object was represented as follows:

<response status="200">
<doc title="200" xml:lang="en">successful operation</doc>
<representation element="tns:Pet" mediaType="application/xml" />
</response>

Since the representation tag does not support arrays, any information about that was lost in the above case. To overcome this problem, we now create a separate model for the response definition that will wrap around the actual response definition. The model will be linked with the representation as follows:

<response status="200">
<doc title="200" xml:lang="en">successful operation</doc>
<representation element="tns:findPetsByStatus_Response" mediaType="application/xml" />
</response>

The model definition, itself, will look like this and is capable of supporting arrays:

<xs:complexType name="findPetsByStatus_Response">
<xs:sequence>
<xs:element minOccurs="1" maxOccurs="unbounded" name="response" type="tns:Pet">
<xs:annotation>
<xs:documentation>successful operation</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>

Incorrect Reference to Primitive XSD Types​

According to the WADL specification, the element attribute expects a valid reference to a type defined under the grammars section. Due to this, a primitive XSD type reference used here directly is not valid and will no longer be used as before.

This is, therefore, invalid:

<response status="200">
<doc title="200" xml:lang="en">successful operation</doc>
<representation element="xs:integer" mediaType="application/json" />
</response>

As was in the previous case, we now create a separate model for the response definitions that will wrap around the actual response definition. The model will be linked with the representation as follows:

<response status="200">
<doc title="200" xml:lang="en">successful operation</doc>
<representation element="tns:getInventory_Response" mediaType="application/json" />
</response>

The model definition, itself, will look like this:

<xs:element name="getInventory_Response" type="xs:integer" />