Reputation: 19880
PROBLEM I use Spring Rest Docs in my project. It is useful at development stage, but i don't want it to be available for ordinary users and search engines in production.
RESEARCH I see no robot meta tags with content like "nocache" & "noindex". What is expected actually is maybe a spring application.property field like spring.rest-docs.enabled=false
. So that I can configure it in production spring profile.
QUESTION How to disable rest docs for some spring profiles.
Upvotes: 0
Views: 648
Reputation: 1925
You can add this property to your application.properties
spring.test.restdocs.failOnUndocumentedFields=false
spring.test.restdocs.failOnUndocumentedParams=false
https://scacap.github.io/spring-auto-restdocs/#_configuration
Configuration available during MockMvc setup:
failOnUndocumentedParams - if build should fail on at least one undocumented parameter failOnUndocumentedFields - if build should fail on at least one undocumented field
Upvotes: 0
Reputation: 19880
There were three ways to do it:
@IfProfileValue(name = "spring.profiles.active", values = {"prod"})
or @EnabledIf("${spring.restdocs.enabled}")
/resources/static
folder access in application-prod.properties
with spring.resources.add-mappings=false
Upvotes: 1