Rest Webservices Api Docs.

Hello devs, It appears that some of the Rest End Points configured in modules don’t appear in the webservice RestApi docs via the legacy ui for example this ActiveVisit EndPoint in EMR-API but yet personImage End point in EMR-API does. My question: what is the criteria for an end point to make it to the docs. Is it when it is configured as a resource which would mean you have that bean for that resource that is persisted to the db? @dkayiwa @mksd @ssmusoke

1 Like

@reagan for an end point to appear in the openmrs swagger spec then it has to implement the Model getGETModel(Representation) , Model getCREATEModel(Representation), Model getUPDATEModel(Representation) methods depending on what CRUD operations its supporting.

Kindly have a look at this to https://wiki.openmrs.org/display/docs/Documenting+REST+Resources

2 Likes

Spot on …Thanks @gcliff

2 Likes

Thanks for bringing this up @reagan , i have been researching about this error ticket, which i have not yet figured out where these error comes from. it has been there since 2017.I would think , while they were creating swaggerspecificationCreator.java in webservices.rest could have arose this error definition,@reagan @gcliff ,have you taken a look at that error

1 Like

@sharif those errors are usually generated when an expected method is not defined in your resource…Havent looked deep into the code to see how the module scans them and handles the NPE which I think is the TO DO of the ticket…Nice coding and u continue researching it

1 Like

@reagan Thanks , You are right this was defined in webservices.rest, however am still looking through it

hello @sharif i would suggest that you have a deeper look in to the comments that @tomtom5152 made about his initial findings on the source of the errors …

Also have a look at this thread and this commit

2 Likes

Thanks @gcliff that was my initial links i followed though still researching where the problem could be.

Turning back to this: I seem to be able to archieve this pattern pretty well when creating a REST end point of a core Object, However I have a followup question. Is this still possible to reflect my endpoint in live docs when am writing an endpoint that is not based entirely on one core Object.such as this end point? @dkayiwa @ibacher @ssmusoke

Did you try it out?

@dkayiwa I couldnt think of a way to do it…So am wondering if it is possible anyway…

https://wiki.openmrs.org/display/docs/Adding+a+Web+Service+Step+by+Step+Guide+for+Module+Developers

@dkayiwa The problem here is that we have a custom end-point which we would like to add to the swagger documentation. The underlying resource is concepts, and is a query, however we do not want to use the concept list as that will bring a performance penalty.

We just want to return the count of obs that contain the specified obs value.

On additional thoughts is there a performant way of returning the count of results for a GET call for a list of resources?

1 Like