Empty attribute in post message in openapi - swagger-ui

I am creating documentation for our API. The problem is that I dont know, how to make attribute "empty" (not visible at all).
There is nice documentation. And also one same question, but it was not answered because of inactivity of user. And documentation does not helped me.
I tried:
allowEmptyValue: true
at the level of object. But the message still contains example value. Of course, I tried also delete this value. Does not help.
Attribute definiton openapi 3.0.2:
LanguagePrefCode:
type: string
allowEmptyValue: true
example: en
description: Language preference code.
xml:
attribute: true
Message AS IS:
<?xml version="1.0" encoding="UTF-8"?>
<Request Code="Secret">
<Context Currency: "EUR" LanguagePrefCode="en">
</Context>
</Request>
Message TO BE:
<?xml version="1.0" encoding="UTF-8"?>
<Request Code="Secret">
<Context Currency: "EUR">
</Context>
</Request>
Also I tried:
required: false
But it should not be at the level of object definition. Context object has only one required attribute, which is currency. Can you please help me?

Related

swagger parameter - title overrides XML object for root object in schema

parameters:
- name: message
in: body
schema:
type: object
title: Ping_Request
xml:
name: message
in swagger ui the example for this would be
<?xml version="1.0"?>
<Ping_Request>
For nested objects it works ok (uses tag name from XML object, not from title for this object).
And for result schema root object it's also ok.
The problem for root object in body parameter only.
It was likely a bug in the Swagger UI version that you used. Version 3.0.5 renders the XML example with the correct root tag:
<?xml version="1.0" encoding="UTF-8"?>
<message>
</message>

Schema error with SalesForce wsdl

I have been working with an Apex class in SalesForce that has been working perfectly in terms of updating, generating the new WSDL and updating the reference in Visual Studio. Yesterday I added a new method and now I get an invalid schema error in VS when trying to update the reference. I tested the validaty of the WSDL here www.wsdl-analyzer.com and sure enough it gave me the error:
The reference ns1:ID in the XML Schema references a type or element that is not defined. Please make sure that your Schema documents are correct.
Looking at the xml file I can see that even in visual studio it doesnt like this particular line or several of the others as well:
<xsd:element name="CreatedById" minOccurs="0" type="ns1:ID" nillable="true"/>
The first few lines of the xml file look like (I've replaced parts with xxxx for privacy but they refer to the SF instance):
<?xml version="1.0" encoding="UTF-8"?>
<definitions targetNamespace="http://soap.sforce.com/schemas/class/xxxx" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://soap.sforce.com/schemas/class/xxxx" xmlns:AvailabilityExtended="http://soap.sforce.com/schemas/class/AvailabilityExtended" xmlns:BookingWrapper="http://soap.sforce.com/schemas/class/BookingWrapper">
<types>
<xsd:schema elementFormDefault="qualified" targetNamespace="http://soap.sforce.com/schemas/class/AvailabilityExtended">
Any suggestions?

open xml file with nokogiri update node and save

I'm trying to figure out how to open an xml file, search by an id, replace a value in the node and then resave the document.
my xml
<?xml version="1.0"?>
<data>
<user id="1370018670618">
<email>1#1.com</email>
<sent>false</sent>
</user>
<user id="1370018701357">
<email>2#2.com</email>
<sent>false</sent>
</user>
<user id="1370018769724">
<email>3#3.com</email>
<sent>false</sent>
</user>
<user id="1370028546850">
<email>4#4.com</email>
<sent>false</sent>
</user>
<user id="1370028588345">
<email>5#5.com</email>
<sent>false</sent>
</user>
</data>
My code to open and find a node
xml_content = File.read("/home/mike/app/users.xml")
doc = Nokogiri::XML(xml_content)
node_update = doc.search("//user[#id='1370028588345'] //sent")
node_update.inner_html ##returns value of "sent"
the part in this where I'm stuck is actually updating the node. node_update.inner_html = "true" returns a method error on inner_html. then after that saving the updated file.
First of all, your node_update is actually a NodeSet, not the Node that you probably think it is. You need a Node if you want to call inner_html= on it:
node_update[0].inner_html = 'true'
Then writing out the updated XML is just a bit of standard file manipulating combined with a to_xml call:
File.open('whatever.xml', 'w') { |f| f.print(doc.to_xml) }
As an aside, your input isn't valid XML. You have a </details> but no <details>.

Intuit anywhere API telling me that a field is required when it's already specified

I am trying to create an invoice in QB for windows. Here is the XML:
<?xml version='1.0' encoding='utf-8'?>
<Add xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.intuit.com/sb/cdm/v2" xsi:schemaLocation="http://www.intuit.com/sb/cdm/V2./RestDataFilter.xsd " RequestId="1836474224e142c9ad9b7dd6cb0eaa41" FullResponse="true">
<OfferingId>ipp</OfferingId>
<ExternalRealmId>596059545</ExternalRealmId>
<Invoice>
<Header>
<TxnDate>2013-01-30</TxnDate>
<DiscountAmt>0</DiscountAmt>
<ARAccountName>Sales - Support and Maintenance</ARAccountName>
<DiscountAccountName>Discounts/Refunds</DiscountAccountName>
<DueDate>2013-02-17</DueDate>
<Currency>USD</Currency>
<CustomerId>4</CustomerId>
</Header>
<Line>
<Qty>1</Qty>
<UnitPrice>7.00</UnitPrice>
<Desc>Follow-up Test, Instant for Person138-Org3 Person138-Org3</Desc>
</Line>
</Invoice>
</Add>
Here's the response:
-2001: cvc-complex-type.2.4.a: Invalid content was found starting with element 'ARAccountName'. One of '{"http://www.intuit.com/sb/cdm/v2":DiscountAccountId, "http://www.intuit.com/sb/cdm/v2":DiscountAccountName, "http://www.intuit.com/sb/cdm/v2":DiscountTaxable, "http://www.intuit.com/sb/cdm/v2":TxnId}' is expected.
I don't understand, as I already have DiscountAccountName specified. I also tried to go with something more like the create example (same as above but with ARAccountName and DiscountAccountName removed) and got a similar response. Thanks in advance for your help.
The Intuit XML requests are validated by an XSD, and with XML validated by XSDs the order of the tags you provide matters.
That means that if the documentation (https://ipp.developer.intuit.com/0010_Intuit_Partner_Platform/0050_Data_Services/0500_QuickBooks_Windows/0600_Object_Reference/Invoice) dictates that ARAccountName comes before DiscountAmt, then you must put ARAccountName before DiscountAmt.
Switch the order of your XML tags to match the order shown in the docs, and you'll be all set.

get hold of node from xml in jquery

If I have the following XML:
<?xml version="1.0" encoding="utf-8"?>
<response>
<status>SUCCESS</status>
<result>
<message>
<field>
<name>referenceNumber</name>
<type>string</type>
<required>true</required>
<max>8</max>
<min>0</min>
<decimal_places>0</decimal_places>
</field> ...
Is there a way to get the value for response/result/message? I know I can use a find("message") but if there are more than 1 message node then it doesn't work. I would like to know if there is a way to get to a particular node without 'guessing' if you know what I mean.
Thanks
you want to use find().each('message)` http://api.jquery.com/jQuery.each/ kinda like
`$(xml).find("listing").each(function (){
// Do stuff.
});

Resources