jeudi 20 décembre 2018

Different types in one API request field

I have an API endpoints:

GET /configurations
GET /configurations/{id}
PUT /configurations/{id}
POST /configurations
DELETE /configurations/{id}

GET request returns a list(or one item) of:

  • some fields
  • a field called "trigger"

Now the problem is that the "trigger" can be of different types. It can return a string "daily", or an object, or a date and possibly more in the future.

How to structure the endpoint so it follows the best practices?

Should there be "triggerType" and "triggerMetadata" fields on the top of the structure?

Should it be separated entirely? (If so then how to do a POST request?)

Aucun commentaire:

Enregistrer un commentaire