Skip to content

chore(api): add the base OpenAPI metadata config#423

Merged
zachyale merged 2 commits into
developfrom
chore/openapi-metadata-config
Apr 8, 2026
Merged

chore(api): add the base OpenAPI metadata config#423
zachyale merged 2 commits into
developfrom
chore/openapi-metadata-config

Conversation

@zachyale

@zachyale zachyale commented Apr 8, 2026

Copy link
Copy Markdown
Member

Description

This PR adds the base metadata config in for the openapi.json generation. This is the first step in adding more rich config details to our API docs. Now that #361 is in, we can begin refactoring SecurityConfig to surface auth schemes.

Linked Issue: #290

Changes

  • Mentions the API doc ref env var more in the README (was a note about not finding it easily enough)
  • Add OpenApiConfig to handle base config setup. Will be expanded on in a future commit to establish auth schemes
  • Added test coverage for the new config and to verify it is not accessible while API docs are disabled

Summary by CodeRabbit

  • New Features

    • API reference availability is now explicitly conditional on the API_DOCS_ENABLED environment setting.
  • Documentation

    • README clarified how API documentation availability is governed by configuration.
  • Tests

    • Added integration tests to confirm API documentation is published only when the configuration is enabled and omitted when disabled.

@coderabbitai

coderabbitai Bot commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 580e063a-ebc0-4598-a304-3c446279833f

📥 Commits

Reviewing files that changed from the base of the PR and between e2fb177 and 337274d.

📒 Files selected for processing (2)
  • booklore-api/src/main/resources/static/scalar.html
  • booklore-api/src/test/java/org/booklore/config/openapi/OpenApiConfigIntegrationTest.java
✅ Files skipped from review due to trivial changes (1)
  • booklore-api/src/main/resources/static/scalar.html
🚧 Files skipped from review as they are similar to previous changes (1)
  • booklore-api/src/test/java/org/booklore/config/openapi/OpenApiConfigIntegrationTest.java
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Test Suite / Frontend Tests
  • GitHub Check: Test Suite / Backend Tests
  • GitHub Check: Analyze (java-kotlin)

📝 Walkthrough

Walkthrough

A new Spring configuration class conditionally registers an OpenAPI bean when app.api-docs.enabled=true, populating metadata from application properties. Integration tests verify bean registration in enabled and disabled states. README wording was adjusted to clarify that API docs availability depends on the environment variable.

Changes

Cohort / File(s) Summary
Documentation
README.md
Clarified that API reference docs availability is conditional on the API_DOCS_ENABLED environment variable.
OpenAPI Configuration
booklore-api/src/main/java/org/booklore/config/openapi/OpenApiConfig.java
Added a conditional Spring @Configuration that provides an OpenAPI bean when app.api-docs.enabled=true, filling title, description, version (from AppProperties), contact, and license metadata.
Integration Tests
booklore-api/src/test/java/org/booklore/config/openapi/OpenApiConfigIntegrationTest.java, booklore-api/src/test/java/org/booklore/config/openapi/OpenApiDocsDisabledIntegrationTest.java
Added tests using ApplicationContextRunner to assert the OpenAPI bean is present and populated when enabled, and absent when disabled.
Static Asset
booklore-api/src/main/resources/static/scalar.html
Tweaked HTML title text from “Grimmory API Reference” to “Grimmory API”.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • imajes
  • balazs-szucs

Poem

