Skip to content

Add grails-rest-library v8 guide (rename of rest-hibernate)#496

Merged
jamesfredley merged 1 commit intomasterfrom
add-grails-rest-library-v8
May 3, 2026
Merged

Add grails-rest-library v8 guide (rename of rest-hibernate)#496
jamesfredley merged 1 commit intomasterfrom
add-grails-rest-library-v8

Conversation

@jamesfredley
Copy link
Copy Markdown
Contributor

Summary

Adds the A Library REST API with Grails 8 guide as the fifth Grails 8 sample-app-flavour guide, following PRs #479, #493, #494, #495.

A worked Book + Author REST API focused on the production-quality concerns most beginner REST guides skip: structured 422 validation responses with stable codes, bounded pagination (page size hard-capped at 100), all-or-nothing bulk create, URL-prefix versioning under /v1/, and HAL-style _links in the JSON views.

Companion conf/guides.yml change (rename of upstream repo)

The upstream repo grails-guides/rest-hibernate was renamed to grails-guides/grails-rest-library to match the sharper topic of the new guide. GitHub auto-redirects keep historical clones working; this PR repoints both v3 and v4 sampleRef.repo lines (lines 4447 and 4484) at the new canonical name. The original grails3, grails4, grails-4, and master branches are preserved on the renamed repo so the historical guides continue to resolve. The grails-guides/rest-mongodb repo is left alone - it covers a different stack and is not in scope.

What's in the PR

  • conf/guides.yml - new grails-rest-library registry entry plus the two repo-name updates on the existing v3 and v4 entries.
  • guides/grails-rest-library/v8/guide/*.adoc - 17 chapters.
  • guides/grails-rest-library/v8/snippets/ - vendored Author + Book domains, UrlMappings, AuthorController + BookController, six .gson views (paired _partial.gson + index.gson + show.gson), and BootStrap.

Upstream sample app

grails-guides/grails-rest-library on the grails8 branch contains the standard initial/ + complete/ layout. initial/ is the vanilla forge output (rest_api type with postgres, testcontainers, views-json, database-migration features). complete/ adds the Library API layer.

Verification

  • ./gradlew validateGuides -PvalidationMode=both returns 86 guides, 0 errors.
  • ./gradlew renderGuide_grails_rest_library_8 --rerun-tasks --no-configuration-cache renders all 17 chapter HTML pages, no Unresolved directive errors.

Notes for reviewers

  • This is the fourth Grails 8 PR that intentionally renames a grails-guides/* repo to a sharper name (after the Tailwind, Docker, and CI/CD PRs). Same pattern: GitHub auto-redirects, conf/guides.yml repointed, original branches preserved.
  • The chapter on bulk create demonstrates transactionStatus.setRollbackOnly() so the failing-batch case really does roll back every persisted entry; it is the safest semantic for a typed API.
  • The chapter on versioning intentionally leads with URL-prefix (/v1/) and recommends starting there; content negotiation is mentioned but not the primary recipe.

Worked example for a Book + Author REST API on Grails 8: RestfulController-
based CRUD, JSON views (.gson) with HAL-style _links, structured 422
validation responses with stable error codes, bounded pagination
(max hard-capped at 100), URL-prefix versioning under /v1/, and an
all-or-nothing bulk create endpoint.

Companion conf/guides.yml change repoints the existing v3 and v4 entries
from grails-guides/rest-hibernate to grails-guides/grails-rest-library
(rename of the upstream repo). The old grails3, grails4, grails-4, master
branches are preserved on the renamed repo so the historical guides
keep resolving. The grails-guides/rest-mongodb repo is left alone (it
covers a different stack).

The 17 chapters cover:

- Getting Started (whatYouWillBuild, requirements, howto)
- Creating the Application (download via the rest_api forge type)
- Domain Model (Book + Author with realistic constraints, lazy loading
  to head off N+1, bootstrap sample data)
- URL Mappings and v1 Versioning (resources mapping + nested collection
  routes for bulk create)
- RestfulController with a Hard Page Cap (listAllResources override)
- JSON Views (.gson partial + index + show pattern)
- Structured 422 Validation Responses (stable field/code/message shape)
- Pagination, Sorting, Filtering (max/offset/sort/order)
- All-or-Nothing Bulk Create (transactionStatus.setRollbackOnly)
- URL-Prefix vs Content-Negotiation Versioning
- Running the Application (curl smoke tests for every endpoint)

Verified locally:

  ./gradlew validateGuides -PvalidationMode=both
    [validateGuides] mode=both: 86 guide(s) parsed, 0 SKIP-warned, 0 errors

  ./gradlew renderGuide_grails_rest_library_8 --rerun-tasks --no-configuration-cache
    Renders all 17 chapter HTML pages, no Unresolved directive errors.

The mode=both pass also confirms grails-guides/grails-rest-library
exists on grails3, grails4, and grails8 branches - i.e. the upstream
rename and the new branch are intact.

Assisted-by: claude-code:claude-opus-4-7
Copilot AI review requested due to automatic review settings May 3, 2026 19:41
@jamesfredley jamesfredley merged commit d7cd9d7 into master May 3, 2026
5 checks passed
@jamesfredley jamesfredley deleted the add-grails-rest-library-v8 branch May 3, 2026 19:42
@jamesfredley jamesfredley review requested due to automatic review settings May 3, 2026 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant