byoungman
3 years agoFrequent Visitor
Response Object Question
Good Morning,
I am new to Swagger and am currently working on documenting an API that I just developed for my company. My question concerns the swagger.yaml Responses object.
The return response from my api is a nested json object - see sample below. I'm thinking I should use schema => type: array but not exactly sure how to detail this in the yaml file.
Sample Response JSON:
{
"results":{
"value0":"Company One",
"matches0":[
{
"matchedNameId":"2861495",
"matchedName":"Company One Inc",
"certainty":"1.0",
"duns":"xxxxx",
"parentDuns":"yyyy",
"annualRevenue":"$1,797,531.80",
"country":"United States",
"crsCode":"4",
"location":"United States",
"naics":"xxxx"
}
],
"value1":"Company Two Inc.",
"matches1":[
{
"matchedNameId":"3423310",
"matchedName":"Company Two Inc",
"certainty":"1.0",
"duns":"xxxx",
"parentDuns":"",
"annualRevenue":"$1,646,675.00",
"country":"United States",
"crsCode":"xx",
"location":"",
"naics":"xxxx"
}
],
"metrics":{
"Total time for run (Total Seconds)":"1.269741",
"Average Query Time (seconds)":"0.0015",
"Total Rows Processed":"15",
"Highest Row Count":"9",
"Average Row Count":"7.5",
"Highest matching index":"8",
"Average index":"1.7",
"Total Num Errors":"0",
"Total Strings To Match":"2",
"Total Matches":"30"
}
}
}
swagger.yaml setting
responses:
'200':
description: OK
content:
'application/json:':
schema:
type: array
items:
type: string
This block doesn't seem to be correct but I'm not sure what it should be.
Thanks,
Bill