teunmooij / payload-tools

Collection of payload plugins and tools: payload-openapi, payload-swagger, create-payload-api-docs, payload-rbac
https://github.com/teunmooij/payload-tools/#readme
MIT License
101 stars 12 forks source link

Refactoring/hpp 00 refactor paginated documents #85

Closed lukyfebrianto closed 6 months ago

lukyfebrianto commented 6 months ago

Refactor: Paginated documents creation model

before:

      properties:
        docs:
          items:
            $ref: "#/components/schemas/<schemaName>"
          type: array
        totalDocs:
          type: number
        limit:
          type: number
        totalPages:
          type: number
        page:
          type: number
        pagingCounter:
          type: number
        hasPrevPage:
          type: boolean
        hasNextPage:
          type: boolean
        prevPage:
          type: number
        nextPage:
          type: number
      required:
        - docs
        - hasNextPage
        - hasPrevPage
        - limit
        - page
        - pagingCounter
        - totalDocs
        - totalPages
      title: Users
      type: object

after:

      allOf:
        - $ref: "#/components/schemas/paginatedDocument"
        - properties:
            docs:
              items:
                $ref: "#/components/schemas/<schemaName>"
              type: array
          required:
            - docs
      type: object