Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Is there a way to obtain the schema of the response body of Web APIs?

There was a relevant thread to my question, however it was left hanging a little, so I decided to post this question again. In addition to what was attempted, I also tried using openapi-typescript to try to derive the response body schema, but was unable to do so. 

As part of our use case, we need to know the fields that are guaranteed to be returned / optional from different endpoints. Is there a way to derive the response body schema type? Thanks!

Best Answer
0 Votes
3 REPLIES 3

Hi @lyqht 

 

In the description of each endpoint, we have displayed the schema.   For example, see https://dev.fitbit.com/build/reference/web-api/activity/get-activity-goals/#Response.  Does this give you the information you need?

 

Gordon

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer
0 Votes

Hi @Gordon-C , yes we have been manually writing typescript interfaces based on the response section in the Web API Docs. This is because when I import fitbit web api swagger.json into postman, no response examples are not documented on swagger directly, so we couldn't generate the types off the API docs. However, this has been inefficient and also insufficient because we might miss out which fields are nullable e.g. Get Daily Activity Summary End point's response has possibly nullable fields such as heartRateZones, elevation, and these facts are only briefly mentioned in additional notes where it could be due to device limitations or scopes. They should be included as part of the schema description itself. 

 

For our use case, we are performing data ingestion in a way where we have to validate every field in the object, so it is necessary for us to know which fields are nullable.

Best Answer
0 Votes

Hi @lyqht 

 

We have an enhancement to update the swagger documentation and the json file.   I'll see what we can do to expand on the information in the json file based on the specification.   If there is anything specific you're looking for, please point it out the information in the swagger documentation (swagger.io).

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer
0 Votes