Adding new APIs


I have been exploring OpenLMIS application on my Ubuntu machine and it is working fine at my local.
But, whenever I added new APIs in my referencedata-service and redeployed, none of those APIs could be hit(Every time I was getting 404 not found error but all other APIs were working fine). After digging much and applying several patches I found that I need to mention those APIs within api-definition.yaml file.

Why this is mandatory?
Is this mandatory for all services or just for the reference-data-service?
Which configuration should be updated to disable this functionality?

Any help would be appreciated.

Hi @jimesh.shah,

It’s mandatory for two reasons:

  1. Because we made an architecture decision that all API access should be formally defined through an IDL. We’re currently using RAML.
  2. To further decouple the UI from the implementation details of the backend services, there is a router which handles the public path mapping to a specific back-end service. Put another way, the architecture says that there shouldn’t be a way to address a specific type of service nor a specific instance of a service publicly. See openlmis-nginx for more documentation.

All services, it’s part of the architecture.

There isn’t as this is part of the architecture. Since it’s 2020 and things have changed since these architecture decisions were made, there are good reasons to revisit them. However by and large these don’t cause major issues that I’m aware of. Now that you have the hang of it, write the RAML for the API first, then provide the code that’ll serve it. And of course testing is important. The service’s tooling and the rest of the infrastructure will take care of the registration, routing, etc.