🐰 I hopped through configs, neat and spry,
I bound up beans beneath the sky,
When enabled, docs will bloom and show,
When off, the silence lets things go,
I twitch my nose — tests passed — hip-hooray!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title follows conventional commit format with type 'chore' and scope 'api', and accurately describes the main change of adding base OpenAPI metadata configuration.
Description check ✅ Passed The description includes all required sections from the template: a clear explanation of what the PR does, a linked issue, and a detailed list of changes made.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/openapi-metadata-config
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch chore/openapi-metadata-config

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@booklore-api/src/test/java/org/booklore/config/openapi/OpenApiConfigIntegrationTest.java`:
- Around line 26-29: The test assertions in OpenApiConfigIntegrationTest refer
to values that don't match the OpenApiConfig implementation: update either the
test expectations or the OpenApiConfig values so they align. Specifically,
reconcile openAPI.getInfo().getDescription() (test expects "REST API for
managing..." but OpenApiConfig currently sets "REST API documentation for
managing...") and openAPI.getInfo().getContact().getName() (test expects
"Grimmory Maintainers" but OpenApiConfig sets "Grimmory"); choose one approach
and make both description and contact name consistent between OpenApiConfig and
the assertions (or update the assert strings in OpenApiConfigIntegrationTest to
match OpenApiConfig), keeping the version assertion unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 48b2665b-1d7a-4f6c-9852-57f712bd5c79

📥 Commits

Reviewing files that changed from the base of the PR and between 67fb707 and e2fb177.

📒 Files selected for processing (4)
  • README.md
  • booklore-api/src/main/java/org/booklore/config/openapi/OpenApiConfig.java
  • booklore-api/src/test/java/org/booklore/config/openapi/OpenApiConfigIntegrationTest.java
  • booklore-api/src/test/java/org/booklore/config/openapi/OpenApiDocsDisabledIntegrationTest.java
📜 Review details
🧰 Additional context used
📓 Path-based instructions (2)
booklore-api/src/**/*.java

📄 CodeRabbit inference engine (AGENTS.md)

booklore-api/src/**/*.java: Use 4-space indentation in Java files and match surrounding Java style
Prefer constructor injection via Lombok patterns already used in the codebase. Do not introduce @Autowired field injection
Use MapStruct for entity/DTO mapping

Files:

  • booklore-api/src/main/java/org/booklore/config/openapi/OpenApiConfig.java
  • booklore-api/src/test/java/org/booklore/config/openapi/OpenApiDocsDisabledIntegrationTest.java
  • booklore-api/src/test/java/org/booklore/config/openapi/OpenApiConfigIntegrationTest.java
booklore-api/src/test/**/*.java

📄 CodeRabbit inference engine (AGENTS.md)

Prefer focused unit tests; use @SpringBootTest only when the Spring context is required

Files:

  • booklore-api/src/test/java/org/booklore/config/openapi/OpenApiDocsDisabledIntegrationTest.java
  • booklore-api/src/test/java/org/booklore/config/openapi/OpenApiConfigIntegrationTest.java
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR
Repo: grimmory-tools/grimmory PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-26T01:46:48.863Z
Learning: Applies to booklore-api/src/test/**/*.java : Prefer focused unit tests; use `SpringBootTest` only when the Spring context is required
📚 Learning: 2026-03-26T01:46:48.863Z
Learnt from: CR
Repo: grimmory-tools/grimmory PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-26T01:46:48.863Z
Learning: Applies to booklore-api/src/test/**/*.java : Prefer focused unit tests; use `SpringBootTest` only when the Spring context is required

Applied to files:

  • booklore-api/src/test/java/org/booklore/config/openapi/OpenApiDocsDisabledIntegrationTest.java
  • booklore-api/src/test/java/org/booklore/config/openapi/OpenApiConfigIntegrationTest.java
🔇 Additional comments (4)
README.md (1)

200-202: LGTM!

The documentation clearly explains the conditional availability of API docs based on API_DOCS_ENABLED, which aligns with the implementation in OpenApiConfig.java.

booklore-api/src/main/java/org/booklore/config/openapi/OpenApiConfig.java (1)

13-33: Well-structured conditional configuration.

Good use of @RequiredArgsConstructor for constructor injection (per coding guidelines), and @ConditionalOnProperty correctly guards the bean registration. The matchIfMissing = false ensures the OpenAPI bean is only created when explicitly enabled.

booklore-api/src/test/java/org/booklore/config/openapi/OpenApiDocsDisabledIntegrationTest.java (1)

12-34: LGTM!

Good use of ApplicationContextRunner for a focused test without spinning up the full Spring context. The test correctly verifies that the OpenAPI bean is not registered when docs are disabled. Based on learnings: "Prefer focused unit tests; use SpringBootTest only when the Spring context is required."

booklore-api/src/test/java/org/booklore/config/openapi/OpenApiConfigIntegrationTest.java (1)

14-15: Good test structure using ApplicationContextRunner.

The use of ApplicationContextRunner with a minimal TestConfiguration providing the required AppProperties dependency is the right approach for testing conditional configuration without a full Spring context.

Also applies to: 38-47

@zachyale zachyale merged commit 5973074 into develop Apr 8, 2026
14 checks passed
@zachyale zachyale deleted the chore/openapi-metadata-config branch April 8, 2026 12:16
zachyale added a commit to zachyale/grimmory that referenced this pull request Apr 17, 2026
zachyale added a commit to zachyale/grimmory that referenced this pull request Apr 17, 2026
dsmouse pushed a commit to dsmouse/grimmory that referenced this pull request May 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants