Skip to content
This repository has been archived by the owner on Feb 17, 2024. It is now read-only.

A reusable 'pageable' trait that can allow reuse of query parameters and result #773

Open
marke-apexit opened this issue Oct 25, 2022 · 0 comments

Comments

@marke-apexit
Copy link

I have been trying to figure out how to leverage traits to implement a reusable 'paging' trait.

I understand how to introduce the query parameters for a reusable 'pageable' definition for GET operations:

traits: 
  pageable: 
    queryParameters:
      offset?:
        type: integer
        default: 0
        minimum: 0
        required: false
      limit?:
        type: integer
        default: 50
        minimum: 1
        maximum: 500
        required: false

However, I also need to return paging result information in each result that supports the pageable trait. Something like the example below where the "paging" object is inserted in the JSON result.

{
  "items": [
     { "foo": "xyzzy",
        "bar": "plugh"
     },
     { "foo": "plover" }
  ],
  
  "pagingInfo": {
    "count": 2,
    "hasMore": false,
    "limit": 50,
    "offset": 0,
  }
}

Is there any way in RAML to create a reusable 'pageable specfication that can be reused across all of my GET operations for both the query parameters and the paging info results?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

1 participant