CollectOutputFileds ION API method
This ION API method analyzes a JSON token returned by an API response in conjunction with a Swagger document to collect output filed definitions. This method resolves $ref references within the schema, detects and handles circular references, and returns the resulting field definitions as serialized JSON list of ResponseProperties.
Example
Parameter pattern:
0 JTokenString1 SwaggerDocument2 SuiteContextValue3 ProxyPathValue4 RestMethodPathValue5 RootElementValue6 CircularReferenceValue7 CollectedFields8 Infobar
Return:
0 = Success, 16 = Error
public int CollectOutputFields( string jtokenString,
string swaggerDocument,
string suiteContextValue,
string proxyPathValue,
string restMethodPathValue,
ref string rootElementValue,
ref string circularReferenceValue,
ref string collectedFields,
ref string infobar )
{
try
{
swaggerDoc = swaggerDocument;
isCustomerApi = suiteContextValue.Contains( "CustomerApi" );
suiteCtx = GetSuiteContext( suiteContextValue );
proxyPath = proxyPathValue;
restMethodPath = restMethodPathValue;
rootElement = rootElementValue;
reference = new List<string>();
circularReference = new List<string>();
fields = new List<ResponseProperties>();
JToken jToken = JToken.Parse( jtokenString );
CollectFields( jToken );
collectedFields = JsonConvert.SerializeObject( fields );
rootElementValue = rootElement;
circularReferenceValue = JsonConvert.SerializeObject( circularReference );
}
catch ( System.Exception e )
{
infobar = e.Message;
return (int)StdMethodResult.StandardError;
}
return (int)StdMethodResult.Success;
}