cancerDHC / ccdh-terminology-service

CCDH Terminology and Mapping Service
3 stars 4 forks source link

Swagger Docs: Add params to the swagger docs request URI #139

Open joeflack4 opened 2 years ago

joeflack4 commented 2 years ago

Description

In the swagger documentation UI, each endpoint automatically has at least two links: (1) a link to the part of the swagger interface for the given endpoint, and (2) a link to get a raw response from the API. Regarding (2), the swagger link that is generated will automatically include the parameters and their values that the user has provided in the swagger interface. It would be nice if the same params and their values coulda also be populated into the link referred to in (1).

To do this, we'd need to at least do 2 things: (i) generate the URL (ii) resolve these URLs

There is a way to do this, it appears, but it would require some time. For (ii), a way to resolve is outlined here: https://stackoverflow.com/questions/31056771/swagger-ui-url-with-parameters

This answer involves some JavaScript. The main issue here is that the swagger docs are auto-generated by FastAPI. So it's not as simple as updating a single file with some JavaScript. This edit would likely have to be a hack around the FastAPI auto-generation. That is the main issue. After solving that, we could use the advice in the stackoverflow article to handle (ii). For (i), we could also likely solve that with some custom JavaScript.

joeflack4 commented 2 years ago

@gaurav @turbomam Just sharing w/ you guys as an FYI. Hopefully what I wrote here makes sense. I looked into improving the URLs generated by in the docs / swagger UI, and this is what I've found / determined so far.