001/*
002 * Copyright 2012-2017 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.boot.test.autoconfigure.restdocs;
018
019import java.lang.annotation.Documented;
020import java.lang.annotation.ElementType;
021import java.lang.annotation.Inherited;
022import java.lang.annotation.Retention;
023import java.lang.annotation.RetentionPolicy;
024import java.lang.annotation.Target;
025
026import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
027import org.springframework.boot.test.autoconfigure.properties.PropertyMapping;
028import org.springframework.context.annotation.Import;
029import org.springframework.core.annotation.AliasFor;
030
031/**
032 * Annotation that can be applied to a test class to enable and configure
033 * auto-configuration of Spring REST Docs. Allows configuration of the output directory
034 * and the host, scheme, and port of generated URIs. When further configuration is
035 * required a {@link RestDocsMockMvcConfigurationCustomizer} bean can be used.
036 *
037 * @author Andy Wilkinson
038 * @since 1.4.0
039 * @see RestDocsAutoConfiguration
040 * @see RestDocsMockMvcConfigurationCustomizer
041 */
042@Target(ElementType.TYPE)
043@Retention(RetentionPolicy.RUNTIME)
044@Documented
045@Inherited
046@ImportAutoConfiguration
047@Import(RestDocumentationContextProviderRegistrar.class)
048@PropertyMapping("spring.test.restdocs")
049public @interface AutoConfigureRestDocs {
050
051        /**
052         * The output directory to which generated snippets will be written. An alias for
053         * {@link #outputDir}.
054         * @return the output directory
055         */
056        @AliasFor("outputDir")
057        String value() default "";
058
059        /**
060         * The output directory to which generated snippets will be written. An alias for
061         * {@link #value}.
062         * @return the output directory
063         */
064        @AliasFor("value")
065        String outputDir() default "";
066
067        /**
068         * The scheme (typically {@code http} or {@code https}) to be used in documented URIs.
069         * Defaults to {@code http}.
070         * @return the scheme
071         */
072        String uriScheme() default "http";
073
074        /**
075         * The host to be used in documented URIs. Defaults to {@code localhost}.
076         * @return the host
077         */
078        String uriHost() default "localhost";
079
080        /**
081         * The port to be used in documented URIs. Defaults to {@code 8080}.
082         * @return the port
083         */
084        int uriPort() default 8080;
085
086}