Skip to content

Spring Data Rest: No model for Paged Collection #1083

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mathias-ewald opened this issue Mar 2, 2021 · 0 comments
Closed

Spring Data Rest: No model for Paged Collection #1083

mathias-ewald opened this issue Mar 2, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@mathias-ewald
Copy link

Describe the bug
When I extend JpaRepository or PagingAndSortingRepository, the collection model returned in a GET to the endpoint contains pagination data in addition to the collection of entity models. Instead a CollectionModelEntityModel* is referenced as the schema which does not include the pagination data.

To Reproduce
Spring Boot: 2.4.3
Springdoc: 1.5.5

@Entity
@Data
...
public class Pet extends BaseEntity {
	...
}

public interface PetRepo extends JpaRepository<Pet, UUID> {}
  /pets:
    get:
      ...
      responses:
        "200":
          description: OK
          content:
            application/hal+json:
              schema:
                $ref: '#/components/schemas/CollectionModelEntityModelPet'
            application/x-spring-data-compact+json:
              schema:
                $ref: '#/components/schemas/CollectionModelEntityModelPet'
            text/uri-list:
              schema:
                $ref: '#/components/schemas/CollectionModelEntityModelPet'
...
    CollectionModelEntityModelPet:
      type: object
      properties:
        _embedded:
          type: object
          properties:
            pets:
              type: array
              items:
                $ref: '#/components/schemas/EntityModelPet'
        _links:
          $ref: '#/components/schemas/Links'

Expected behavior
A PagedCollectionModelEntityModelPet should be generated that matches the following schema

{
  "_embedded" : {
    "pets" : [ ... ]
  },
  "_links" : {
    ...
  },
  "page" : {
    "size" : 20,
    "totalElements" : 8,
    "totalPages" : 1,
    "number" : 0
  }
This was referenced Mar 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants