Skip to content

Spring Data REST API

Overview

Gustaffo Reservations utilizes Spring Data REST to expose certain repositories as RESTful resources with hypermedia support (HATEOAS). These endpoints provide standardized access to data entities with built-in pagination, sorting, and filtering capabilities.

Base Path

All Spring Data REST endpoints are prefixed with /api

Authentication

Access to Spring Data REST endpoints requires authentication with appropriate permissions based on the resource.

HATEOAS Features

The Spring Data REST API implements HATEOAS (Hypermedia as the Engine of Application State) principles, providing:

  • Self-descriptive responses with links to related resources
  • Consistent resource representations
  • Discoverability through hypermedia controls
  • Standard pagination and sorting

Available Repositories

Salutations Repository

Base Path: /api/salutations

Provides access to salutation options for user interfaces.

Key Operations: - List all salutations - Retrieve specific salutation by ID - Search salutations by criteria

Greetings Repository

Base Path: /api/greetings

Manages title greetings for communications.

Key Operations: - List all greetings - Retrieve specific greeting by ID - Search greetings by criteria

Feature Toggle Repository

Base Path: /api/featureToggles

Manages system-wide feature toggles with custom projection support.

Key Operations: - List all feature toggles - Retrieve specific feature toggle by ID - Create and update feature toggles - Toggle feature activation status

Property Feature Toggle Repository

Base Path: /api/propertyFeatureToggles

Manages property-specific feature toggles with custom projection support.

Key Operations: - List all property feature toggles - Retrieve specific property feature toggle by ID - Create and update property feature toggles - Filter toggles by property

Ticket Repository

Base Path: /api/tickets

Manages support tickets within the system.

Key Operations: - List all tickets - Retrieve specific ticket by ID - Create and update tickets - Filter tickets by status

Ticket Guest Repository

Base Path: /api/ticketGuests

Manages guest associations with support tickets.

Key Operations: - List all ticket guests - Retrieve specific ticket guest by ID - Create and update ticket guest associations - Filter by ticket or guest

Custom Projections

Some repositories use custom projections to optimize data retrieval:

  • FeatureToggleProjection: Streamlined view of feature toggles
  • PropertyFeatureToggleProjection: Property-specific feature toggle view

Resource Operations

Standard operations supported across all repositories:

GET Collection

Retrieve a collection of resources with pagination, sorting, and filtering.

Example: GET /api/featureToggles?page=0&size=20&sort=name,asc

Response:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{
  "_embedded": {
    "featureToggles": [
      {
        "name": "enableNewBookingUI",
        "enabled": true,
        "_links": {
          "self": { "href": "http://api.gustaffo.com/api/featureToggles/1" },
          "featureToggle": { "href": "http://api.gustaffo.com/api/featureToggles/1" }
        }
      }
    ]
  },
  "_links": {
    "self": { "href": "http://api.gustaffo.com/api/featureToggles" },
    "profile": { "href": "http://api.gustaffo.com/api/profile/featureToggles" }
  },
  "page": {
    "size": 20,
    "totalElements": 1,
    "totalPages": 1,
    "number": 0
  }
}

GET Single Resource

Retrieve a specific resource by ID.

Example: GET /api/featureToggles/1

Response:

1
2
3
4
5
6
7
8
9
{
  "name": "enableNewBookingUI",
  "enabled": true,
  "description": "Enables the new booking UI",
  "_links": {
    "self": { "href": "http://api.gustaffo.com/api/featureToggles/1" },
    "featureToggle": { "href": "http://api.gustaffo.com/api/featureToggles/1" }
  }
}

POST Create Resource

Create a new resource.

Example: POST /api/featureToggles

Request Body:

1
2
3
4
5
{
  "name": "enableNewPaymentGateway",
  "enabled": false,
  "description": "Enables the new payment gateway integration"
}

PUT/PATCH Update Resource

Update an existing resource (full or partial update).

Example: PATCH /api/featureToggles/1

Request Body:

1
2
3
{
  "enabled": true
}

DELETE Resource

Delete a resource.

Example: DELETE /api/featureToggles/1

Search Operations

Spring Data REST automatically exposes repository query methods as search resources.

Example: GET /api/featureToggles/search/findByEnabled?enabled=true

Integration with Core API

The Spring Data REST API complements the core API by providing:

  • Standardized access to data entities
  • Consistent pagination and sorting
  • Hypermedia controls for navigation
  • Automatic exposure of repository functionality

HAL Browser

For interactive exploration of the API, a HAL Browser is available at: /api/browser/index.html

This browser allows developers to navigate the API, view documentation, and test endpoints directly.

Back to top