Commit 2fd51dd8 authored by Andy Wilkinson's avatar Andy Wilkinson

Upgrade to Spring REST Docs 1.2.0.RC1

Closes gh-8716
parent 5e0acc60
......@@ -167,7 +167,7 @@
<spring-loaded.version>1.2.7.RELEASE</spring-loaded.version>
<spring-mobile.version>2.0.0.M1</spring-mobile.version>
<spring-plugin.version>1.2.0.RELEASE</spring-plugin.version>
<spring-restdocs.version>1.2.0.BUILD-SNAPSHOT</spring-restdocs.version>
<spring-restdocs.version>1.2.0.RC1</spring-restdocs.version>
<spring-retry.version>1.2.0.RELEASE</spring-retry.version>
<spring-security.version>5.0.0.BUILD-SNAPSHOT</spring-security.version>
<spring-security-jwt.version>1.0.7.RELEASE</spring-security-jwt.version>
......
......@@ -5770,7 +5770,7 @@ remove the need for Spring REST Docs' JUnit rule.
@RunWith(SpringRunner.class)
@WebMvcTest(UserController.class)
@AutoConfigureRestDocs("target/generated-snippets")
@AutoConfigureRestDocs
public class UserDocumentationTests {
@Autowired
......@@ -5786,10 +5786,11 @@ remove the need for Spring REST Docs' JUnit rule.
}
----
In addition to configuring the output directory, `@AutoConfigureRestDocs` can also
configure the host, scheme, and port that will appear in any documented URIs. If you
require more control over Spring REST Docs' configuration a
`RestDocsMockMvcConfigurationCustomizer` bean can be used:
`@AutoConfigureRestDocs` can be used to override the default output directory
(`target/generated-snippets` if you are using Maven or `build/generated-snippets` if you
are using Gradle). It can also be used to configure the host, scheme, and port that will
appear in any documented URIs. If you require more control over Spring REST Docs'
configuration a `RestDocsMockMvcConfigurationCustomizer` bean can be used:
[source,java,indent=0]
----
......
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -18,12 +18,12 @@ package org.springframework.boot.test.autoconfigure.restdocs;
import java.util.Map;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.restdocs.ManualRestDocumentation;
import org.springframework.util.StringUtils;
/**
* {@link ImportBeanDefinitionRegistrar} used by {@link AutoConfigureRestDocs}.
......@@ -38,12 +38,14 @@ class RestDocumentationContextProviderRegistrar implements ImportBeanDefinitionR
BeanDefinitionRegistry registry) {
Map<String, Object> annotationAttributes = importingClassMetadata
.getAnnotationAttributes(AutoConfigureRestDocs.class.getName());
BeanDefinitionBuilder definitionBuilder = BeanDefinitionBuilder
.genericBeanDefinition(ManualRestDocumentation.class);
String outputDir = (String) annotationAttributes.get("outputDir");
AbstractBeanDefinition beanDefinition = BeanDefinitionBuilder
.genericBeanDefinition(ManualRestDocumentation.class)
.addConstructorArgValue(outputDir).getBeanDefinition();
if (StringUtils.hasText(outputDir)) {
definitionBuilder.addConstructorArgValue(outputDir);
}
registry.registerBeanDefinition(ManualRestDocumentation.class.getName(),
beanDefinition);
definitionBuilder.getBeanDefinition());
}
}
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -47,7 +47,7 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
*/
@RunWith(SpringRunner.class)
@WebMvcTest(controllers = RestDocsTestController.class, secure = false)
@AutoConfigureRestDocs("target/generated-snippets")
@AutoConfigureRestDocs
public class RestDocsAutoConfigurationAdvancedConfigurationIntegrationTests {
@Before
......
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -40,7 +40,7 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
*/
@RunWith(SpringRunner.class)
@WebMvcTest
@AutoConfigureRestDocs(outputDir = "target/generated-snippets", uriScheme = "https", uriHost = "api.example.com", uriPort = 443)
@AutoConfigureRestDocs(uriScheme = "https", uriHost = "api.example.com", uriPort = 443)
public class RestDocsAutoConfigurationIntegrationTests {
@Before
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment