Ask a Question

Ask a Question
Back to All

Is there a way to push out json output instead of string or bool based output on the microservices auto generated swagger

this is a current example public async Task GetActiveCurrencyId()
{
var inventoryView = await Services.Inventory.GetCurrent();
if (inventoryView.currencies.Count > 0)
{
KeyValuePair<string, long> firstCurrency = inventoryView.currencies.FirstOrDefault();
return firstCurrency.Key;
}
return "";
}

but I would like to do something like this

public async Task GetJsonActiveCurrencyId()
{
string currencyId = await GetActiveCurrencyId();

string jsonCurrencyId = JsonConvert.SerializeObject(new { CurrencyId = currencyId });

return jsonCurrencyId;
} //output {
"CurrencyId": "currencyIdValue"
}

but the microservice seems to break soon as I add in newtonsoft to the microservice file, is there way I can get around this issue