Merge branch 'gh-119'
This commit is contained in:
38
build.gradle
38
build.gradle
@@ -47,7 +47,6 @@ subprojects {
|
||||
apply plugin: 'propdeps-eclipse'
|
||||
apply plugin: 'propdeps-maven'
|
||||
apply plugin: 'maven'
|
||||
apply from: "${rootProject.projectDir}/gradle/publish-maven.gradle"
|
||||
|
||||
sourceCompatibility = 1.7
|
||||
targetCompatibility = 1.7
|
||||
@@ -72,6 +71,34 @@ subprojects {
|
||||
}
|
||||
}
|
||||
|
||||
test {
|
||||
testLogging {
|
||||
exceptionFormat "full"
|
||||
}
|
||||
}
|
||||
|
||||
eclipseJdt {
|
||||
inputFile = rootProject.file('config/eclipse/org.eclipse.jdt.core.prefs')
|
||||
doLast {
|
||||
project.file('.settings/org.eclipse.jdt.ui.prefs').withWriter { writer ->
|
||||
writer << rootProject.file('config/eclipse/org.eclipse.jdt.ui.prefs').text
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
configure(subprojects - project(":docs")) { subproject ->
|
||||
|
||||
apply plugin: 'checkstyle'
|
||||
apply from: "${rootProject.projectDir}/gradle/publish-maven.gradle"
|
||||
|
||||
checkstyle {
|
||||
configFile = rootProject.file('config/checkstyle/checkstyle.xml')
|
||||
configProperties = [ 'checkstyle.config.dir' : rootProject.file('config/checkstyle') ]
|
||||
toolVersion = '6.10.1'
|
||||
}
|
||||
|
||||
configurations {
|
||||
jacoco
|
||||
}
|
||||
@@ -80,12 +107,6 @@ subprojects {
|
||||
jacoco 'org.jacoco:org.jacoco.agent::runtime'
|
||||
}
|
||||
|
||||
test {
|
||||
testLogging {
|
||||
exceptionFormat "full"
|
||||
}
|
||||
}
|
||||
|
||||
javadoc {
|
||||
description = "Generates project-level javadoc for use in -javadoc jar"
|
||||
options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED
|
||||
@@ -96,9 +117,6 @@ subprojects {
|
||||
options.addStringOption '-quiet'
|
||||
}
|
||||
|
||||
eclipseJdt.onlyIf { false }
|
||||
cleanEclipseJdt.onlyIf { false }
|
||||
|
||||
task sourcesJar(type: Jar) {
|
||||
classifier = 'sources'
|
||||
from project.sourceSets.main.allSource
|
||||
|
||||
17
config/checkstyle/checkstyle-header.txt
Normal file
17
config/checkstyle/checkstyle-header.txt
Normal file
@@ -0,0 +1,17 @@
|
||||
^\Q/*\E$
|
||||
^\Q * Copyright \E20\d\d\-20\d\d\Q the original author or authors.\E$
|
||||
^\Q *\E$
|
||||
^\Q * Licensed under the Apache License, Version 2.0 (the "License");\E$
|
||||
^\Q * you may not use this file except in compliance with the License.\E$
|
||||
^\Q * You may obtain a copy of the License at\E$
|
||||
^\Q *\E$
|
||||
^\Q * http://www.apache.org/licenses/LICENSE-2.0\E$
|
||||
^\Q *\E$
|
||||
^\Q * Unless required by applicable law or agreed to in writing, software\E$
|
||||
^\Q * distributed under the License is distributed on an "AS IS" BASIS,\E$
|
||||
^\Q * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\E$
|
||||
^\Q * See the License for the specific language governing permissions and\E$
|
||||
^\Q * limitations under the License.\E$
|
||||
^\Q */\E$
|
||||
^$
|
||||
^.*$
|
||||
12
config/checkstyle/checkstyle-import-control.xml
Normal file
12
config/checkstyle/checkstyle-import-control.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE import-control PUBLIC "-//Puppy Crawl//DTD Import Control 1.1//EN" "http://www.puppycrawl.com/dtds/import_control_1_1.dtd">
|
||||
<import-control pkg="org.springframework.restdocs">
|
||||
|
||||
<allow pkg=".*" regex="true"/>
|
||||
|
||||
<!-- Use BDD Mockito -->
|
||||
<disallow class="org.mockito.Mockito.when"/>
|
||||
<disallow class="org.mockito.Mockito.doThrow"/>
|
||||
<disallow class="org.mockito.Mockito.doAnswer"/>
|
||||
|
||||
</import-control>
|
||||
8
config/checkstyle/checkstyle-suppressions.xml
Normal file
8
config/checkstyle/checkstyle-suppressions.xml
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE suppressions PUBLIC
|
||||
"-//Puppy Crawl//DTD Suppressions 1.1//EN"
|
||||
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
|
||||
<suppressions>
|
||||
<suppress files="[\\/]src[\\/]test[\\/]java[\\/]" checks="JavadocVariable" />
|
||||
<suppress files="[\\/]src[\\/]test[\\/]java[\\/]" checks="JavadocMethod" />
|
||||
</suppressions>
|
||||
156
config/checkstyle/checkstyle.xml
Normal file
156
config/checkstyle/checkstyle.xml
Normal file
@@ -0,0 +1,156 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.2//EN" "http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
|
||||
<module name="Checker">
|
||||
|
||||
<!-- Root Checks -->
|
||||
<module name="RegexpHeader">
|
||||
<property name="headerFile" value="${checkstyle.config.dir}/checkstyle-header.txt" />
|
||||
<property name="fileExtensions" value="java" />
|
||||
</module>
|
||||
<module name="NewlineAtEndOfFile" />
|
||||
|
||||
<module name="SuppressionFilter">
|
||||
<property name="file" value="${checkstyle.config.dir}/checkstyle-suppressions.xml"/>
|
||||
</module>
|
||||
|
||||
<!-- TreeWalker Checks -->
|
||||
<module name="TreeWalker">
|
||||
|
||||
<!-- Annotations -->
|
||||
<module name="AnnotationUseStyle">
|
||||
<property name="elementStyle" value="compact" />
|
||||
</module>
|
||||
<module name="MissingOverride" />
|
||||
<module name="PackageAnnotation" />
|
||||
<module name="AnnotationLocation">
|
||||
<property name="allowSamelineSingleParameterlessAnnotation"
|
||||
value="false" />
|
||||
</module>
|
||||
|
||||
<!-- Block Checks -->
|
||||
<module name="EmptyBlock">
|
||||
<property name="option" value="text" />
|
||||
</module>
|
||||
<module name="LeftCurly" />
|
||||
<module name="RightCurly">
|
||||
<property name="option" value="alone" />
|
||||
</module>
|
||||
<module name="NeedBraces" />
|
||||
<module name="AvoidNestedBlocks" />
|
||||
|
||||
<!-- Class Design -->
|
||||
<module name="FinalClass" />
|
||||
<module name="InterfaceIsType" />
|
||||
<module name="HideUtilityClassConstructor" />
|
||||
<module name="MutableException" />
|
||||
<module name="InnerTypeLast" />
|
||||
<module name="OneTopLevelClass" />
|
||||
|
||||
<!-- Coding -->
|
||||
<module name="CovariantEquals" />
|
||||
<module name="EmptyStatement" />
|
||||
<module name="EqualsHashCode" />
|
||||
<module name="InnerAssignment" />
|
||||
<module name="SimplifyBooleanExpression" />
|
||||
<module name="SimplifyBooleanReturn" />
|
||||
<module name="StringLiteralEquality" />
|
||||
<module name="NestedForDepth">
|
||||
<property name="max" value="3" />
|
||||
</module>
|
||||
<module name="NestedIfDepth">
|
||||
<property name="max" value="3" />
|
||||
</module>
|
||||
<module name="NestedTryDepth">
|
||||
<property name="max" value="3" />
|
||||
</module>
|
||||
<module name="MultipleVariableDeclarations" />
|
||||
<module name="RequireThis">
|
||||
<property name="checkMethods" value="false" />
|
||||
</module>
|
||||
<module name="OneStatementPerLine" />
|
||||
|
||||
<!-- Imports -->
|
||||
<module name="AvoidStarImport" />
|
||||
<module name="AvoidStaticImport">
|
||||
<property name="excludes"
|
||||
value="org.junit.Assert.*, org.junit.Assume.*, org.hamcrest.CoreMatchers.*, org.hamcrest.Matchers.*, org.mockito.Mockito.*, org.mockito.BDDMockito.*, org.mockito.Matchers.*, org.springframework.restdocs.curl.CurlDocumentation.*, org.springframework.restdocs.hypermedia.HypermediaDocumentation.*, org.springframework.restdocs.mockmvc.IterableEnumeration.*, org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.*, org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*, org.springframework.restdocs.operation.preprocess.Preprocessors.*, org.springframework.restdocs.payload.PayloadDocumentation.*, org.springframework.restdocs.request.RequestDocumentation.*, org.springframework.restdocs.snippet.Attributes.*, org.springframework.restdocs.test.SnippetMatchers.*, org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*, org.springframework.test.web.servlet.result.MockMvcResultMatchers.*" />
|
||||
</module>
|
||||
<module name="IllegalImport" />
|
||||
<module name="RedundantImport" />
|
||||
<module name="UnusedImports">
|
||||
<property name="processJavadoc" value="true" />
|
||||
</module>
|
||||
<module name="ImportOrder">
|
||||
<property name="groups" value="java,/^javax?\./,org,com,*" />
|
||||
<property name="ordered" value="true" />
|
||||
<property name="separated" value="true" />
|
||||
<property name="option" value="bottom" />
|
||||
<property name="sortStaticImportsAlphabetically" value="true" />
|
||||
</module>
|
||||
<module name="ImportControl">
|
||||
<property name="file" value="${checkstyle.config.dir}/checkstyle-import-control.xml"/>
|
||||
</module>
|
||||
|
||||
<!-- Javadoc Comments -->
|
||||
<module name="JavadocType">
|
||||
<property name="scope" value="package"/>
|
||||
<property name="authorFormat" value=".+\s.+"/>
|
||||
</module>
|
||||
<module name="JavadocMethod">
|
||||
<property name="scope" value="protected"/>
|
||||
</module>
|
||||
<module name="JavadocVariable">
|
||||
<property name="scope" value="protected"/>
|
||||
</module>
|
||||
<module name="JavadocStyle">
|
||||
<property name="checkEmptyJavadoc" value="true"/>
|
||||
</module>
|
||||
<module name="NonEmptyAtclauseDescription"/>
|
||||
<module name="JavadocTagContinuationIndentation">
|
||||
<property name="offset" value="0"/>
|
||||
</module>
|
||||
<module name="AtclauseOrder">
|
||||
<property name="target" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF"/>
|
||||
<property name="tagOrder" value="@param, @author, @since, @see, @version, @serial, @deprecated"/>
|
||||
</module>
|
||||
<module name="AtclauseOrder">
|
||||
<property name="target" value="METHOD_DEF, CTOR_DEF, VARIABLE_DEF"/>
|
||||
<property name="tagOrder" value="@param, @return, @throws, @since, @deprecated, @see"/>
|
||||
</module>
|
||||
|
||||
<!-- Miscellaneous -->
|
||||
<module name="CommentsIndentation" />
|
||||
<module name="UpperEll" />
|
||||
<module name="ArrayTypeStyle" />
|
||||
<module name="OuterTypeFilename" />
|
||||
|
||||
<!-- Modifiers -->
|
||||
<module name="RedundantModifier" />
|
||||
|
||||
<!-- Regexp -->
|
||||
<module name="RegexpSinglelineJava">
|
||||
<property name="format" value="^\t* +\t*\S" />
|
||||
<property name="message"
|
||||
value="Line has leading space characters; indentation should be performed with tabs only." />
|
||||
<property name="ignoreComments" value="true" />
|
||||
</module>
|
||||
<module name="Regexp">
|
||||
<property name="format" value="[ \t]+$" />
|
||||
<property name="illegalPattern" value="true" />
|
||||
<property name="message" value="Trailing whitespace" />
|
||||
</module>
|
||||
|
||||
<!-- Whitespace -->
|
||||
<module name="GenericWhitespace" />
|
||||
<module name="MethodParamPad" />
|
||||
<module name="NoWhitespaceAfter" >
|
||||
<property name="tokens" value="BNOT, DEC, DOT, INC, LNOT, UNARY_MINUS, UNARY_PLUS, ARRAY_DECLARATOR"/>
|
||||
</module>
|
||||
<module name="NoWhitespaceBefore" />
|
||||
<module name="ParenPad" />
|
||||
<module name="TypecastParenPad" />
|
||||
<module name="WhitespaceAfter" />
|
||||
<module name="WhitespaceAround" />
|
||||
|
||||
</module>
|
||||
</module>
|
||||
@@ -10,14 +10,100 @@ org.eclipse.jdt.core.codeComplete.staticFieldSuffixes=
|
||||
org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes=
|
||||
org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes=
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.doc.comment.support=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
|
||||
org.eclipse.jdt.core.compiler.problem.deadCode=warning
|
||||
org.eclipse.jdt.core.compiler.problem.deprecation=warning
|
||||
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
|
||||
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
|
||||
org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
|
||||
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning
|
||||
org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=default
|
||||
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
|
||||
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=all_standard_tags
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocTags=warning
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=default
|
||||
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
|
||||
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
|
||||
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.nullReference=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
|
||||
org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
|
||||
org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
|
||||
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedImport=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
|
||||
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
|
||||
org.eclipse.jdt.core.compiler.processAnnotations=disabled
|
||||
org.eclipse.jdt.core.compiler.source=1.7
|
||||
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
|
||||
@@ -46,8 +132,8 @@ org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration
|
||||
org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16
|
||||
org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_after_package=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_field=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_field=0
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_method=1
|
||||
@@ -100,7 +186,7 @@ org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
|
||||
org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
|
||||
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
|
||||
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false
|
||||
org.eclipse.jdt.core.formatter.indentation.size=8
|
||||
org.eclipse.jdt.core.formatter.indentation.size=4
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert
|
||||
@@ -128,7 +214,7 @@ org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
|
||||
125
config/eclipse/org.eclipse.jdt.ui.prefs
Normal file
125
config/eclipse/org.eclipse.jdt.ui.prefs
Normal file
File diff suppressed because one or more lines are too long
@@ -27,7 +27,7 @@ import org.springframework.web.context.WebApplicationContext;
|
||||
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.documentationConfiguration;
|
||||
|
||||
public class ExampleApplicationTests {
|
||||
|
||||
|
||||
// tag::mock-mvc-setup[]
|
||||
@Rule
|
||||
public final RestDocumentation restDocumentation = new RestDocumentation("build/generated-snippets");
|
||||
@@ -44,4 +44,4 @@ public class ExampleApplicationTests {
|
||||
.build();
|
||||
}
|
||||
// end::mock-mvc-setup[]
|
||||
}
|
||||
}
|
||||
|
||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,6 @@
|
||||
#Tue Jul 28 11:16:06 BST 2015
|
||||
#Wed Sep 23 15:50:30 BST 2015
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.5-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.7-bin.zip
|
||||
|
||||
6
gradlew
vendored
6
gradlew
vendored
@@ -42,11 +42,6 @@ case "`uname`" in
|
||||
;;
|
||||
esac
|
||||
|
||||
# For Cygwin, ensure paths are in UNIX format before anything is touched.
|
||||
if $cygwin ; then
|
||||
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
||||
fi
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
@@ -114,6 +109,7 @@ fi
|
||||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
|
||||
@@ -8,6 +8,7 @@ org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.7
|
||||
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
|
||||
|
||||
@@ -13,7 +13,7 @@ cleanup.always_use_this_for_non_static_field_access=true
|
||||
cleanup.always_use_this_for_non_static_method_access=false
|
||||
cleanup.convert_functional_interfaces=false
|
||||
cleanup.convert_to_enhanced_for_loop=false
|
||||
cleanup.correct_indentation=false
|
||||
cleanup.correct_indentation=true
|
||||
cleanup.format_source_code=true
|
||||
cleanup.format_source_code_changes_only=false
|
||||
cleanup.insert_inferred_type_arguments=false
|
||||
|
||||
@@ -13,7 +13,7 @@ cleanup.always_use_this_for_non_static_field_access=true
|
||||
cleanup.always_use_this_for_non_static_method_access=false
|
||||
cleanup.convert_functional_interfaces=false
|
||||
cleanup.convert_to_enhanced_for_loop=false
|
||||
cleanup.correct_indentation=false
|
||||
cleanup.correct_indentation=true
|
||||
cleanup.format_source_code=true
|
||||
cleanup.format_source_code_changes_only=false
|
||||
cleanup.insert_inferred_type_arguments=false
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -37,7 +37,7 @@ public class RestDocumentation implements TestRule {
|
||||
|
||||
/**
|
||||
* Creates a new {@code RestDocumentation} instance that will generate snippets to the
|
||||
* given {@code outputDirectory}
|
||||
* given {@code outputDirectory}.
|
||||
*
|
||||
* @param outputDirectory the output directory
|
||||
*/
|
||||
|
||||
@@ -39,7 +39,7 @@ public final class RestDocumentationContext {
|
||||
* Creates a new {@code RestDocumentationContext} for a test on the given
|
||||
* {@code testClass} with given {@code testMethodName} that will generate
|
||||
* documentation to the given {@code outputDirectory}.
|
||||
*
|
||||
*
|
||||
* @param testClass the class whose test is being executed
|
||||
* @param testMethodName the name of the test method that is being executed
|
||||
* @param outputDirectory the directory to which documentation should be written.
|
||||
@@ -52,7 +52,7 @@ public final class RestDocumentationContext {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the class whose tests are currently executing
|
||||
* Returns the class whose tests are currently executing.
|
||||
*
|
||||
* @return The test class
|
||||
*/
|
||||
@@ -61,8 +61,8 @@ public final class RestDocumentationContext {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the test method that is currently executing
|
||||
*
|
||||
* Returns the name of the test method that is currently executing.
|
||||
*
|
||||
* @return The name of the test method
|
||||
*/
|
||||
public String getTestMethodName() {
|
||||
@@ -70,7 +70,7 @@ public final class RestDocumentationContext {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current step count and then increments it
|
||||
* Returns the current step count and then increments it.
|
||||
*
|
||||
* @return The step count prior to it being incremented
|
||||
*/
|
||||
@@ -79,7 +79,7 @@ public final class RestDocumentationContext {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current step count
|
||||
* Returns the current step count.
|
||||
*
|
||||
* @return The current step count
|
||||
*/
|
||||
@@ -89,7 +89,7 @@ public final class RestDocumentationContext {
|
||||
|
||||
/**
|
||||
* Returns the output directory to which generated snippets should be written.
|
||||
*
|
||||
*
|
||||
* @return the output directory
|
||||
*/
|
||||
public File getOutputDirectory() {
|
||||
|
||||
@@ -19,8 +19,8 @@ package org.springframework.restdocs.constraints;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* A constraint
|
||||
*
|
||||
* A constraint.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class Constraint {
|
||||
@@ -32,7 +32,7 @@ public class Constraint {
|
||||
/**
|
||||
* Creates a new {@code Constraint} with the given {@code name} and
|
||||
* {@code configuration}.
|
||||
*
|
||||
*
|
||||
* @param name the name
|
||||
* @param configuration the configuration
|
||||
*/
|
||||
@@ -42,8 +42,8 @@ public class Constraint {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the constraint
|
||||
*
|
||||
* Returns the name of the constraint.
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
@@ -51,8 +51,8 @@ public class Constraint {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the configuration of the constraint
|
||||
*
|
||||
* Returns the configuration of the constraint.
|
||||
*
|
||||
* @return the configuration
|
||||
*/
|
||||
public Map<String, Object> getConfiguration() {
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.restdocs.constraints;
|
||||
|
||||
/**
|
||||
* Resolves a description for a {@link Constraint}.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*
|
||||
*/
|
||||
@@ -26,9 +26,9 @@ public interface ConstraintDescriptionResolver {
|
||||
|
||||
/**
|
||||
* Resolves the description for the given {@code constraint}.
|
||||
*
|
||||
*
|
||||
* @param constraint the constraint
|
||||
* @return the description
|
||||
*/
|
||||
public String resolveDescription(Constraint constraint);
|
||||
String resolveDescription(Constraint constraint);
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Provides access to descriptions of a class's constraints
|
||||
*
|
||||
* Provides access to descriptions of a class's constraints.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class ConstraintDescriptions {
|
||||
@@ -38,7 +38,7 @@ public class ConstraintDescriptions {
|
||||
* Constraints will be resolved using a {@link ValidatorConstraintResolver} and
|
||||
* descriptions will be resolved using a
|
||||
* {@link ResourceBundleConstraintDescriptionResolver}.
|
||||
*
|
||||
*
|
||||
* @param clazz the class
|
||||
*/
|
||||
public ConstraintDescriptions(Class<?> clazz) {
|
||||
@@ -51,7 +51,7 @@ public class ConstraintDescriptions {
|
||||
* Constraints will be resolved using the given {@code constraintResolver} and
|
||||
* descriptions will be resolved using a
|
||||
* {@link ResourceBundleConstraintDescriptionResolver}.
|
||||
*
|
||||
*
|
||||
* @param clazz the class
|
||||
* @param constraintResolver the constraint resolver
|
||||
*/
|
||||
@@ -63,7 +63,7 @@ public class ConstraintDescriptions {
|
||||
* Create a new {@code ConstraintDescriptions} for the given {@code clazz}.
|
||||
* Constraints will be resolved using a {@link ValidatorConstraintResolver} and
|
||||
* descriptions will be resolved using the given {@code descriptionResolver}.
|
||||
*
|
||||
*
|
||||
* @param clazz the class
|
||||
* @param descriptionResolver the description resolver
|
||||
*/
|
||||
@@ -76,7 +76,7 @@ public class ConstraintDescriptions {
|
||||
* Create a new {@code ConstraintDescriptions} for the given {@code clazz}.
|
||||
* Constraints will be resolved using the given {@code constraintResolver} and
|
||||
* descriptions will be resolved using the given {@code descriptionResolver}.
|
||||
*
|
||||
*
|
||||
* @param clazz the class
|
||||
* @param constraintResolver the constraint resolver
|
||||
* @param descriptionResolver the description resolver
|
||||
@@ -89,8 +89,8 @@ public class ConstraintDescriptions {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of the descriptions for the constraints on the given property
|
||||
*
|
||||
* Returns a list of the descriptions for the constraints on the given property.
|
||||
*
|
||||
* @param property the property
|
||||
* @return the list of constraint descriptions
|
||||
*/
|
||||
@@ -104,5 +104,4 @@ public class ConstraintDescriptions {
|
||||
Collections.sort(descriptions);
|
||||
return descriptions;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* An abstraction for resolving a class's constraints.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public interface ConstraintResolver {
|
||||
@@ -28,7 +28,7 @@ public interface ConstraintResolver {
|
||||
/**
|
||||
* Resolves and returns the constraints for the given {@code property} on the given
|
||||
* {@code clazz}. If there are no constraints, an empty list is returned.
|
||||
*
|
||||
*
|
||||
* @param property the property
|
||||
* @param clazz the class
|
||||
* @return the list of constraints, never {@code null}
|
||||
|
||||
@@ -45,7 +45,7 @@ import org.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver;
|
||||
* {@code javax.validation.constraints.NotNull.description}.
|
||||
* <p>
|
||||
* Default descriptions are provided for Bean Validation 1.1's constraints:
|
||||
*
|
||||
*
|
||||
* <ul>
|
||||
* <li>{@link AssertFalse}
|
||||
* <li>{@link AssertTrue}
|
||||
@@ -61,7 +61,7 @@ import org.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver;
|
||||
* <li>{@link Pattern}
|
||||
* <li>{@link Size}
|
||||
* </ul>
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class ResourceBundleConstraintDescriptionResolver implements
|
||||
@@ -78,7 +78,7 @@ public class ResourceBundleConstraintDescriptionResolver implements
|
||||
* Creates a new {@code ResourceBundleConstraintDescriptionResolver} that will resolve
|
||||
* descriptions by looking them up in a resource bundle with the base name
|
||||
* {@code org.springframework.restdocs.constraints.ConstraintDescriptions} in the
|
||||
* default locale loaded using the thread context class loader
|
||||
* default locale loaded using the thread context class loader.
|
||||
*/
|
||||
public ResourceBundleConstraintDescriptionResolver() {
|
||||
this(getBundle("ConstraintDescriptions"));
|
||||
@@ -87,7 +87,7 @@ public class ResourceBundleConstraintDescriptionResolver implements
|
||||
/**
|
||||
* Creates a new {@code ResourceBundleConstraintDescriptionResolver} that will resolve
|
||||
* descriptions by looking them up in the given {@code resourceBundle}.
|
||||
*
|
||||
*
|
||||
* @param resourceBundle the resource bundle
|
||||
*/
|
||||
public ResourceBundleConstraintDescriptionResolver(ResourceBundle resourceBundle) {
|
||||
@@ -126,7 +126,8 @@ public class ResourceBundleConstraintDescriptionResolver implements
|
||||
return this.defaultDescriptions.getString(key);
|
||||
}
|
||||
|
||||
private static class ConstraintPlaceholderResolver implements PlaceholderResolver {
|
||||
private static final class ConstraintPlaceholderResolver implements
|
||||
PlaceholderResolver {
|
||||
|
||||
private final Constraint constraint;
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ import javax.validation.metadata.PropertyDescriptor;
|
||||
* constraints. The name of the constraint is the fully-qualified class name of the
|
||||
* constraint annotation. For example, a {@link NotNull} constraint will be named
|
||||
* {@code javax.validation.constraints.NotNull}.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*
|
||||
*/
|
||||
@@ -43,7 +43,7 @@ public class ValidatorConstraintResolver implements ConstraintResolver {
|
||||
/**
|
||||
* Creates a new {@code ValidatorConstraintResolver} that will use a {@link Validator}
|
||||
* in its default configuration to resolve constraints.
|
||||
*
|
||||
*
|
||||
* @see Validation#buildDefaultValidatorFactory()
|
||||
* @see ValidatorFactory#getValidator()
|
||||
*/
|
||||
@@ -54,7 +54,7 @@ public class ValidatorConstraintResolver implements ConstraintResolver {
|
||||
/**
|
||||
* Creates a new {@code ValidatorConstraintResolver} that will use the given
|
||||
* {@code Validator} to resolve constraints.
|
||||
*
|
||||
*
|
||||
* @param validator the validator
|
||||
*/
|
||||
public ValidatorConstraintResolver(Validator validator) {
|
||||
@@ -78,5 +78,4 @@ public class ValidatorConstraintResolver implements ConstraintResolver {
|
||||
}
|
||||
return constraints;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,4 +17,5 @@
|
||||
/**
|
||||
* Documenting a RESTful API's constraints.
|
||||
*/
|
||||
package org.springframework.restdocs.constraints;
|
||||
package org.springframework.restdocs.constraints;
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ public class CurlRequestSnippet extends TemplatedSnippet {
|
||||
/**
|
||||
* Creates a new {@code CurlRequestSnippet} with the given additional
|
||||
* {@code attributes} that will be included in the model during template rendering.
|
||||
*
|
||||
*
|
||||
* @param attributes The additional attributes
|
||||
*/
|
||||
protected CurlRequestSnippet(Map<String, Object> attributes) {
|
||||
|
||||
@@ -17,4 +17,5 @@
|
||||
/**
|
||||
* Documenting the curl command required to make a request to a RESTful API.
|
||||
*/
|
||||
package org.springframework.restdocs.curl;
|
||||
package org.springframework.restdocs.curl;
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.springframework.restdocs.snippet.Snippet;
|
||||
|
||||
/**
|
||||
* Static factory methods for documenting a RESTful API's HTTP requests.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @author Jonathan Pearlin
|
||||
*/
|
||||
@@ -35,7 +35,7 @@ public abstract class HttpDocumentation {
|
||||
/**
|
||||
* Returns a handler that will produce a snippet containing the HTTP request for the
|
||||
* API call.
|
||||
*
|
||||
*
|
||||
* @return the handler that will produce the snippet
|
||||
*/
|
||||
public static Snippet httpRequest() {
|
||||
|
||||
@@ -55,7 +55,7 @@ public class HttpRequestSnippet extends TemplatedSnippet {
|
||||
/**
|
||||
* Creates a new {@code HttpRequestSnippet} with the given additional
|
||||
* {@code attributes} that will be included in the model during template rendering.
|
||||
*
|
||||
*
|
||||
* @param attributes The additional attributes
|
||||
*/
|
||||
protected HttpRequestSnippet(Map<String, Object> attributes) {
|
||||
@@ -186,4 +186,4 @@ public class HttpRequestSnippet extends TemplatedSnippet {
|
||||
return header;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public class HttpResponseSnippet extends TemplatedSnippet {
|
||||
/**
|
||||
* Creates a new {@code HttpResponseSnippet} with the given additional
|
||||
* {@code attributes} that will be included in the model during template rendering.
|
||||
*
|
||||
*
|
||||
* @param attributes The additional attributes
|
||||
*/
|
||||
protected HttpResponseSnippet(Map<String, Object> attributes) {
|
||||
@@ -86,4 +86,5 @@ public class HttpResponseSnippet extends TemplatedSnippet {
|
||||
header.put("value", value);
|
||||
return header;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,4 +18,5 @@
|
||||
* Documenting the HTTP request sent to a RESTful API and the HTTP response that is
|
||||
* returned.
|
||||
*/
|
||||
package org.springframework.restdocs.http;
|
||||
package org.springframework.restdocs.http;
|
||||
|
||||
|
||||
@@ -25,8 +25,8 @@ import org.springframework.restdocs.operation.OperationResponse;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
/**
|
||||
* Abstract base class for a {@link LinkExtractor} that extracts links from JSON
|
||||
*
|
||||
* Abstract base class for a {@link LinkExtractor} that extracts links from JSON.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
abstract class AbstractJsonLinkExtractor implements LinkExtractor {
|
||||
@@ -43,4 +43,5 @@ abstract class AbstractJsonLinkExtractor implements LinkExtractor {
|
||||
}
|
||||
|
||||
protected abstract Map<String, List<Link>> extractLinks(Map<String, Object> json);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.springframework.util.MultiValueMap;
|
||||
|
||||
/**
|
||||
* {@link LinkExtractor} that extracts links in Atom format.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -62,4 +62,5 @@ class AtomLinkExtractor extends AbstractJsonLinkExtractor {
|
||||
extractedLinks.add(link.getRel(), link);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.springframework.http.MediaType;
|
||||
/**
|
||||
* {@link LinkExtractor} that extracts links in Hypermedia Application Language (HAL)
|
||||
* format.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
class HalLinkExtractor extends AbstractJsonLinkExtractor {
|
||||
@@ -77,4 +77,5 @@ class HalLinkExtractor extends AbstractJsonLinkExtractor {
|
||||
links.add(possibleLink);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.springframework.restdocs.snippet.Snippet;
|
||||
|
||||
/**
|
||||
* Static factory methods for documenting a RESTful API that utilizes Hypermedia.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public abstract class HypermediaDocumentation {
|
||||
@@ -34,7 +34,7 @@ public abstract class HypermediaDocumentation {
|
||||
|
||||
/**
|
||||
* Creates a {@code LinkDescriptor} that describes a link with the given {@code rel}.
|
||||
*
|
||||
*
|
||||
* @param rel The rel of the link
|
||||
* @return a {@code LinkDescriptor} ready for further configuration
|
||||
*/
|
||||
@@ -46,7 +46,7 @@ public abstract class HypermediaDocumentation {
|
||||
* Returns a handler that will produce a snippet documenting the links in the API
|
||||
* call's response. Links will be extracted from the response automatically based on
|
||||
* its content type.
|
||||
*
|
||||
*
|
||||
* @param descriptors The descriptions of the response's links
|
||||
* @return the handler
|
||||
*/
|
||||
@@ -60,22 +60,22 @@ public abstract class HypermediaDocumentation {
|
||||
* call's response. The given {@code attributes} will be available during snippet
|
||||
* generation. Links will be extracted from the response automatically based on its
|
||||
* content type.
|
||||
*
|
||||
*
|
||||
* @param attributes Attributes made available during rendering of the links snippet
|
||||
* @param descriptors The descriptions of the response's links
|
||||
* @return the handler
|
||||
*/
|
||||
public static Snippet links(Map<String, Object> attributes,
|
||||
LinkDescriptor... descriptors) {
|
||||
return new LinksSnippet(new ContentTypeLinkExtractor(), Arrays.asList(descriptors),
|
||||
attributes);
|
||||
return new LinksSnippet(new ContentTypeLinkExtractor(),
|
||||
Arrays.asList(descriptors), attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a handler that will produce a snippet documenting the links in the API
|
||||
* call's response. Links will be extracted from the response using the given
|
||||
* {@code linkExtractor}.
|
||||
*
|
||||
*
|
||||
* @param linkExtractor Used to extract the links from the response
|
||||
* @param descriptors The descriptions of the response's links
|
||||
* @return the handler
|
||||
@@ -90,7 +90,7 @@ public abstract class HypermediaDocumentation {
|
||||
* call's response. The given {@code attributes} will be available during snippet
|
||||
* generation. Links will be extracted from the response using the given
|
||||
* {@code linkExtractor}.
|
||||
*
|
||||
*
|
||||
* @param attributes Attributes made available during rendering of the links snippet
|
||||
* @param linkExtractor Used to extract the links from the response
|
||||
* @param descriptors The descriptions of the response's links
|
||||
@@ -98,8 +98,7 @@ public abstract class HypermediaDocumentation {
|
||||
*/
|
||||
public static Snippet links(LinkExtractor linkExtractor,
|
||||
Map<String, Object> attributes, LinkDescriptor... descriptors) {
|
||||
return new LinksSnippet(linkExtractor, Arrays.asList(descriptors),
|
||||
attributes);
|
||||
return new LinksSnippet(linkExtractor, Arrays.asList(descriptors), attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.springframework.restdocs.hypermedia;
|
||||
import org.springframework.core.style.ToStringCreator;
|
||||
|
||||
/**
|
||||
* Representation of a link used in a Hypermedia-based API
|
||||
* Representation of a link used in a Hypermedia-based API.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
@@ -30,7 +30,7 @@ public class Link {
|
||||
private final String href;
|
||||
|
||||
/**
|
||||
* Creates a new {@code Link} with the given {@code rel} and {@code href}
|
||||
* Creates a new {@code Link} with the given {@code rel} and {@code href}.
|
||||
*
|
||||
* @param rel The link's rel
|
||||
* @param href The link's href
|
||||
@@ -41,7 +41,7 @@ public class Link {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the link's {@code rel}
|
||||
* Returns the link's {@code rel}.
|
||||
* @return the link's {@code rel}
|
||||
*/
|
||||
public String getRel() {
|
||||
@@ -49,7 +49,7 @@ public class Link {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the link's {@code href}
|
||||
* Returns the link's {@code href}.
|
||||
* @return the link's {@code href}
|
||||
*/
|
||||
public String getHref() {
|
||||
|
||||
@@ -19,11 +19,10 @@ package org.springframework.restdocs.hypermedia;
|
||||
import org.springframework.restdocs.snippet.AbstractDescriptor;
|
||||
|
||||
/**
|
||||
* A description of a link found in a hypermedia API
|
||||
*
|
||||
* @see HypermediaDocumentation#linkWithRel(String)
|
||||
*
|
||||
* A description of a link found in a hypermedia API.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @see HypermediaDocumentation#linkWithRel(String)
|
||||
*/
|
||||
public class LinkDescriptor extends AbstractDescriptor<LinkDescriptor> {
|
||||
|
||||
@@ -33,7 +32,7 @@ public class LinkDescriptor extends AbstractDescriptor<LinkDescriptor> {
|
||||
|
||||
/**
|
||||
* Creates a new {@code LinkDescriptor} describing a link with the given {@code rel}.
|
||||
*
|
||||
*
|
||||
* @param rel the rel of the link
|
||||
*/
|
||||
protected LinkDescriptor(String rel) {
|
||||
@@ -41,7 +40,7 @@ public class LinkDescriptor extends AbstractDescriptor<LinkDescriptor> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks the link as optional
|
||||
* Marks the link as optional.
|
||||
*
|
||||
* @return {@code this}
|
||||
*/
|
||||
@@ -51,8 +50,8 @@ public class LinkDescriptor extends AbstractDescriptor<LinkDescriptor> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the rel of the link described by this descriptor
|
||||
*
|
||||
* Returns the rel of the link described by this descriptor.
|
||||
*
|
||||
* @return the rel
|
||||
*/
|
||||
public final String getRel() {
|
||||
@@ -60,8 +59,8 @@ public class LinkDescriptor extends AbstractDescriptor<LinkDescriptor> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@code true} if the described link is optional, otherwise {@code false}
|
||||
*
|
||||
* Returns {@code true} if the described link is optional, otherwise {@code false}.
|
||||
*
|
||||
* @return {@code true} if the described link is optional, otherwise {@code false}
|
||||
*/
|
||||
public final boolean isOptional() {
|
||||
|
||||
@@ -52,7 +52,7 @@ public class LinksSnippet extends TemplatedSnippet {
|
||||
/**
|
||||
* Creates a new {@code LinksSnippet} that will extract links using the given
|
||||
* {@code linkExtractor} and document them using the given {@code descriptors}.
|
||||
*
|
||||
*
|
||||
* @param linkExtractor the link extractor
|
||||
* @param descriptors the link descriptors
|
||||
*/
|
||||
@@ -64,7 +64,7 @@ public class LinksSnippet extends TemplatedSnippet {
|
||||
* Creates a new {@code LinksSnippet} that will extract links using the given
|
||||
* {@code linkExtractor} and document them using the given {@code descriptors}. The
|
||||
* given {@code attributes} will be included in the model during template rendering.
|
||||
*
|
||||
*
|
||||
* @param linkExtractor the link extractor
|
||||
* @param descriptors the link descriptors
|
||||
* @param attributes the additional attributes
|
||||
@@ -139,7 +139,7 @@ public class LinksSnippet extends TemplatedSnippet {
|
||||
/**
|
||||
* Returns a {@code Map} of {@link LinkDescriptor LinkDescriptors} keyed by their
|
||||
* {@link LinkDescriptor#getRel() rels}.
|
||||
*
|
||||
*
|
||||
* @return the link descriptors
|
||||
*/
|
||||
protected final Map<String, LinkDescriptor> getDescriptorsByRel() {
|
||||
@@ -147,8 +147,8 @@ public class LinksSnippet extends TemplatedSnippet {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a model for the given {@code descriptor}
|
||||
*
|
||||
* Returns a model for the given {@code descriptor}.
|
||||
*
|
||||
* @param descriptor the descriptor
|
||||
* @return the model
|
||||
*/
|
||||
@@ -161,4 +161,4 @@ public class LinksSnippet extends TemplatedSnippet {
|
||||
return model;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,4 +17,5 @@
|
||||
/**
|
||||
* Documenting a RESTful API that uses hypermedia.
|
||||
*/
|
||||
package org.springframework.restdocs.hypermedia;
|
||||
package org.springframework.restdocs.hypermedia;
|
||||
|
||||
|
||||
@@ -20,35 +20,35 @@ import java.util.Map;
|
||||
|
||||
/**
|
||||
* Describes an operation performed on a RESTful service.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public interface Operation {
|
||||
|
||||
/**
|
||||
* Returns a {@code Map} of attributes associated with the operation.
|
||||
*
|
||||
*
|
||||
* @return the attributes
|
||||
*/
|
||||
Map<String, Object> getAttributes();
|
||||
|
||||
/**
|
||||
* Returns the name of the operation.
|
||||
*
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Returns the request that was sent.
|
||||
*
|
||||
*
|
||||
* @return the request
|
||||
*/
|
||||
OperationRequest getRequest();
|
||||
|
||||
/**
|
||||
* Returns the response that was received.
|
||||
*
|
||||
*
|
||||
* @return the response
|
||||
*/
|
||||
OperationResponse getResponse();
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.springframework.http.HttpMethod;
|
||||
|
||||
/**
|
||||
* The request that was sent as part of performing an operation on a RESTful service.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @see Operation#getRequest()
|
||||
*/
|
||||
@@ -32,22 +32,22 @@ public interface OperationRequest {
|
||||
|
||||
/**
|
||||
* Returns the contents of the request. If the request has no content an empty array
|
||||
* is returned
|
||||
*
|
||||
* is returned.
|
||||
*
|
||||
* @return the contents, never {@code null}
|
||||
*/
|
||||
byte[] getContent();
|
||||
|
||||
/**
|
||||
* Returns the headers that were included in the request.
|
||||
*
|
||||
*
|
||||
* @return the headers
|
||||
*/
|
||||
HttpHeaders getHeaders();
|
||||
|
||||
/**
|
||||
* Returns the HTTP method of the request
|
||||
*
|
||||
* Returns the HTTP method of the request.
|
||||
*
|
||||
* @return the HTTP method
|
||||
*/
|
||||
HttpMethod getMethod();
|
||||
@@ -56,7 +56,7 @@ public interface OperationRequest {
|
||||
* Returns the request's parameters. For a {@code GET} request, the parameters are
|
||||
* derived from the query string. For a {@code POST} request, the parameters are
|
||||
* derived form the request's body.
|
||||
*
|
||||
*
|
||||
* @return the parameters
|
||||
*/
|
||||
Parameters getParameters();
|
||||
@@ -64,14 +64,14 @@ public interface OperationRequest {
|
||||
/**
|
||||
* Returns the request's parts, provided that it is a multipart request. If not, then
|
||||
* an empty {@link Collection} is returned.
|
||||
*
|
||||
*
|
||||
* @return the parts
|
||||
*/
|
||||
Collection<OperationRequestPart> getParts();
|
||||
|
||||
/**
|
||||
* Returns the request's URI.
|
||||
*
|
||||
*
|
||||
* @return the URI
|
||||
*/
|
||||
URI getUri();
|
||||
|
||||
@@ -19,37 +19,37 @@ package org.springframework.restdocs.operation;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
|
||||
/**
|
||||
* A part of a multipart request
|
||||
*
|
||||
* @author awilkinson
|
||||
* A part of a multipart request.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @see OperationRequest#getParts()
|
||||
*/
|
||||
public interface OperationRequestPart {
|
||||
|
||||
/**
|
||||
* Returns the name of the part.
|
||||
*
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Returns the name of the file that is being uploaded in this part.
|
||||
*
|
||||
*
|
||||
* @return the name of the file
|
||||
*/
|
||||
String getSubmittedFileName();
|
||||
|
||||
/**
|
||||
* Returns the contents of the part.
|
||||
*
|
||||
*
|
||||
* @return the contents
|
||||
*/
|
||||
byte[] getContent();
|
||||
|
||||
/**
|
||||
* Returns the part's headers.
|
||||
*
|
||||
*
|
||||
* @return the headers
|
||||
*/
|
||||
HttpHeaders getHeaders();
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.springframework.http.HttpStatus;
|
||||
|
||||
/**
|
||||
* The response that was received as part of performing an operation on a RESTful service.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @see Operation
|
||||
* @see Operation#getRequest()
|
||||
@@ -30,14 +30,14 @@ public interface OperationResponse {
|
||||
|
||||
/**
|
||||
* Returns the status of the response.
|
||||
*
|
||||
*
|
||||
* @return the status
|
||||
*/
|
||||
HttpStatus getStatus();
|
||||
|
||||
/**
|
||||
* Returns the headers in the response.
|
||||
*
|
||||
*
|
||||
* @return the headers
|
||||
*/
|
||||
HttpHeaders getHeaders();
|
||||
@@ -45,7 +45,7 @@ public interface OperationResponse {
|
||||
/**
|
||||
* Returns the contents of the response. If the response has no content an empty array
|
||||
* is returned.
|
||||
*
|
||||
*
|
||||
* @return the contents, never {@code null}
|
||||
*/
|
||||
byte[] getContent();
|
||||
|
||||
@@ -24,8 +24,8 @@ import java.util.Map;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
|
||||
/**
|
||||
* The parameters received in a request
|
||||
*
|
||||
* The parameters received in a request.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
@@ -33,8 +33,8 @@ public class Parameters extends LinkedMultiValueMap<String, String> {
|
||||
|
||||
/**
|
||||
* Converts the parameters to a query string suitable for use in a URI or the body of
|
||||
* a form-encoded request
|
||||
*
|
||||
* a form-encoded request.
|
||||
*
|
||||
* @return the query string
|
||||
*/
|
||||
public String toQueryString() {
|
||||
|
||||
@@ -19,8 +19,8 @@ package org.springframework.restdocs.operation;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Standard implementation of {@link Operation}
|
||||
*
|
||||
* Standard implementation of {@link Operation}.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class StandardOperation implements Operation {
|
||||
@@ -34,8 +34,8 @@ public class StandardOperation implements Operation {
|
||||
private final Map<String, Object> attributes;
|
||||
|
||||
/**
|
||||
* Creates a new {@code StandardOperation}
|
||||
*
|
||||
* Creates a new {@code StandardOperation}.
|
||||
*
|
||||
* @param name the name of the operation
|
||||
* @param request the request that was sent
|
||||
* @param response the response that was received
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.springframework.http.HttpMethod;
|
||||
|
||||
/**
|
||||
* Standard implementation of {@link OperationRequest}.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class StandardOperationRequest implements OperationRequest {
|
||||
@@ -46,7 +46,7 @@ public class StandardOperationRequest implements OperationRequest {
|
||||
/**
|
||||
* Creates a new request with the given {@code uri} and {@code method}. The request
|
||||
* will have the given {@code headers}, {@code parameters}, and {@code parts}.
|
||||
*
|
||||
*
|
||||
* @param uri the uri
|
||||
* @param method the method
|
||||
* @param content the content
|
||||
|
||||
@@ -20,7 +20,7 @@ import org.springframework.http.HttpHeaders;
|
||||
|
||||
/**
|
||||
* Standard implementation of {@code OperationRequestPart}.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class StandardOperationRequestPart implements OperationRequestPart {
|
||||
@@ -35,7 +35,7 @@ public class StandardOperationRequestPart implements OperationRequestPart {
|
||||
|
||||
/**
|
||||
* Creates a new {@code StandardOperationRequestPart} with the given {@code name}.
|
||||
*
|
||||
*
|
||||
* @param name the name of the part
|
||||
* @param submittedFileName the name of the file being uploaded by this part
|
||||
* @param content the contents of the part
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.springframework.http.HttpStatus;
|
||||
|
||||
/**
|
||||
* Standard implementation of {@link OperationResponse}.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class StandardOperationResponse implements OperationResponse {
|
||||
@@ -35,7 +35,7 @@ public class StandardOperationResponse implements OperationResponse {
|
||||
/**
|
||||
* Creates a new response with the given {@code status}, {@code headers}, and
|
||||
* {@code content}.
|
||||
*
|
||||
*
|
||||
* @param status the status of the response
|
||||
* @param headers the headers of the response
|
||||
* @param content the content of the response
|
||||
|
||||
@@ -18,4 +18,5 @@
|
||||
* Operation API that describes a request that was sent and the response that was
|
||||
* received when calling a RESTful API.
|
||||
*/
|
||||
package org.springframework.restdocs.operation;
|
||||
package org.springframework.restdocs.operation;
|
||||
|
||||
|
||||
@@ -23,15 +23,15 @@ import org.springframework.restdocs.operation.OperationResponse;
|
||||
* A {@code ContentModifier} modifies the content of an {@link OperationRequest} or
|
||||
* {@link OperationResponse} during the preprocessing that is performed prior to
|
||||
* documentation generation.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @see ContentModifyingOperationPreprocessor
|
||||
*/
|
||||
public interface ContentModifier {
|
||||
|
||||
/**
|
||||
* Returns modified content based on the given {@code originalContent}
|
||||
*
|
||||
* Returns modified content based on the given {@code originalContent}.
|
||||
*
|
||||
* @param originalContent the original content
|
||||
* @return the modified content
|
||||
*/
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.springframework.restdocs.operation.StandardOperationResponse;
|
||||
/**
|
||||
* An {@link OperationPreprocessor} that applies a {@link ContentModifier} to the content
|
||||
* of the request or response.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class ContentModifyingOperationPreprocessor implements OperationPreprocessor {
|
||||
@@ -35,7 +35,7 @@ public class ContentModifyingOperationPreprocessor implements OperationPreproces
|
||||
/**
|
||||
* Create a new {@code ContentModifyingOperationPreprocessor} that will apply the
|
||||
* given {@code contentModifier} to the operation's request or response.
|
||||
*
|
||||
*
|
||||
* @param contentModifier the contentModifier
|
||||
*/
|
||||
public ContentModifyingOperationPreprocessor(ContentModifier contentModifier) {
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.springframework.util.Assert;
|
||||
* An {@link OperationRequestPreprocessor} that delgates to one or more
|
||||
* {@link OperationPreprocessor OperationPreprocessors} to preprocess an
|
||||
* {@link OperationRequest}.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*
|
||||
*/
|
||||
@@ -37,7 +37,7 @@ class DelegatingOperationRequestPreprocessor implements OperationRequestPreproce
|
||||
* Creates a new {@code DelegatingOperationRequestPreprocessor} that will delegate to
|
||||
* the given {@code delegates} by calling
|
||||
* {@link OperationPreprocessor#preprocess(OperationRequest)}.
|
||||
*
|
||||
*
|
||||
* @param delegates the delegates
|
||||
*/
|
||||
DelegatingOperationRequestPreprocessor(List<OperationPreprocessor> delegates) {
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.springframework.util.Assert;
|
||||
* An {@link OperationResponsePreprocessor} that delgates to one or more
|
||||
* {@link OperationPreprocessor OperationPreprocessors} to preprocess an
|
||||
* {@link OperationResponse}.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
class DelegatingOperationResponsePreprocessor implements OperationResponsePreprocessor {
|
||||
@@ -36,7 +36,7 @@ class DelegatingOperationResponsePreprocessor implements OperationResponsePrepro
|
||||
* Creates a new {@code DelegatingOperationResponsePreprocessor} that will delegate to
|
||||
* the given {@code delegates} by calling
|
||||
* {@link OperationPreprocessor#preprocess(OperationResponse)}.
|
||||
*
|
||||
*
|
||||
* @param delegates the delegates
|
||||
*/
|
||||
DelegatingOperationResponsePreprocessor(List<OperationPreprocessor> delegates) {
|
||||
|
||||
@@ -27,8 +27,8 @@ import org.springframework.restdocs.operation.StandardOperationRequest;
|
||||
import org.springframework.restdocs.operation.StandardOperationResponse;
|
||||
|
||||
/**
|
||||
* An {@link OperationPreprocessor} that removes headers
|
||||
*
|
||||
* An {@link OperationPreprocessor} that removes headers.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
class HeaderRemovingOperationPreprocessor implements OperationPreprocessor {
|
||||
|
||||
@@ -19,8 +19,8 @@ package org.springframework.restdocs.operation.preprocess;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* A content modifier the masks the {@code href} of any hypermedia links
|
||||
*
|
||||
* A content modifier the masks the {@code href} of any hypermedia links.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
class LinkMaskingContentModifier implements ContentModifier {
|
||||
|
||||
@@ -23,22 +23,22 @@ import org.springframework.restdocs.operation.OperationResponse;
|
||||
/**
|
||||
* An {@code OperationPreprocessor} processes the {@link OperationRequest} and
|
||||
* {@link OperationResponse} of an {@link Operation} prior to it being documented.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public interface OperationPreprocessor {
|
||||
|
||||
/**
|
||||
* Processes the given {@code request}
|
||||
*
|
||||
* Processes the given {@code request}.
|
||||
*
|
||||
* @param request the request to process
|
||||
* @return the processed request
|
||||
*/
|
||||
OperationRequest preprocess(OperationRequest request);
|
||||
|
||||
/**
|
||||
* Processes the given {@code response}
|
||||
*
|
||||
* Processes the given {@code response}.
|
||||
*
|
||||
* @param response the response to process
|
||||
* @return the processed response
|
||||
*/
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.springframework.restdocs.operation.OperationRequest;
|
||||
/**
|
||||
* An {@code OperationRequestPreprocessor} is used to modify an {@code OperationRequest}
|
||||
* prior to it being documented.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public interface OperationRequestPreprocessor {
|
||||
@@ -29,7 +29,7 @@ public interface OperationRequestPreprocessor {
|
||||
/**
|
||||
* Processes and potentially modifies the given {@code request} before it is
|
||||
* documented.
|
||||
*
|
||||
*
|
||||
* @param request the request
|
||||
* @return the modified request
|
||||
*/
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.util.regex.Pattern;
|
||||
/**
|
||||
* A {@link ContentModifier} that modifies the content by replacing occurrences of a
|
||||
* regular expression {@link Pattern}.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @author Dewet Diener
|
||||
*/
|
||||
@@ -35,7 +35,7 @@ class PatternReplacingContentModifier implements ContentModifier {
|
||||
/**
|
||||
* Creates a new {@link PatternReplacingContentModifier} that will replace occurences
|
||||
* the given {@code pattern} with the given {@code replacement}.
|
||||
*
|
||||
*
|
||||
* @param pattern the pattern
|
||||
* @param replacement the replacement
|
||||
*/
|
||||
|
||||
@@ -28,10 +28,10 @@ import org.springframework.restdocs.operation.OperationResponse;
|
||||
* OperationPreprocessors} that can be applied to an {@link Operation Operation's}
|
||||
* {@link OperationRequest request} or {@link OperationResponse response} before it is
|
||||
* documented.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class Preprocessors {
|
||||
public final class Preprocessors {
|
||||
|
||||
private Preprocessors() {
|
||||
|
||||
@@ -40,7 +40,7 @@ public class Preprocessors {
|
||||
/**
|
||||
* Returns an {@link OperationRequestPreprocessor} that will preprocess the request by
|
||||
* applying the given {@code preprocessors} to it.
|
||||
*
|
||||
*
|
||||
* @param preprocessors the preprocessors
|
||||
* @return the request preprocessor
|
||||
*/
|
||||
@@ -52,7 +52,7 @@ public class Preprocessors {
|
||||
/**
|
||||
* Returns an {@link OperationResponsePreprocessor} that will preprocess the response
|
||||
* by applying the given {@code preprocessors} to it.
|
||||
*
|
||||
*
|
||||
* @param preprocessors the preprocessors
|
||||
* @return the response preprocessor
|
||||
*/
|
||||
@@ -64,7 +64,7 @@ public class Preprocessors {
|
||||
/**
|
||||
* Returns an {@code OperationPreprocessor} that will pretty print the content of the
|
||||
* request or response.
|
||||
*
|
||||
*
|
||||
* @return the preprocessor
|
||||
*/
|
||||
public static OperationPreprocessor prettyPrint() {
|
||||
@@ -75,7 +75,7 @@ public class Preprocessors {
|
||||
/**
|
||||
* Returns an {@code OperationPreprocessor} that will remove headers from the request
|
||||
* or response.
|
||||
*
|
||||
*
|
||||
* @param headersToRemove the names of the headers to remove
|
||||
* @return the preprocessor
|
||||
*/
|
||||
@@ -86,7 +86,7 @@ public class Preprocessors {
|
||||
/**
|
||||
* Returns an {@code OperationPreprocessor} that will mask the href of hypermedia
|
||||
* links in the request or response.
|
||||
*
|
||||
*
|
||||
* @return the preprocessor
|
||||
*/
|
||||
public static OperationPreprocessor maskLinks() {
|
||||
@@ -96,7 +96,7 @@ public class Preprocessors {
|
||||
/**
|
||||
* Returns an {@code OperationPreprocessor} that will mask the href of hypermedia
|
||||
* links in the request or response.
|
||||
*
|
||||
*
|
||||
* @param mask the link mask
|
||||
* @return the preprocessor
|
||||
*/
|
||||
@@ -108,8 +108,8 @@ public class Preprocessors {
|
||||
/**
|
||||
* Returns an {@code OperationPreprocessor} that will modify the content of the
|
||||
* request or response by replacing occurences of the given {@code pattern} with the
|
||||
* given {@code replacement}
|
||||
*
|
||||
* given {@code replacement}.
|
||||
*
|
||||
* @param pattern the pattern
|
||||
* @param replacement the replacement
|
||||
* @return the preprocessor
|
||||
|
||||
@@ -34,7 +34,7 @@ import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
|
||||
/**
|
||||
* A {@link ContentModifier} that modifies the content by pretty printing it.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class PrettyPrintingContentModifier implements ContentModifier {
|
||||
|
||||
@@ -17,4 +17,5 @@
|
||||
/**
|
||||
* Support for preprocessing an operation prior to it being documented.
|
||||
*/
|
||||
package org.springframework.restdocs.operation.preprocess;
|
||||
package org.springframework.restdocs.operation.preprocess;
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Core Spring REST Docs classes.
|
||||
* Core Spring REST Docs classes.
|
||||
*/
|
||||
package org.springframework.restdocs;
|
||||
package org.springframework.restdocs;
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ public abstract class AbstractFieldsSnippet extends TemplatedSnippet {
|
||||
* {@code <type>-fields}. The fields will be documented using the given
|
||||
* {@code descriptors} and the given {@code attributes} will be included in the model
|
||||
* during template rendering.
|
||||
*
|
||||
*
|
||||
* @param type the type of the fields
|
||||
* @param descriptors the field descriptors
|
||||
* @param attributes the additional attributes
|
||||
@@ -130,7 +130,7 @@ public abstract class AbstractFieldsSnippet extends TemplatedSnippet {
|
||||
/**
|
||||
* Returns the content type of the request or response extracted from the given
|
||||
* {@code operation}.
|
||||
*
|
||||
*
|
||||
* @param operation The operation
|
||||
* @return The content type
|
||||
*/
|
||||
@@ -139,7 +139,7 @@ public abstract class AbstractFieldsSnippet extends TemplatedSnippet {
|
||||
/**
|
||||
* Returns the content of the request or response extracted form the given
|
||||
* {@code operation}.
|
||||
*
|
||||
*
|
||||
* @param operation The operation
|
||||
* @return The content
|
||||
* @throws IOException if the content cannot be extracted
|
||||
@@ -149,7 +149,7 @@ public abstract class AbstractFieldsSnippet extends TemplatedSnippet {
|
||||
/**
|
||||
* Returns the list of {@link FieldDescriptor FieldDescriptors} that will be used to
|
||||
* generate the documentation.
|
||||
*
|
||||
*
|
||||
* @return the field descriptors
|
||||
*/
|
||||
protected final List<FieldDescriptor> getFieldDescriptors() {
|
||||
@@ -157,8 +157,8 @@ public abstract class AbstractFieldsSnippet extends TemplatedSnippet {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a model for the given {@code descriptor}
|
||||
*
|
||||
* Returns a model for the given {@code descriptor}.
|
||||
*
|
||||
* @param descriptor the descriptor
|
||||
* @return the model
|
||||
*/
|
||||
@@ -172,4 +172,4 @@ public abstract class AbstractFieldsSnippet extends TemplatedSnippet {
|
||||
return model;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ package org.springframework.restdocs.payload;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A handler for the content of a request or response
|
||||
*
|
||||
* A handler for the content of a request or response.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
interface ContentHandler {
|
||||
@@ -29,7 +29,7 @@ interface ContentHandler {
|
||||
* Finds the fields that are missing from the handler's payload. A field is missing if
|
||||
* it is described by one of the {@code fieldDescriptors} but is not present in the
|
||||
* payload.
|
||||
*
|
||||
*
|
||||
* @param fieldDescriptors the descriptors
|
||||
* @return descriptors for the fields that are missing from the payload
|
||||
* @throws PayloadHandlingException if a failure occurs
|
||||
@@ -41,7 +41,7 @@ interface ContentHandler {
|
||||
* are undocumented. A field is undocumented if it is present in the handler's content
|
||||
* but is not described by the given {@code fieldDescriptors}. If the content is
|
||||
* completely documented, {@code null} is returned
|
||||
*
|
||||
*
|
||||
* @param fieldDescriptors the descriptors
|
||||
* @return the undocumented content, or {@code null} if all of the content is
|
||||
* documented
|
||||
@@ -52,10 +52,10 @@ interface ContentHandler {
|
||||
/**
|
||||
* Returns the type of the field with the given {@code path} based on the content of
|
||||
* the payload.
|
||||
*
|
||||
*
|
||||
* @param path the field path
|
||||
* @return the type of the field
|
||||
*/
|
||||
Object determineFieldType(String path);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,12 +19,11 @@ package org.springframework.restdocs.payload;
|
||||
import org.springframework.restdocs.snippet.AbstractDescriptor;
|
||||
|
||||
/**
|
||||
* A description of a field found in a request or response payload
|
||||
*
|
||||
* @see PayloadDocumentation#fieldWithPath(String)
|
||||
*
|
||||
* A description of a field found in a request or response payload.
|
||||
*
|
||||
* @author Andreas Evers
|
||||
* @author Andy Wilkinson
|
||||
* @see PayloadDocumentation#fieldWithPath(String)
|
||||
*/
|
||||
public class FieldDescriptor extends AbstractDescriptor<FieldDescriptor> {
|
||||
|
||||
@@ -46,7 +45,7 @@ public class FieldDescriptor extends AbstractDescriptor<FieldDescriptor> {
|
||||
/**
|
||||
* Specifies the type of the field. When documenting a JSON payload, the
|
||||
* {@link JsonFieldType} enumeration will typically be used.
|
||||
*
|
||||
*
|
||||
* @param type The type of the field
|
||||
* @return {@code this}
|
||||
* @see JsonFieldType
|
||||
@@ -57,8 +56,8 @@ public class FieldDescriptor extends AbstractDescriptor<FieldDescriptor> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks the field as optional
|
||||
*
|
||||
* Marks the field as optional.
|
||||
*
|
||||
* @return {@code this}
|
||||
*/
|
||||
public final FieldDescriptor optional() {
|
||||
@@ -67,8 +66,8 @@ public class FieldDescriptor extends AbstractDescriptor<FieldDescriptor> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the path of the field described by this descriptor
|
||||
*
|
||||
* Returns the path of the field described by this descriptor.
|
||||
*
|
||||
* @return the path
|
||||
*/
|
||||
public final String getPath() {
|
||||
@@ -76,8 +75,8 @@ public class FieldDescriptor extends AbstractDescriptor<FieldDescriptor> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of the field described by this descriptor
|
||||
*
|
||||
* Returns the type of the field described by this descriptor.
|
||||
*
|
||||
* @return the type
|
||||
*/
|
||||
public final Object getType() {
|
||||
@@ -85,8 +84,8 @@ public class FieldDescriptor extends AbstractDescriptor<FieldDescriptor> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@code true} if the described field is optional, otherwise {@code false}
|
||||
*
|
||||
* Returns {@code true} if the described field is optional, otherwise {@code false}.
|
||||
*
|
||||
* @return {@code true} if the described field is optional, otherwise {@code false}
|
||||
*/
|
||||
public final boolean isOptional() {
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.springframework.restdocs.payload;
|
||||
/**
|
||||
* A {@code FieldDoesNotExistException} is thrown when a requested field does not exist in
|
||||
* a payload.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
@@ -28,7 +28,7 @@ public class FieldDoesNotExistException extends RuntimeException {
|
||||
/**
|
||||
* Creates a new {@code FieldDoesNotExistException} that indicates that the field with
|
||||
* the given {@code fieldPath} does not exist.
|
||||
*
|
||||
*
|
||||
* @param fieldPath the path of the field that does not exist
|
||||
*/
|
||||
public FieldDoesNotExistException(JsonFieldPath fieldPath) {
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.springframework.restdocs.payload;
|
||||
/**
|
||||
* A {@code FieldTypeRequiredException} is thrown when a field's type cannot be determined
|
||||
* automatically and, therefore, must be explicitly provided.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
@@ -28,7 +28,7 @@ public class FieldTypeRequiredException extends RuntimeException {
|
||||
/**
|
||||
* Creates a new {@code FieldTypeRequiredException} indicating that a type is required
|
||||
* for the reason described in the given {@code message}.
|
||||
*
|
||||
*
|
||||
* @param message the message
|
||||
*/
|
||||
public FieldTypeRequiredException(String message) {
|
||||
|
||||
@@ -26,7 +26,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
|
||||
/**
|
||||
* A {@link ContentHandler} for JSON content
|
||||
* A {@link ContentHandler} for JSON content.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
|
||||
@@ -22,8 +22,8 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* A path that identifies a field in a JSON payload
|
||||
*
|
||||
* A path that identifies a field in a JSON payload.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @author Jeremy Rickard
|
||||
*
|
||||
|
||||
@@ -24,8 +24,8 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
/**
|
||||
* A {@code JsonFieldProcessor} processes a payload's fields, allowing them to be
|
||||
* extracted and removed
|
||||
*
|
||||
* extracted and removed.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*
|
||||
*/
|
||||
@@ -212,8 +212,8 @@ final class JsonFieldProcessor {
|
||||
this(payload, path, null, null);
|
||||
}
|
||||
|
||||
private ProcessingContext(Object payload, JsonFieldPath path, List<String> segments,
|
||||
Match parent) {
|
||||
private ProcessingContext(Object payload, JsonFieldPath path,
|
||||
List<String> segments, Match parent) {
|
||||
this.payload = payload;
|
||||
this.path = path;
|
||||
this.segments = segments == null ? path.getSegments() : segments;
|
||||
|
||||
@@ -21,13 +21,46 @@ import java.util.Locale;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* An enumeration of the possible types for a field in a JSON request or response payload
|
||||
*
|
||||
* An enumeration of the possible types for a field in a JSON request or response payload.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public enum JsonFieldType {
|
||||
|
||||
ARRAY, BOOLEAN, OBJECT, NUMBER, NULL, STRING, VARIES;
|
||||
/**
|
||||
* An array.
|
||||
*/
|
||||
ARRAY,
|
||||
|
||||
/**
|
||||
* A boolean value.
|
||||
*/
|
||||
BOOLEAN,
|
||||
|
||||
/**
|
||||
* An object (map).
|
||||
*/
|
||||
OBJECT,
|
||||
|
||||
/**
|
||||
* A number.
|
||||
*/
|
||||
NUMBER,
|
||||
|
||||
/**
|
||||
* {@code null}.
|
||||
*/
|
||||
NULL,
|
||||
|
||||
/**
|
||||
* A string.
|
||||
*/
|
||||
STRING,
|
||||
|
||||
/**
|
||||
* A variety of different types.
|
||||
*/
|
||||
VARIES;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
@@ -20,8 +20,8 @@ import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Resolves the type of a field in a JSON request or response payload
|
||||
*
|
||||
* Resolves the type of a field in a JSON request or response payload.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
class JsonFieldTypeResolver {
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.springframework.restdocs.snippet.Snippet;
|
||||
|
||||
/**
|
||||
* Static factory methods for documenting a RESTful API's request and response payloads.
|
||||
*
|
||||
*
|
||||
* @author Andreas Evers
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
@@ -43,27 +43,27 @@ public abstract class PayloadDocumentation {
|
||||
* When documenting a JSON payload, the {@code path} uses '.' to descend into a child
|
||||
* object and ' {@code []}' to descend into an array. For example, with this JSON
|
||||
* payload:
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
* {
|
||||
* "a":{
|
||||
* "b":[
|
||||
* {
|
||||
* "c":"one"
|
||||
* },
|
||||
* {
|
||||
* "c":"two"
|
||||
* },
|
||||
* {
|
||||
* "d":"three"
|
||||
* }
|
||||
* ]
|
||||
* }
|
||||
* }
|
||||
* "a":{
|
||||
* "b":[
|
||||
* {
|
||||
* "c":"one"
|
||||
* },
|
||||
* {
|
||||
* "c":"two"
|
||||
* },
|
||||
* {
|
||||
* "d":"three"
|
||||
* }
|
||||
* ]
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* The following paths are all present:
|
||||
*
|
||||
*
|
||||
* <table summary="Paths and their values">
|
||||
* <tr>
|
||||
* <th>Path</th>
|
||||
@@ -90,7 +90,7 @@ public abstract class PayloadDocumentation {
|
||||
* <td>The string "three"</td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
*
|
||||
* @param path The path of the field
|
||||
* @return a {@code FieldDescriptor} ready for further configuration
|
||||
*/
|
||||
@@ -108,7 +108,7 @@ public abstract class PayloadDocumentation {
|
||||
* a failure will also occur. For payloads with a hierarchical structure, documenting
|
||||
* a field is sufficient for all of its descendants to also be treated as having been
|
||||
* documented.
|
||||
*
|
||||
*
|
||||
* @param descriptors The descriptions of the request's fields
|
||||
* @return the handler
|
||||
* @see #fieldWithPath(String)
|
||||
@@ -128,7 +128,7 @@ public abstract class PayloadDocumentation {
|
||||
* a failure will also occur. For payloads with a hierarchical structure, documenting
|
||||
* a field is sufficient for all of its descendants to also be treated as having been
|
||||
* documented.
|
||||
*
|
||||
*
|
||||
* @param attributes Attributes made available during rendering of the snippet
|
||||
* @param descriptors The descriptions of the request's fields
|
||||
* @return the handler
|
||||
@@ -149,7 +149,7 @@ public abstract class PayloadDocumentation {
|
||||
* a failure will also occur. For payloads with a hierarchical structure, documenting
|
||||
* a field is sufficient for all of its descendants to also be treated as having been
|
||||
* documented.
|
||||
*
|
||||
*
|
||||
* @param descriptors The descriptions of the response's fields
|
||||
* @return the handler
|
||||
* @see #fieldWithPath(String)
|
||||
@@ -169,7 +169,7 @@ public abstract class PayloadDocumentation {
|
||||
* a failure will also occur. For payloads with a hierarchical structure, documenting
|
||||
* a field is sufficient for all of its descendants to also be treated as having been
|
||||
* documented.
|
||||
*
|
||||
*
|
||||
* @param attributes Attributes made available during rendering of the snippet
|
||||
* @param descriptors The descriptions of the response's fields
|
||||
* @return the handler
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package org.springframework.restdocs.payload;
|
||||
|
||||
/**
|
||||
* Thrown to indicate that a failure has occurred during payload handling
|
||||
* Thrown to indicate that a failure has occurred during payload handling.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*
|
||||
@@ -26,7 +26,7 @@ package org.springframework.restdocs.payload;
|
||||
class PayloadHandlingException extends RuntimeException {
|
||||
|
||||
/**
|
||||
* Creates a new {@code PayloadHandlingException} with the given cause
|
||||
* Creates a new {@code PayloadHandlingException} with the given cause.
|
||||
* @param cause the cause of the failure
|
||||
*/
|
||||
PayloadHandlingException(Throwable cause) {
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.springframework.restdocs.snippet.Snippet;
|
||||
|
||||
/**
|
||||
* A {@link Snippet} that documents the fields in a request.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @see PayloadDocumentation#requestFields(FieldDescriptor...)
|
||||
* @see PayloadDocumentation#requestFields(Map, FieldDescriptor...)
|
||||
@@ -36,7 +36,7 @@ public class RequestFieldsSnippet extends AbstractFieldsSnippet {
|
||||
/**
|
||||
* Creates a new {@code RequestFieldsSnippet} that will document the fields in the
|
||||
* request using the given {@code descriptors}.
|
||||
*
|
||||
*
|
||||
* @param descriptors the descriptors
|
||||
*/
|
||||
protected RequestFieldsSnippet(List<FieldDescriptor> descriptors) {
|
||||
@@ -47,7 +47,7 @@ public class RequestFieldsSnippet extends AbstractFieldsSnippet {
|
||||
* Creates a new {@code RequestFieldsSnippet} that will document the fields in the
|
||||
* request using the given {@code descriptors}. The given {@code attributes} will be
|
||||
* included in the model during template rendering.
|
||||
*
|
||||
*
|
||||
* @param descriptors the descriptors
|
||||
* @param attributes the additional attributes
|
||||
*/
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.restdocs.payload;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -25,7 +26,7 @@ import org.springframework.restdocs.snippet.Snippet;
|
||||
|
||||
/**
|
||||
* A {@link Snippet} that documents the fields in a response.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @see PayloadDocumentation#responseFields(FieldDescriptor...)
|
||||
* @see PayloadDocumentation#responseFields(Map, FieldDescriptor...)
|
||||
@@ -35,7 +36,7 @@ public class ResponseFieldsSnippet extends AbstractFieldsSnippet {
|
||||
/**
|
||||
* Creates a new {@code ResponseFieldsSnippet} that will document the fields in the
|
||||
* response using the given {@code descriptors}.
|
||||
*
|
||||
*
|
||||
* @param descriptors the descriptors
|
||||
*/
|
||||
protected ResponseFieldsSnippet(List<FieldDescriptor> descriptors) {
|
||||
@@ -46,7 +47,7 @@ public class ResponseFieldsSnippet extends AbstractFieldsSnippet {
|
||||
* Creates a new {@code ResponseFieldsSnippet} that will document the fields in the
|
||||
* response using the given {@code descriptors}. The given {@code attributes} will be
|
||||
* included in the model during template rendering.
|
||||
*
|
||||
*
|
||||
* @param descriptors the descriptors
|
||||
* @param attributes the additional attributes
|
||||
*/
|
||||
|
||||
@@ -40,8 +40,8 @@ import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.InputSource;
|
||||
|
||||
/**
|
||||
* A {@link ContentHandler} for XML content
|
||||
*
|
||||
* A {@link ContentHandler} for XML content.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
class XmlContentHandler implements ContentHandler {
|
||||
|
||||
@@ -17,4 +17,5 @@
|
||||
/**
|
||||
* Documenting the payload of a RESTful API's requests and responses.
|
||||
*/
|
||||
package org.springframework.restdocs.payload;
|
||||
package org.springframework.restdocs.payload;
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ public abstract class AbstractParametersSnippet extends TemplatedSnippet {
|
||||
* the given {@code snippetName} that will document parameters using the given
|
||||
* {@code descriptors}. The given {@code attributes} will be included in the model
|
||||
* during template rendering.
|
||||
*
|
||||
*
|
||||
* @param snippetName The snippet name
|
||||
* @param descriptors The descriptors
|
||||
* @param attributes The additional attributes
|
||||
@@ -73,7 +73,7 @@ public abstract class AbstractParametersSnippet extends TemplatedSnippet {
|
||||
return model;
|
||||
}
|
||||
|
||||
protected void verifyParameterDescriptors(Operation operation) {
|
||||
private void verifyParameterDescriptors(Operation operation) {
|
||||
Set<String> actualParameters = extractActualParameters(operation);
|
||||
Set<String> expectedParameters = this.descriptorsByName.keySet();
|
||||
Set<String> undocumentedParameters = new HashSet<String>(actualParameters);
|
||||
@@ -84,13 +84,25 @@ public abstract class AbstractParametersSnippet extends TemplatedSnippet {
|
||||
if (!undocumentedParameters.isEmpty() || !missingParameters.isEmpty()) {
|
||||
verificationFailed(undocumentedParameters, missingParameters);
|
||||
}
|
||||
else {
|
||||
Assert.isTrue(actualParameters.equals(expectedParameters));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the names of the parameters that were present in the given
|
||||
* {@code operation}.
|
||||
*
|
||||
* @param operation the operation
|
||||
* @return the parameters
|
||||
*/
|
||||
protected abstract Set<String> extractActualParameters(Operation operation);
|
||||
|
||||
/**
|
||||
* Called when the documented parameters do not match the actual parameters.
|
||||
*
|
||||
* @param undocumentedParameters the parameters that were found in the operation but
|
||||
* were not documented
|
||||
* @param missingParameters the parameters that were documented but were not found in
|
||||
* the operation
|
||||
*/
|
||||
protected abstract void verificationFailed(Set<String> undocumentedParameters,
|
||||
Set<String> missingParameters);
|
||||
|
||||
@@ -98,7 +110,7 @@ public abstract class AbstractParametersSnippet extends TemplatedSnippet {
|
||||
* Returns a {@code Map} of {@link ParameterDescriptor ParameterDescriptors} that will
|
||||
* be used to generate the documentation key by their
|
||||
* {@link ParameterDescriptor#getName()}.
|
||||
*
|
||||
*
|
||||
* @return the map of path descriptors
|
||||
*/
|
||||
protected final Map<String, ParameterDescriptor> getFieldDescriptors() {
|
||||
@@ -107,7 +119,7 @@ public abstract class AbstractParametersSnippet extends TemplatedSnippet {
|
||||
|
||||
/**
|
||||
* Returns a model for the given {@code descriptor}.
|
||||
*
|
||||
*
|
||||
* @param descriptor the descriptor
|
||||
* @return the model
|
||||
*/
|
||||
|
||||
@@ -19,8 +19,8 @@ package org.springframework.restdocs.request;
|
||||
import org.springframework.restdocs.snippet.AbstractDescriptor;
|
||||
|
||||
/**
|
||||
* A descriptor of a request or path parameter
|
||||
*
|
||||
* A descriptor of a request or path parameter.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @see RequestDocumentation#parameterWithName
|
||||
*
|
||||
@@ -32,7 +32,7 @@ public class ParameterDescriptor extends AbstractDescriptor<ParameterDescriptor>
|
||||
/**
|
||||
* Creates a new {@code ParameterDescriptor} describing the parameter with the given
|
||||
* {@code name}.
|
||||
*
|
||||
*
|
||||
* @param name the name of the parameter
|
||||
*/
|
||||
protected ParameterDescriptor(String name) {
|
||||
@@ -40,8 +40,8 @@ public class ParameterDescriptor extends AbstractDescriptor<ParameterDescriptor>
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the parameter being described by this descriptor
|
||||
*
|
||||
* Returns the name of the parameter being described by this descriptor.
|
||||
*
|
||||
* @return the name of the parameter
|
||||
*/
|
||||
public final String getName() {
|
||||
|
||||
@@ -42,7 +42,7 @@ public class PathParametersSnippet extends AbstractParametersSnippet {
|
||||
/**
|
||||
* Creates a new {@code PathParametersSnippet} that will document the request's path
|
||||
* parameters using the given {@code descriptors}.
|
||||
*
|
||||
*
|
||||
* @param descriptors the parameter descriptors
|
||||
*/
|
||||
protected PathParametersSnippet(List<ParameterDescriptor> descriptors) {
|
||||
@@ -53,7 +53,7 @@ public class PathParametersSnippet extends AbstractParametersSnippet {
|
||||
* Creates a new {@code PathParametersSnippet} that will document the request's path
|
||||
* parameters using the given {@code descriptors}. The given {@code attributes} will
|
||||
* be included in the model during template rendering.
|
||||
*
|
||||
*
|
||||
* @param descriptors the parameter descriptors
|
||||
* @param attributes the additional attributes
|
||||
*/
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
/**
|
||||
* Static factory methods for documenting aspects of a request sent to a RESTful API.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public abstract class RequestDocumentation {
|
||||
@@ -39,7 +39,7 @@ public abstract class RequestDocumentation {
|
||||
/**
|
||||
* Creates a {@link ParameterDescriptor} that describes a request or path parameter
|
||||
* with the given {@code name}.
|
||||
*
|
||||
*
|
||||
* @param name The name of the parameter
|
||||
* @return a {@link ParameterDescriptor} ready for further configuration
|
||||
*/
|
||||
@@ -50,7 +50,7 @@ public abstract class RequestDocumentation {
|
||||
/**
|
||||
* Returns a snippet that will document the path parameters from the API call's
|
||||
* request.
|
||||
*
|
||||
*
|
||||
* @param descriptors The descriptions of the parameters in the request's path
|
||||
* @return the snippet
|
||||
* @see PathVariable
|
||||
@@ -62,7 +62,7 @@ public abstract class RequestDocumentation {
|
||||
/**
|
||||
* Returns a snippet that will document the path parameters from the API call's
|
||||
* request. The given {@code attributes} will be available during snippet rendering.
|
||||
*
|
||||
*
|
||||
* @param attributes Attributes made available during rendering of the path parameters
|
||||
* snippet
|
||||
* @param descriptors The descriptions of the parameters in the request's path
|
||||
@@ -77,7 +77,7 @@ public abstract class RequestDocumentation {
|
||||
/**
|
||||
* Returns a snippet that will document the request parameters from the API call's
|
||||
* request.
|
||||
*
|
||||
*
|
||||
* @param descriptors The descriptions of the request's parameters
|
||||
* @return the snippet
|
||||
* @see RequestParam
|
||||
@@ -90,7 +90,7 @@ public abstract class RequestDocumentation {
|
||||
/**
|
||||
* Returns a snippet that will document the request parameters from the API call's
|
||||
* request. The given {@code attributes} will be available during snippet rendering.
|
||||
*
|
||||
*
|
||||
* @param attributes Attributes made available during rendering of the request
|
||||
* parameters snippet
|
||||
* @param descriptors The descriptions of the request's parameters
|
||||
|
||||
@@ -41,7 +41,7 @@ public class RequestParametersSnippet extends AbstractParametersSnippet {
|
||||
/**
|
||||
* Creates a new {@code RequestParametersSnippet} that will document the request's
|
||||
* parameters using the given {@code descriptors}.
|
||||
*
|
||||
*
|
||||
* @param descriptors the parameter descriptors
|
||||
*/
|
||||
protected RequestParametersSnippet(List<ParameterDescriptor> descriptors) {
|
||||
@@ -52,7 +52,7 @@ public class RequestParametersSnippet extends AbstractParametersSnippet {
|
||||
* Creates a new {@code RequestParametersSnippet} that will document the request's
|
||||
* parameters using the given {@code descriptors}. The given {@code attributes} will
|
||||
* be included in the model during template rendering.
|
||||
*
|
||||
*
|
||||
* @param descriptors the parameter descriptors
|
||||
* @param attributes the additional attributes
|
||||
*/
|
||||
|
||||
@@ -17,4 +17,5 @@
|
||||
/**
|
||||
* Documenting query and path parameters of requests sent to a RESTful API.
|
||||
*/
|
||||
package org.springframework.restdocs.request;
|
||||
package org.springframework.restdocs.request;
|
||||
|
||||
|
||||
@@ -25,9 +25,8 @@ import org.springframework.restdocs.snippet.Attributes.Attribute;
|
||||
* Base class for descriptors. Provides the ability to associate arbitrary attributes with
|
||||
* a descriptor.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*
|
||||
* @param <T> the type of the descriptor
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public abstract class AbstractDescriptor<T extends AbstractDescriptor<T>> {
|
||||
|
||||
@@ -36,7 +35,7 @@ public abstract class AbstractDescriptor<T extends AbstractDescriptor<T>> {
|
||||
private Object description;
|
||||
|
||||
/**
|
||||
* Adds the given {@code attributes} to the descriptor
|
||||
* Adds the given {@code attributes} to the descriptor.
|
||||
*
|
||||
* @param attributes the attributes
|
||||
* @return the descriptor
|
||||
@@ -50,8 +49,8 @@ public abstract class AbstractDescriptor<T extends AbstractDescriptor<T>> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the description
|
||||
*
|
||||
* Specifies the description.
|
||||
*
|
||||
* @param description the description
|
||||
* @return the descriptor
|
||||
*/
|
||||
@@ -62,8 +61,8 @@ public abstract class AbstractDescriptor<T extends AbstractDescriptor<T>> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the description
|
||||
*
|
||||
* Returns the description.
|
||||
*
|
||||
* @return the description
|
||||
*/
|
||||
public final Object getDescription() {
|
||||
@@ -71,7 +70,7 @@ public abstract class AbstractDescriptor<T extends AbstractDescriptor<T>> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the descriptor's attributes
|
||||
* Returns the descriptor's attributes.
|
||||
*
|
||||
* @return the attributes
|
||||
*/
|
||||
|
||||
@@ -13,14 +13,15 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.restdocs.snippet;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* A fluent API for building a map of attributes
|
||||
*
|
||||
* A fluent API for building a map of attributes.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public abstract class Attributes {
|
||||
@@ -32,7 +33,7 @@ public abstract class Attributes {
|
||||
/**
|
||||
* Creates an attribute with the given {@code key}. A value for the attribute must
|
||||
* still be specified.
|
||||
*
|
||||
*
|
||||
* @param key The key of the attribute
|
||||
* @return An {@code AttributeBuilder} to use to specify the value of the attribute
|
||||
* @see AttributeBuilder#value(Object)
|
||||
@@ -43,7 +44,7 @@ public abstract class Attributes {
|
||||
|
||||
/**
|
||||
* Creates a {@code Map} of the given {@code attributes}.
|
||||
*
|
||||
*
|
||||
* @param attributes The attributes
|
||||
* @return A Map of the attributes
|
||||
*/
|
||||
@@ -56,9 +57,9 @@ public abstract class Attributes {
|
||||
}
|
||||
|
||||
/**
|
||||
* A simple builder for an attribute (key-value pair)
|
||||
* A simple builder for an attribute (key-value pair).
|
||||
*/
|
||||
public static class AttributeBuilder {
|
||||
public static final class AttributeBuilder {
|
||||
|
||||
private final String key;
|
||||
|
||||
@@ -67,8 +68,8 @@ public abstract class Attributes {
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the value of the attribute
|
||||
*
|
||||
* Configures the value of the attribute.
|
||||
*
|
||||
* @param value The attribute's value
|
||||
* @return A newly created {@code Attribute}
|
||||
*/
|
||||
@@ -81,7 +82,7 @@ public abstract class Attributes {
|
||||
/**
|
||||
* An attribute (key-value pair).
|
||||
*/
|
||||
public static class Attribute {
|
||||
public static final class Attribute {
|
||||
|
||||
private final String key;
|
||||
|
||||
@@ -89,6 +90,7 @@ public abstract class Attributes {
|
||||
|
||||
/**
|
||||
* Creates a new attribute with the given {@code key} and {@code value}.
|
||||
*
|
||||
* @param key the key
|
||||
* @param value the value
|
||||
*/
|
||||
@@ -98,7 +100,8 @@ public abstract class Attributes {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the attribute's key
|
||||
* Returns the attribute's key.
|
||||
*
|
||||
* @return the key
|
||||
*/
|
||||
public String getKey() {
|
||||
@@ -106,7 +109,8 @@ public abstract class Attributes {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the attribute's value
|
||||
* Returns the attribute's value.
|
||||
*
|
||||
* @return the value
|
||||
*/
|
||||
public Object getValue() {
|
||||
|
||||
@@ -13,23 +13,22 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.restdocs.snippet;
|
||||
|
||||
import org.springframework.restdocs.operation.Operation;
|
||||
package org.springframework.restdocs.snippet;
|
||||
|
||||
/**
|
||||
* An exception that can be thrown by a {@link TemplatedSnippet} to indicate that a
|
||||
* failure has occurred during model creation.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @see TemplatedSnippet#createModel(Operation)
|
||||
* @see TemplatedSnippet#createModel(org.springframework.restdocs.operation.Operation)
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class ModelCreationException extends RuntimeException {
|
||||
|
||||
/**
|
||||
* Creates a new {@code ModelCreationException} with the given {@code cause}.
|
||||
*
|
||||
*
|
||||
* @param cause the cause
|
||||
*/
|
||||
public ModelCreationException(Throwable cause) {
|
||||
@@ -39,7 +38,7 @@ public class ModelCreationException extends RuntimeException {
|
||||
/**
|
||||
* Creates a new {@code ModelCreationException} with the given {@code message} and
|
||||
* {@code cause}.
|
||||
*
|
||||
*
|
||||
* @param message the message
|
||||
* @param cause the cause
|
||||
*/
|
||||
|
||||
@@ -46,7 +46,7 @@ import org.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver;
|
||||
* {@link RestDocumentationContext#getTestClass() current test class} formatted using
|
||||
* snake case
|
||||
* </ul>
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class RestDocumentationContextPlaceholderResolver implements PlaceholderResolver {
|
||||
@@ -58,7 +58,7 @@ public class RestDocumentationContextPlaceholderResolver implements PlaceholderR
|
||||
/**
|
||||
* Creates a new placeholder resolver that will resolve placeholders using the given
|
||||
* {@code context}.
|
||||
*
|
||||
*
|
||||
* @param context the context to use
|
||||
*/
|
||||
public RestDocumentationContextPlaceholderResolver(RestDocumentationContext context) {
|
||||
@@ -93,7 +93,7 @@ public class RestDocumentationContextPlaceholderResolver implements PlaceholderR
|
||||
|
||||
/**
|
||||
* Converts the given {@code string} from camelCase to kebab-case.
|
||||
*
|
||||
*
|
||||
* @param string the string
|
||||
* @return the converted string
|
||||
*/
|
||||
@@ -103,7 +103,7 @@ public class RestDocumentationContextPlaceholderResolver implements PlaceholderR
|
||||
|
||||
/**
|
||||
* Converts the given {@code string} from camelCase to snake_case.
|
||||
*
|
||||
*
|
||||
* @param string the string
|
||||
* @return the converted string
|
||||
*/
|
||||
@@ -114,7 +114,7 @@ public class RestDocumentationContextPlaceholderResolver implements PlaceholderR
|
||||
/**
|
||||
* Returns the {@link RestDocumentationContext} that should be used during placeholder
|
||||
* resolution.
|
||||
*
|
||||
*
|
||||
* @return the context
|
||||
*/
|
||||
protected final RestDocumentationContext getContext() {
|
||||
|
||||
@@ -22,14 +22,14 @@ import org.springframework.restdocs.operation.Operation;
|
||||
|
||||
/**
|
||||
* A {@link Snippet} is used to document aspects of a call to a RESTful API.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public interface Snippet {
|
||||
|
||||
/**
|
||||
* Documents the call to the RESTful API described by the given {@code operation}.
|
||||
*
|
||||
*
|
||||
* @param operation the API operation
|
||||
* @throws IOException if a failure occurs will documenting the operation
|
||||
*/
|
||||
|
||||
@@ -19,14 +19,15 @@ package org.springframework.restdocs.snippet;
|
||||
/**
|
||||
* A {@link RuntimeException} thrown to indicate a problem with the generation of a
|
||||
* documentation snippet.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class SnippetException extends RuntimeException {
|
||||
|
||||
/**
|
||||
* Creates a new {@code SnippetException} described by the given {@code message}
|
||||
* Creates a new {@code SnippetException} described by the given {@code message}.
|
||||
*
|
||||
* @param message the message that describes the problem
|
||||
*/
|
||||
public SnippetException(String message) {
|
||||
|
||||
@@ -28,10 +28,10 @@ import org.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver;
|
||||
|
||||
/**
|
||||
* Standard implementation of {@link WriterResolver}.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class StandardWriterResolver implements WriterResolver {
|
||||
public final class StandardWriterResolver implements WriterResolver {
|
||||
|
||||
private String encoding = "UTF-8";
|
||||
|
||||
@@ -44,7 +44,7 @@ public class StandardWriterResolver implements WriterResolver {
|
||||
* Creates a new {@code StandardWriterResolver} that will use the given
|
||||
* {@code placeholderResolver} to resolve any placeholders in the
|
||||
* {@code operationName}.
|
||||
*
|
||||
*
|
||||
* @param placeholderResolver the placeholder resolver
|
||||
*/
|
||||
public StandardWriterResolver(PlaceholderResolver placeholderResolver) {
|
||||
@@ -71,7 +71,7 @@ public class StandardWriterResolver implements WriterResolver {
|
||||
this.encoding = encoding;
|
||||
}
|
||||
|
||||
protected File resolveFile(String outputDirectory, String fileName,
|
||||
File resolveFile(String outputDirectory, String fileName,
|
||||
RestDocumentationContext context) {
|
||||
File outputFile = new File(outputDirectory, fileName);
|
||||
if (!outputFile.isAbsolute()) {
|
||||
|
||||
@@ -42,7 +42,7 @@ public abstract class TemplatedSnippet implements Snippet {
|
||||
* Creates a new {@code TemplatedSnippet} that will produce a snippet with the given
|
||||
* {@code snippetName}. The given {@code attributes} will be included in the model
|
||||
* during rendering of the template.
|
||||
*
|
||||
*
|
||||
* @param snippetName The name of the snippet
|
||||
* @param attributes The additional attributes
|
||||
*/
|
||||
@@ -74,7 +74,7 @@ public abstract class TemplatedSnippet implements Snippet {
|
||||
* given {@code operation}. Any additional attributes that were supplied when this
|
||||
* {@code TemplatedSnippet} were created will be automatically added to the model
|
||||
* prior to rendering.
|
||||
*
|
||||
*
|
||||
* @param operation The operation
|
||||
* @return the model
|
||||
* @throws ModelCreationException if model creation fails
|
||||
@@ -84,7 +84,7 @@ public abstract class TemplatedSnippet implements Snippet {
|
||||
/**
|
||||
* Returns the additional attributes that will be included in the model during
|
||||
* template rendering.
|
||||
*
|
||||
*
|
||||
* @return the additional attributes
|
||||
*/
|
||||
protected final Map<String, Object> getAttributes() {
|
||||
@@ -93,11 +93,11 @@ public abstract class TemplatedSnippet implements Snippet {
|
||||
|
||||
/**
|
||||
* Returns the name of the snippet that will be created.
|
||||
*
|
||||
*
|
||||
* @return the snippet name
|
||||
*/
|
||||
protected final String getSnippetName() {
|
||||
return this.snippetName;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.springframework.restdocs.RestDocumentationContext;
|
||||
/**
|
||||
* A {@code WriterResolver} is used to access the {@link Writer} that should be used to
|
||||
* write a snippet for an operation that is being documented.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public interface WriterResolver {
|
||||
@@ -32,6 +32,7 @@ public interface WriterResolver {
|
||||
/**
|
||||
* Returns a writer that can be used to write the snippet with the given name for the
|
||||
* operation with the given name.
|
||||
*
|
||||
* @param operationName the name of the operation that is being documented
|
||||
* @param snippetName the name of the snippet
|
||||
* @param restDocumentationContext the current documentation context
|
||||
@@ -43,7 +44,8 @@ public interface WriterResolver {
|
||||
|
||||
/**
|
||||
* Configures the encoding that should be used by any writers produced by this
|
||||
* resolver
|
||||
* resolver.
|
||||
*
|
||||
* @param encoding the encoding
|
||||
*/
|
||||
void setEncoding(String encoding);
|
||||
|
||||
@@ -17,4 +17,5 @@
|
||||
/**
|
||||
* Snippet generation.
|
||||
*/
|
||||
package org.springframework.restdocs.snippet;
|
||||
package org.springframework.restdocs.snippet;
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.restdocs.templates;
|
||||
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
@@ -26,7 +27,7 @@ import org.springframework.core.io.Resource;
|
||||
* resource exists {@code default-} is prepended to the name and the classpath is checked
|
||||
* again. The built-in snippet templates are all named {@code default- name}, thereby
|
||||
* allowing them to be overridden.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class StandardTemplateResourceResolver implements TemplateResourceResolver {
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.springframework.restdocs.templates.mustache.MustacheTemplateEngine;
|
||||
|
||||
/**
|
||||
* A {@code TemplateEngine} is used to render documentation snippets.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @see MustacheTemplateEngine
|
||||
*/
|
||||
@@ -32,7 +32,7 @@ public interface TemplateEngine {
|
||||
* Compiles the template at the given {@code path}. Typically, a
|
||||
* {@link TemplateResourceResolver} will be used to resolve the path into a resource
|
||||
* that can be read and compiled.
|
||||
*
|
||||
*
|
||||
* @param path the path of the template
|
||||
* @return the compiled {@code Template}
|
||||
* @throws IOException if compilation fails
|
||||
|
||||
@@ -21,17 +21,17 @@ import org.springframework.core.io.Resource;
|
||||
/**
|
||||
* A {@code TemplateResourceResolver} is responsible for resolving a name for a template
|
||||
* into a {@link Resource} from which the template can be read.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public interface TemplateResourceResolver {
|
||||
|
||||
/**
|
||||
* Resolves a {@link Resource} for the template with the given {@code name}.
|
||||
*
|
||||
*
|
||||
* @param name the name of the template
|
||||
* @return the {@code Resource} from which the template can be read
|
||||
*/
|
||||
public Resource resolveTemplateResource(String name);
|
||||
Resource resolveTemplateResource(String name);
|
||||
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.restdocs.templates.mustache;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -22,7 +23,7 @@ import org.springframework.restdocs.templates.Template;
|
||||
/**
|
||||
* An adapter that exposes a compiled <a href="https://mustache.github.io">Mustache</a>
|
||||
* template as a {@link Template}.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class MustacheTemplate implements Template {
|
||||
@@ -33,6 +34,7 @@ public class MustacheTemplate implements Template {
|
||||
* Creates a new {@code MustacheTemplate} that adapts the given {@code delegate}. When
|
||||
* rendered, the given {@code defaultContext} will be combined with the render context
|
||||
* prior to executing the delegate.
|
||||
*
|
||||
* @param delegate The delegate to adapt
|
||||
*/
|
||||
public MustacheTemplate(org.springframework.restdocs.mustache.Template delegate) {
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.restdocs.templates.mustache;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -30,7 +31,7 @@ import org.springframework.restdocs.templates.TemplateResourceResolver;
|
||||
* implemented using <a href="https://github.com/samskivert/jmustache">JMustache</a>.
|
||||
* <p>
|
||||
* Note that JMustache has been repackaged and embedded to prevent classpath conflicts.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class MustacheTemplateEngine implements TemplateEngine {
|
||||
@@ -42,7 +43,7 @@ public class MustacheTemplateEngine implements TemplateEngine {
|
||||
/**
|
||||
* Creates a new {@link MustacheTemplateEngine} that will use the given
|
||||
* {@code templateResourceResolver} to resolve template paths.
|
||||
*
|
||||
*
|
||||
* @param templateResourceResolver The resolve to use
|
||||
*/
|
||||
public MustacheTemplateEngine(TemplateResourceResolver templateResourceResolver) {
|
||||
|
||||
@@ -17,4 +17,5 @@
|
||||
/**
|
||||
* JMustache-based implementation of the template API.
|
||||
*/
|
||||
package org.springframework.restdocs.templates.mustache;
|
||||
package org.springframework.restdocs.templates.mustache;
|
||||
|
||||
|
||||
@@ -17,4 +17,5 @@
|
||||
/**
|
||||
* Template API used to render documentation snippets.
|
||||
*/
|
||||
package org.springframework.restdocs.templates;
|
||||
package org.springframework.restdocs.templates;
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user