Search code examples
actionraml

How do you model an action in RAML


I would like to understand what is the best approach for modeling an action on a resource using RAML.

E.g. I have the following resource definition in RAML:

/orders:
  type: collection
  get:
    description: Gets all orders
  post:
    description: Creates a new order

  /{orderId}:
    type: element
    get:
      description: Gets a order

    put:
      description: Updates a order

    delete:
      description: Deletes a order

Now for an order I would like to model an "approve" action. Is there a best practice of doing this with RAML ?


Solution

    • You could PUT or PATCH for setting some "Approval" to true in your model.
    • You could think about the approval as a resource. For example:

      /orders:
        type: collection
        get:
        post:
        /{orderId}:
          type: element
          get:
          put:
          delete:
          /approval:
            post:
            get:
            ...
      

    It's not a RAML best practice. It's more related with how do you represent your model in REST.