Bird
0
0

How can you configure SpringDoc OpenAPI to serve the API docs JSON at a custom path like /custom-api-docs?

hard📝 Conceptual Q9 of 15
Spring Boot - API Documentation
How can you configure SpringDoc OpenAPI to serve the API docs JSON at a custom path like /custom-api-docs?
ARename the OpenAPI bean method to customApiDocs()
BCreate a controller that forwards /custom-api-docs to /v3/api-docs
CSet property springdoc.api-docs.path=/custom-api-docs in application.properties
DAdd @RequestMapping("/custom-api-docs") on the main application class
Step-by-Step Solution
Solution:
  1. Step 1: Know SpringDoc configuration properties

    SpringDoc supports customizing API docs path via springdoc.api-docs.path property.
  2. Step 2: Apply property in application.properties

    Setting springdoc.api-docs.path=/custom-api-docs changes the JSON docs endpoint accordingly.
  3. Step 3: Exclude incorrect methods

    Creating controllers or renaming bean methods does not affect the docs path; @RequestMapping on main class is unrelated.
  4. Final Answer:

    Set property springdoc.api-docs.path=/custom-api-docs in application.properties -> Option C
  5. Quick Check:

    Custom docs path = springdoc.api-docs.path property [OK]
Quick Trick: Use springdoc.api-docs.path to change docs URL [OK]
Common Mistakes:
  • Trying to forward requests manually
  • Renaming bean methods expecting path change
  • Using @RequestMapping on main class

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes