cancel
Showing results for 
Search instead for 
Did you mean: 

Mock API XML response allOf array bug

Highlighted
New Contributor

Mock API XML response allOf array bug

Hello when using the Mock API within SwaggerHub, the XML response doesn't handle properly arrays of objects using allOf.

The example that swaggerHub generates is OK, but not the response sent by the mock.

 

For instance, in this API, the Supplier and Customer schemas both include their own properties and properties inherited from Manufacturer schema (using the allOf keyword)

 

The response contains a Manufacturer, an array of Suppliers, and a Customer.

 

The example  generated by SwaggerHub is fine : 

 

<?xml version="1.0" encoding="UTF-8"?>
<inventoryItems>
	<inventoryItem>
		<id>d290f1ee-6c54-4b01-90e6-d701748f0851</id>
		<name>Widget Adapter</name>
		<releaseDate>2016-08-29T09:12:33.001Z</releaseDate>
		<manufacturer>
			<name>ACME Corporation</name>
			<homePage>https://www.acme-corp.com</homePage>
			<phone>408-867-5309</phone>
		</manufacturer>
		<supplier>
			<name>ACME Corporation</name>
			<homePage>https://www.acme-corp.com</homePage>
			<phone>408-867-5309</phone>
			<supplierRef>REF123</supplierRef>
		</supplier>
		<customer>
			<name>ACME Corporation</name>
			<homePage>https://www.acme-corp.com</homePage>
			<phone>408-867-5309</phone>
			<customerRef>REF123</customerRef>
		</customer>
	</inventoryItem>
</inventoryItems>

 

But the Mock API response adds an AnonymousModel tag as if the xml name of the object had not been properly defined :

<?xml version='1.1' encoding='UTF-8'?>
  <inventoryItems>
    <inventoryItem>
      <id>d290f1ee-6c54-4b01-90e6-d701748f0851</id>
      <name>Widget Adapter</name>
      <releaseDate>2015-07-20T15:49:04-07:00</releaseDate>
      <manufacturer>
        <name>ACME Corporation</name>
        <homePage>https://www.acme-corp.com</homePage>
        <phone>408-867-5309</phone>
      </manufacturer>
      <supplier>
        <AnonymousModel>
          <name>ACME Corporation</name>
          <homePage>https://www.acme-corp.com</homePage>
          <phone>408-867-5309</phone>
          <supplierRef>REF123</supplierRef>
        </AnonymousModel>
      </supplier>
      <customer>
        <name>ACME Corporation</name>
        <homePage>https://www.acme-corp.com</homePage>
        <phone>408-867-5309</phone>
        <customerRef>REF123</customerRef>
      </customer>
    </inventoryItem>
  </inventoryItems>

 

Note that this only happens when using arrays of schemas defined with allOf (supplier), not unique objects using allOf (customer)

 

Any chance to get this fixed ?

Right now the mock can't be used to test responses as the answer is not coherent with the spec...

2 REPLIES 2
New Contributor

Re: Mock API XML response allOf array bug

This issue was also posted here, but wasn't followed up

Moderator

Re: Mock API XML response allOf array bug

Hi,

 

We have opened an internal defect to fix this issue.  As a workaround for now, please add examples directly in the responses to override the XML response that is returned by the auto mock integration as below.

 

responses:
        '200':
          description: search results matching criteria
          content:
            application/xml:
              schema:
                ...
              example: |
                <inventoryItems>
                   <!-- ... -->
                </inventoryItems>

Regards,

Marcus James

SmartBear Support



 Join SmartBear Connect next April in Boston to meet with software development, API and testing experts from around the world! Get your ticket today!