├── .github ├── actions │ ├── await-http-resource │ │ └── action.yml │ ├── build │ │ └── action.yml │ ├── create-github-release │ │ ├── action.yml │ │ └── changelog-generator.yml │ ├── prepare-gradle-build │ │ └── action.yml │ ├── print-jvm-thread-dumps │ │ └── action.yml │ ├── send-notification │ │ └── action.yml │ └── sync-to-maven-central │ │ ├── action.yml │ │ └── artifacts.spec ├── dco.yml └── workflows │ ├── build-and-deploy-snapshot.yml │ ├── build-pull-request.yml │ ├── ci.yml │ ├── delete-staged-release.yml │ └── release.yml ├── .gitignore ├── .idea └── icon.svg ├── .sdkmanrc ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE.txt ├── README.md ├── build.gradle ├── buildSrc ├── build.gradle └── src │ └── main │ ├── java │ └── org │ │ └── springframework │ │ └── restdocs │ │ └── build │ │ └── optional │ │ └── OptionalDependenciesPlugin.java │ └── resources │ └── META-INF │ └── gradle-plugins │ └── optional-dependencies.properties ├── ci ├── README.adoc ├── config │ ├── changelog-generator.yml │ └── release-scripts.yml ├── images │ ├── README.adoc │ ├── ci-image │ │ └── Dockerfile │ ├── get-jdk-url.sh │ └── setup.sh ├── parameters.yml ├── pipeline.yml ├── scripts │ ├── build-project-windows.bat │ ├── build-project.sh │ ├── common.sh │ ├── generate-changelog.sh │ ├── promote.sh │ └── stage.sh └── tasks │ ├── build-ci-image.yml │ ├── build-project-windows.yml │ ├── build-project.yml │ ├── generate-changelog.yml │ ├── promote.yml │ └── stage.yml ├── config └── checkstyle │ ├── checkstyle-suppressions.xml │ └── checkstyle.xml ├── docs ├── build.gradle └── src │ ├── docs │ └── asciidoc │ │ ├── configuration.adoc │ │ ├── contributing.adoc │ │ ├── customizing-requests-and-responses.adoc │ │ ├── documenting-your-api.adoc │ │ ├── getting-started.adoc │ │ ├── index.adoc │ │ ├── introduction.adoc │ │ ├── working-with-asciidoctor.adoc │ │ └── working-with-markdown.adoc │ └── test │ └── java │ └── com │ └── example │ ├── Constraints.java │ ├── Hypermedia.java │ ├── Payload.java │ ├── SnippetReuse.java │ ├── mockmvc │ ├── CustomDefaultOperationPreprocessors.java │ ├── CustomDefaultSnippets.java │ ├── CustomEncoding.java │ ├── CustomFormat.java │ ├── CustomUriConfiguration.java │ ├── EveryTestPreprocessing.java │ ├── ExampleApplicationJUnit5Tests.java │ ├── ExampleApplicationTestNgTests.java │ ├── ExampleApplicationTests.java │ ├── FormParameters.java │ ├── HttpCookies.java │ ├── HttpHeaders.java │ ├── Hypermedia.java │ ├── InvokeService.java │ ├── MockMvcSnippetReuse.java │ ├── ParameterizedOutput.java │ ├── PathParameters.java │ ├── Payload.java │ ├── PerTestPreprocessing.java │ ├── QueryParameters.java │ ├── RequestPartPayload.java │ └── RequestParts.java │ ├── restassured │ ├── CustomDefaultOperationPreprocessors.java │ ├── CustomDefaultSnippets.java │ ├── CustomEncoding.java │ ├── CustomFormat.java │ ├── EveryTestPreprocessing.java │ ├── ExampleApplicationJUnit5Tests.java │ ├── ExampleApplicationTestNgTests.java │ ├── ExampleApplicationTests.java │ ├── FormParameters.java │ ├── HttpCookies.java │ ├── HttpHeaders.java │ ├── Hypermedia.java │ ├── InvokeService.java │ ├── ParameterizedOutput.java │ ├── PathParameters.java │ ├── Payload.java │ ├── PerTestPreprocessing.java │ ├── QueryParameters.java │ ├── RequestPartPayload.java │ ├── RequestParts.java │ └── RestAssuredSnippetReuse.java │ └── webtestclient │ ├── CustomDefaultOperationPreprocessors.java │ ├── CustomDefaultSnippets.java │ ├── CustomEncoding.java │ ├── CustomFormat.java │ ├── CustomUriConfiguration.java │ ├── EveryTestPreprocessing.java │ ├── ExampleApplicationJUnit5Tests.java │ ├── ExampleApplicationTestNgTests.java │ ├── ExampleApplicationTests.java │ ├── FormParameters.java │ ├── HttpCookies.java │ ├── HttpHeaders.java │ ├── Hypermedia.java │ ├── InvokeService.java │ ├── ParameterizedOutput.java │ ├── PathParameters.java │ ├── Payload.java │ ├── PerTestPreprocessing.java │ ├── QueryParameters.java │ ├── RequestPartPayload.java │ ├── RequestParts.java │ └── WebTestClientSnippetReuse.java ├── git └── hooks │ ├── forward-merge │ └── prepare-forward-merge ├── gradle.properties ├── gradle ├── publish-maven.gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle ├── spring-restdocs-asciidoctor ├── build.gradle └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── springframework │ │ │ └── restdocs │ │ │ └── asciidoctor │ │ │ ├── DefaultAttributesPreprocessor.java │ │ │ ├── RestDocsExtensionRegistry.java │ │ │ ├── SnippetsDirectoryResolver.java │ │ │ └── package-info.java │ └── resources │ │ ├── META-INF │ │ └── services │ │ │ └── org.asciidoctor.jruby.extension.spi.ExtensionRegistry │ │ └── extensions │ │ └── operation_block_macro.rb │ └── test │ ├── java │ └── org │ │ └── springframework │ │ └── restdocs │ │ └── asciidoctor │ │ ├── AbstractOperationBlockMacroTests.java │ │ ├── CapturingLogHandler.java │ │ ├── DefaultAttributesPreprocessorTests.java │ │ ├── GradleOperationBlockMacroTests.java │ │ ├── MavenOperationBlockMacroTests.java │ │ └── SnippetsDirectoryResolverTests.java │ └── resources │ ├── META-INF │ └── services │ │ └── org.asciidoctor.log.LogHandler │ ├── operations │ ├── all-snippets.html │ ├── built-in-snippet-custom-title.html │ ├── custom-snippet-custom-title.html │ ├── custom-snippet-default-title.html │ ├── missing-operation.html │ ├── missing-snippet.html │ ├── multiple-snippets.html │ ├── snippet-in-section.html │ ├── snippet-simple.html │ ├── snippet-table.html │ └── snippet-with-level.html │ ├── sample-snippet.adoc │ └── some-operation │ ├── curl-request.adoc │ ├── custom-snippet.adoc │ ├── http-request.adoc │ └── response-fields.adoc ├── spring-restdocs-bom └── build.gradle ├── spring-restdocs-core ├── build.gradle └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── springframework │ │ │ └── restdocs │ │ │ ├── JUnitRestDocumentation.java │ │ │ ├── ManualRestDocumentation.java │ │ │ ├── RestDocumentationContext.java │ │ │ ├── RestDocumentationContextProvider.java │ │ │ ├── RestDocumentationExtension.java │ │ │ ├── StandardRestDocumentationContext.java │ │ │ ├── cli │ │ │ ├── CliDocumentation.java │ │ │ ├── CliOperationRequest.java │ │ │ ├── CommandFormatter.java │ │ │ ├── ConcatenatingCommandFormatter.java │ │ │ ├── CurlRequestSnippet.java │ │ │ ├── HttpieRequestSnippet.java │ │ │ └── package-info.java │ │ │ ├── config │ │ │ ├── AbstractConfigurer.java │ │ │ ├── AbstractNestedConfigurer.java │ │ │ ├── NestedConfigurer.java │ │ │ ├── OperationPreprocessorsConfigurer.java │ │ │ ├── RestDocumentationConfigurer.java │ │ │ ├── SnippetConfiguration.java │ │ │ ├── SnippetConfigurer.java │ │ │ └── package-info.java │ │ │ ├── constraints │ │ │ ├── Constraint.java │ │ │ ├── ConstraintDescriptionResolver.java │ │ │ ├── ConstraintDescriptions.java │ │ │ ├── ConstraintResolver.java │ │ │ ├── ResourceBundleConstraintDescriptionResolver.java │ │ │ ├── ValidatorConstraintResolver.java │ │ │ └── package-info.java │ │ │ ├── cookies │ │ │ ├── AbstractCookiesSnippet.java │ │ │ ├── CookieDescriptor.java │ │ │ ├── CookieDocumentation.java │ │ │ ├── RequestCookiesSnippet.java │ │ │ ├── ResponseCookiesSnippet.java │ │ │ └── package-info.java │ │ │ ├── generate │ │ │ ├── RestDocumentationGenerationException.java │ │ │ ├── RestDocumentationGenerator.java │ │ │ └── package-info.java │ │ │ ├── headers │ │ │ ├── AbstractHeadersSnippet.java │ │ │ ├── HeaderDescriptor.java │ │ │ ├── HeaderDocumentation.java │ │ │ ├── RequestHeadersSnippet.java │ │ │ ├── ResponseHeadersSnippet.java │ │ │ └── package-info.java │ │ │ ├── http │ │ │ ├── HttpDocumentation.java │ │ │ ├── HttpRequestSnippet.java │ │ │ ├── HttpResponseSnippet.java │ │ │ └── package-info.java │ │ │ ├── hypermedia │ │ │ ├── AbstractJsonLinkExtractor.java │ │ │ ├── AtomLinkExtractor.java │ │ │ ├── ContentTypeLinkExtractor.java │ │ │ ├── HalLinkExtractor.java │ │ │ ├── HypermediaDocumentation.java │ │ │ ├── Link.java │ │ │ ├── LinkDescriptor.java │ │ │ ├── LinkExtractor.java │ │ │ ├── LinksSnippet.java │ │ │ └── package-info.java │ │ │ ├── operation │ │ │ ├── AbstractOperationMessage.java │ │ │ ├── ConversionException.java │ │ │ ├── FormParameters.java │ │ │ ├── HttpHeadersHelper.java │ │ │ ├── Operation.java │ │ │ ├── OperationMessage.java │ │ │ ├── OperationRequest.java │ │ │ ├── OperationRequestFactory.java │ │ │ ├── OperationRequestPart.java │ │ │ ├── OperationRequestPartFactory.java │ │ │ ├── OperationResponse.java │ │ │ ├── OperationResponseFactory.java │ │ │ ├── QueryParameters.java │ │ │ ├── RequestConverter.java │ │ │ ├── RequestCookie.java │ │ │ ├── ResponseConverter.java │ │ │ ├── ResponseCookie.java │ │ │ ├── StandardOperation.java │ │ │ ├── StandardOperationRequest.java │ │ │ ├── StandardOperationRequestPart.java │ │ │ ├── StandardOperationResponse.java │ │ │ ├── package-info.java │ │ │ └── preprocess │ │ │ │ ├── ContentModifier.java │ │ │ │ ├── ContentModifyingOperationPreprocessor.java │ │ │ │ ├── DelegatingOperationRequestPreprocessor.java │ │ │ │ ├── DelegatingOperationResponsePreprocessor.java │ │ │ │ ├── ExactMatchHeaderFilter.java │ │ │ │ ├── HeaderFilter.java │ │ │ │ ├── HeadersModifyingOperationPreprocessor.java │ │ │ │ ├── LinkMaskingContentModifier.java │ │ │ │ ├── OperationPreprocessor.java │ │ │ │ ├── OperationPreprocessorAdapter.java │ │ │ │ ├── OperationRequestPreprocessor.java │ │ │ │ ├── OperationResponsePreprocessor.java │ │ │ │ ├── PatternMatchHeaderFilter.java │ │ │ │ ├── PatternReplacingContentModifier.java │ │ │ │ ├── Preprocessors.java │ │ │ │ ├── PrettyPrintingContentModifier.java │ │ │ │ ├── UriModifyingOperationPreprocessor.java │ │ │ │ └── package-info.java │ │ │ ├── package-info.java │ │ │ ├── payload │ │ │ ├── AbstractBodySnippet.java │ │ │ ├── AbstractFieldsSnippet.java │ │ │ ├── ContentHandler.java │ │ │ ├── FieldDescriptor.java │ │ │ ├── FieldDoesNotExistException.java │ │ │ ├── FieldPathPayloadSubsectionExtractor.java │ │ │ ├── FieldTypeRequiredException.java │ │ │ ├── FieldTypeResolver.java │ │ │ ├── FieldTypesDoNotMatchException.java │ │ │ ├── JsonContentHandler.java │ │ │ ├── JsonFieldPath.java │ │ │ ├── JsonFieldPaths.java │ │ │ ├── JsonFieldProcessor.java │ │ │ ├── JsonFieldType.java │ │ │ ├── JsonFieldTypes.java │ │ │ ├── JsonFieldTypesDiscoverer.java │ │ │ ├── PayloadDocumentation.java │ │ │ ├── PayloadHandlingException.java │ │ │ ├── PayloadSubsectionExtractor.java │ │ │ ├── RequestBodySnippet.java │ │ │ ├── RequestFieldsSnippet.java │ │ │ ├── RequestPartBodySnippet.java │ │ │ ├── RequestPartFieldsSnippet.java │ │ │ ├── ResponseBodySnippet.java │ │ │ ├── ResponseFieldsSnippet.java │ │ │ ├── SubsectionDescriptor.java │ │ │ ├── XmlContentHandler.java │ │ │ └── package-info.java │ │ │ ├── request │ │ │ ├── AbstractParametersSnippet.java │ │ │ ├── FormParametersSnippet.java │ │ │ ├── ParameterDescriptor.java │ │ │ ├── PathParametersSnippet.java │ │ │ ├── QueryParametersSnippet.java │ │ │ ├── RequestDocumentation.java │ │ │ ├── RequestPartDescriptor.java │ │ │ ├── RequestPartsSnippet.java │ │ │ └── package-info.java │ │ │ ├── snippet │ │ │ ├── AbstractDescriptor.java │ │ │ ├── Attributes.java │ │ │ ├── IgnorableDescriptor.java │ │ │ ├── ModelCreationException.java │ │ │ ├── PlaceholderResolverFactory.java │ │ │ ├── RestDocumentationContextPlaceholderResolver.java │ │ │ ├── RestDocumentationContextPlaceholderResolverFactory.java │ │ │ ├── Snippet.java │ │ │ ├── SnippetException.java │ │ │ ├── StandardWriterResolver.java │ │ │ ├── TemplatedSnippet.java │ │ │ ├── WriterResolver.java │ │ │ └── package-info.java │ │ │ └── templates │ │ │ ├── StandardTemplateResourceResolver.java │ │ │ ├── Template.java │ │ │ ├── TemplateEngine.java │ │ │ ├── TemplateFormat.java │ │ │ ├── TemplateFormats.java │ │ │ ├── TemplateResourceResolver.java │ │ │ ├── mustache │ │ │ ├── AsciidoctorTableCellContentLambda.java │ │ │ ├── MustacheTemplate.java │ │ │ ├── MustacheTemplateEngine.java │ │ │ └── package-info.java │ │ │ └── package-info.java │ └── resources │ │ └── org │ │ └── springframework │ │ └── restdocs │ │ ├── constraints │ │ └── DefaultConstraintDescriptions.properties │ │ └── templates │ │ ├── asciidoctor │ │ ├── default-curl-request.snippet │ │ ├── default-form-parameters.snippet │ │ ├── default-http-request.snippet │ │ ├── default-http-response.snippet │ │ ├── default-httpie-request.snippet │ │ ├── default-links.snippet │ │ ├── default-path-parameters.snippet │ │ ├── default-query-parameters.snippet │ │ ├── default-request-body.snippet │ │ ├── default-request-cookies.snippet │ │ ├── default-request-fields.snippet │ │ ├── default-request-headers.snippet │ │ ├── default-request-parameters.snippet │ │ ├── default-request-part-body.snippet │ │ ├── default-request-part-fields.snippet │ │ ├── default-request-parts.snippet │ │ ├── default-response-body.snippet │ │ ├── default-response-cookies.snippet │ │ ├── default-response-fields.snippet │ │ └── default-response-headers.snippet │ │ └── markdown │ │ ├── default-curl-request.snippet │ │ ├── default-form-parameters.snippet │ │ ├── default-http-request.snippet │ │ ├── default-http-response.snippet │ │ ├── default-httpie-request.snippet │ │ ├── default-links.snippet │ │ ├── default-path-parameters.snippet │ │ ├── default-query-parameters.snippet │ │ ├── default-request-body.snippet │ │ ├── default-request-cookies.snippet │ │ ├── default-request-fields.snippet │ │ ├── default-request-headers.snippet │ │ ├── default-request-parameters.snippet │ │ ├── default-request-part-body.snippet │ │ ├── default-request-part-fields.snippet │ │ ├── default-request-parts.snippet │ │ ├── default-response-body.snippet │ │ ├── default-response-cookies.snippet │ │ ├── default-response-fields.snippet │ │ └── default-response-headers.snippet │ ├── test │ ├── java │ │ └── org │ │ │ └── springframework │ │ │ └── restdocs │ │ │ ├── AbstractSnippetTests.java │ │ │ ├── RestDocumentationGeneratorTests.java │ │ │ ├── cli │ │ │ ├── ConcatenatingCommandFormatterTests.java │ │ │ ├── CurlRequestSnippetTests.java │ │ │ └── HttpieRequestSnippetTests.java │ │ │ ├── config │ │ │ └── RestDocumentationConfigurerTests.java │ │ │ ├── constraints │ │ │ ├── ConstraintDescriptionsTests.java │ │ │ ├── ResourceBundleConstraintDescriptionResolverTests.java │ │ │ └── ValidatorConstraintResolverTests.java │ │ │ ├── cookies │ │ │ ├── RequestCookiesSnippetFailureTests.java │ │ │ ├── RequestCookiesSnippetTests.java │ │ │ ├── ResponseCookiesSnippetFailureTests.java │ │ │ └── ResponseCookiesSnippetTests.java │ │ │ ├── headers │ │ │ ├── RequestHeadersSnippetFailureTests.java │ │ │ ├── RequestHeadersSnippetTests.java │ │ │ ├── ResponseHeadersSnippetFailureTests.java │ │ │ └── ResponseHeadersSnippetTests.java │ │ │ ├── http │ │ │ ├── HttpRequestSnippetTests.java │ │ │ └── HttpResponseSnippetTests.java │ │ │ ├── hypermedia │ │ │ ├── ContentTypeLinkExtractorTests.java │ │ │ ├── LinkExtractorsPayloadTests.java │ │ │ ├── LinksSnippetFailureTests.java │ │ │ ├── LinksSnippetTests.java │ │ │ └── StubLinkExtractor.java │ │ │ ├── operation │ │ │ └── preprocess │ │ │ │ ├── ContentModifyingOperationPreprocessorTests.java │ │ │ │ ├── DelegatingOperationRequestPreprocessorTests.java │ │ │ │ ├── DelegatingOperationResponsePreprocessorTests.java │ │ │ │ ├── HeadersModifyingOperationPreprocessorTests.java │ │ │ │ ├── LinkMaskingContentModifierTests.java │ │ │ │ ├── PatternReplacingContentModifierTests.java │ │ │ │ ├── PrettyPrintingContentModifierTests.java │ │ │ │ └── UriModifyingOperationPreprocessorTests.java │ │ │ ├── payload │ │ │ ├── AsciidoctorRequestFieldsSnippetTests.java │ │ │ ├── FieldPathPayloadSubsectionExtractorTests.java │ │ │ ├── FieldTypeResolverTests.java │ │ │ ├── JsonContentHandlerTests.java │ │ │ ├── JsonFieldPathTests.java │ │ │ ├── JsonFieldPathsTests.java │ │ │ ├── JsonFieldProcessorTests.java │ │ │ ├── JsonFieldTypesDiscovererTests.java │ │ │ ├── JsonFieldTypesTests.java │ │ │ ├── PayloadDocumentationTests.java │ │ │ ├── RequestBodyPartSnippetTests.java │ │ │ ├── RequestBodySnippetTests.java │ │ │ ├── RequestFieldsSnippetFailureTests.java │ │ │ ├── RequestFieldsSnippetTests.java │ │ │ ├── RequestPartFieldsSnippetFailureTests.java │ │ │ ├── RequestPartFieldsSnippetTests.java │ │ │ ├── ResponseBodySnippetTests.java │ │ │ ├── ResponseFieldsSnippetFailureTests.java │ │ │ ├── ResponseFieldsSnippetTests.java │ │ │ └── XmlContentHandlerTests.java │ │ │ ├── request │ │ │ ├── FormParametersSnippetFailureTests.java │ │ │ ├── FormParametersSnippetTests.java │ │ │ ├── PathParametersSnippetFailureTests.java │ │ │ ├── PathParametersSnippetTests.java │ │ │ ├── QueryParametersSnippetFailureTests.java │ │ │ ├── QueryParametersSnippetTests.java │ │ │ ├── RequestPartsSnippetFailureTests.java │ │ │ └── RequestPartsSnippetTests.java │ │ │ ├── snippet │ │ │ ├── RestDocumentationContextPlaceholderResolverTests.java │ │ │ ├── StandardWriterResolverTests.java │ │ │ └── TemplatedSnippetTests.java │ │ │ └── templates │ │ │ ├── StandardTemplateResourceResolverTests.java │ │ │ └── mustache │ │ │ └── AsciidoctorTableCellContentLambdaTests.java │ └── resources │ │ ├── custom-snippet-templates │ │ ├── asciidoctor │ │ │ ├── curl-request-with-title.snippet │ │ │ ├── form-parameters-with-extra-column.snippet │ │ │ ├── form-parameters-with-optional-column.snippet │ │ │ ├── form-parameters-with-title.snippet │ │ │ ├── http-request-with-title.snippet │ │ │ ├── http-response-with-title.snippet │ │ │ ├── httpie-request-with-title.snippet │ │ │ ├── links-with-extra-column.snippet │ │ │ ├── links-with-title.snippet │ │ │ ├── path-parameters-with-extra-column.snippet │ │ │ ├── path-parameters-with-title.snippet │ │ │ ├── query-parameters-with-extra-column.snippet │ │ │ ├── query-parameters-with-optional-column.snippet │ │ │ ├── query-parameters-with-title.snippet │ │ │ ├── request-body-with-language.snippet │ │ │ ├── request-cookies-with-extra-column.snippet │ │ │ ├── request-cookies-with-title.snippet │ │ │ ├── request-fields-with-extra-column.snippet │ │ │ ├── request-fields-with-list-description.snippet │ │ │ ├── request-fields-with-title.snippet │ │ │ ├── request-headers-with-extra-column.snippet │ │ │ ├── request-headers-with-title.snippet │ │ │ ├── request-part-body-with-language.snippet │ │ │ ├── request-parts-with-extra-column.snippet │ │ │ ├── request-parts-with-optional-column.snippet │ │ │ ├── request-parts-with-title.snippet │ │ │ ├── response-body-with-language.snippet │ │ │ ├── response-cookies-with-extra-column.snippet │ │ │ ├── response-cookies-with-title.snippet │ │ │ ├── response-fields-with-extra-column.snippet │ │ │ ├── response-fields-with-title.snippet │ │ │ ├── response-headers-with-extra-column.snippet │ │ │ └── response-headers-with-title.snippet │ │ └── markdown │ │ │ ├── curl-request-with-title.snippet │ │ │ ├── form-parameters-with-extra-column.snippet │ │ │ ├── form-parameters-with-optional-column.snippet │ │ │ ├── form-parameters-with-title.snippet │ │ │ ├── http-request-with-title.snippet │ │ │ ├── http-response-with-title.snippet │ │ │ ├── httpie-request-with-title.snippet │ │ │ ├── links-with-extra-column.snippet │ │ │ ├── links-with-title.snippet │ │ │ ├── path-parameters-with-extra-column.snippet │ │ │ ├── path-parameters-with-title.snippet │ │ │ ├── query-parameters-with-extra-column.snippet │ │ │ ├── query-parameters-with-optional-column.snippet │ │ │ ├── query-parameters-with-title.snippet │ │ │ ├── request-body-with-language.snippet │ │ │ ├── request-cookies-with-extra-column.snippet │ │ │ ├── request-cookies-with-title.snippet │ │ │ ├── request-fields-with-extra-column.snippet │ │ │ ├── request-fields-with-title.snippet │ │ │ ├── request-headers-with-extra-column.snippet │ │ │ ├── request-headers-with-title.snippet │ │ │ ├── request-part-body-with-language.snippet │ │ │ ├── request-parts-with-extra-column.snippet │ │ │ ├── request-parts-with-optional-column.snippet │ │ │ ├── request-parts-with-title.snippet │ │ │ ├── response-body-with-language.snippet │ │ │ ├── response-cookies-with-extra-column.snippet │ │ │ ├── response-cookies-with-title.snippet │ │ │ ├── response-fields-with-extra-column.snippet │ │ │ ├── response-fields-with-title.snippet │ │ │ ├── response-headers-with-extra-column.snippet │ │ │ └── response-headers-with-title.snippet │ │ ├── field-payloads │ │ ├── multiple-fields-and-embedded-and-links.json │ │ ├── multiple-fields-and-embedded.json │ │ ├── multiple-fields-and-links.json │ │ ├── multiple-fields.json │ │ ├── no-fields.json │ │ └── single-field.json │ │ ├── link-payloads │ │ ├── atom │ │ │ ├── multiple-links-different-rels.json │ │ │ ├── multiple-links-same-rels.json │ │ │ ├── no-links.json │ │ │ ├── single-link.json │ │ │ └── wrong-format.json │ │ └── hal │ │ │ ├── multiple-links-different-rels.json │ │ │ ├── multiple-links-same-rels.json │ │ │ ├── no-links.json │ │ │ ├── single-link.json │ │ │ └── wrong-format.json │ │ └── org │ │ └── springframework │ │ └── restdocs │ │ ├── constraints │ │ └── TestConstraintDescriptions.properties │ │ └── templates │ │ ├── multiple-snippets.snippet │ │ ├── test-custom.snippet │ │ ├── test-default.snippet │ │ └── test-format-specific-custom.snippet │ └── testFixtures │ └── java │ └── org │ └── springframework │ └── restdocs │ └── testfixtures │ ├── CapturedOutput.java │ ├── GeneratedSnippets.java │ ├── OperationBuilder.java │ ├── OperationTestRule.java │ ├── OutputCapture.java │ ├── OutputCaptureRule.java │ └── SnippetConditions.java ├── spring-restdocs-mockmvc ├── build.gradle └── src │ ├── main │ └── java │ │ └── org │ │ └── springframework │ │ └── restdocs │ │ └── mockmvc │ │ ├── IterableEnumeration.java │ │ ├── MockMvcOperationPreprocessorsConfigurer.java │ │ ├── MockMvcRequestConverter.java │ │ ├── MockMvcResponseConverter.java │ │ ├── MockMvcRestDocumentation.java │ │ ├── MockMvcRestDocumentationConfigurer.java │ │ ├── MockMvcSnippetConfigurer.java │ │ ├── RestDocumentationRequestBuilders.java │ │ ├── RestDocumentationResultHandler.java │ │ ├── UriConfigurer.java │ │ └── package-info.java │ └── test │ ├── java │ └── org │ │ └── springframework │ │ └── restdocs │ │ └── mockmvc │ │ ├── MockMvcRequestConverterTests.java │ │ ├── MockMvcResponseConverterTests.java │ │ ├── MockMvcRestDocumentationConfigurerTests.java │ │ ├── MockMvcRestDocumentationIntegrationTests.java │ │ └── RestDocumentationRequestBuildersTests.java │ └── resources │ ├── custom-snippet-templates │ └── org │ │ └── springframework │ │ └── restdocs │ │ └── templates │ │ └── curl-request.snippet │ └── org │ └── springframework │ └── restdocs │ └── templates │ └── request-parts.snippet ├── spring-restdocs-platform └── build.gradle ├── spring-restdocs-restassured ├── build.gradle └── src │ ├── main │ └── java │ │ └── org │ │ └── springframework │ │ └── restdocs │ │ └── restassured │ │ ├── RestAssuredOperationPreprocessorsConfigurer.java │ │ ├── RestAssuredRequestConverter.java │ │ ├── RestAssuredResponseConverter.java │ │ ├── RestAssuredRestDocumentation.java │ │ ├── RestAssuredRestDocumentationConfigurer.java │ │ ├── RestAssuredSnippetConfigurer.java │ │ ├── RestDocumentationFilter.java │ │ └── package-info.java │ └── test │ ├── java │ └── org │ │ └── springframework │ │ └── restdocs │ │ └── restassured │ │ ├── RestAssuredParameterBehaviorTests.java │ │ ├── RestAssuredRequestConverterTests.java │ │ ├── RestAssuredResponseConverterTests.java │ │ ├── RestAssuredRestDocumentationConfigurerTests.java │ │ ├── RestAssuredRestDocumentationIntegrationTests.java │ │ └── TomcatServer.java │ └── resources │ ├── body.txt │ └── custom-snippet-templates │ └── org │ └── springframework │ └── restdocs │ └── templates │ └── curl-request.snippet └── spring-restdocs-webtestclient ├── build.gradle └── src ├── main └── java │ └── org │ └── springframework │ └── restdocs │ └── webtestclient │ ├── WebTestClientOperationPreprocessorsConfigurer.java │ ├── WebTestClientRequestConverter.java │ ├── WebTestClientResponseConverter.java │ ├── WebTestClientRestDocumentation.java │ ├── WebTestClientRestDocumentationConfigurer.java │ ├── WebTestClientSnippetConfigurer.java │ └── package-info.java └── test └── java └── org └── springframework └── restdocs └── webtestclient ├── WebTestClientRequestConverterTests.java ├── WebTestClientResponseConverterTests.java ├── WebTestClientRestDocumentationConfigurerTests.java └── WebTestClientRestDocumentationIntegrationTests.java /.github/actions/await-http-resource/action.yml: -------------------------------------------------------------------------------- 1 | name: Await HTTP Resource 2 | description: 'Waits for an HTTP resource to be available (a HEAD request succeeds)' 3 | inputs: 4 | url: 5 | description: 'URL of the resource to await' 6 | required: true 7 | runs: 8 | using: composite 9 | steps: 10 | - name: Await HTTP resource 11 | shell: bash 12 | run: | 13 | url=${{ inputs.url }} 14 | echo "Waiting for $url" 15 | until curl --fail --head --silent ${{ inputs.url }} > /dev/null 16 | do 17 | echo "." 18 | sleep 60 19 | done 20 | echo "$url is available" 21 | -------------------------------------------------------------------------------- /.github/actions/create-github-release/action.yml: -------------------------------------------------------------------------------- 1 | name: Create GitHub Release 2 | description: 'Create the release on GitHub with a changelog' 3 | inputs: 4 | milestone: 5 | description: 'Name of the GitHub milestone for which a release will be created' 6 | required: true 7 | pre-release: 8 | description: 'Whether the release is a pre-release (a milestone or release candidate)' 9 | required: false 10 | default: 'false' 11 | token: 12 | description: 'Token to use for authentication with GitHub' 13 | required: true 14 | runs: 15 | using: composite 16 | steps: 17 | - name: Generate Changelog 18 | uses: spring-io/github-changelog-generator@185319ad7eaa75b0e8e72e4b6db19c8b2cb8c4c1 #v0.0.11 19 | with: 20 | config-file: .github/actions/create-github-release/changelog-generator.yml 21 | milestone: ${{ inputs.milestone }} 22 | token: ${{ inputs.token }} 23 | - name: Create GitHub Release 24 | shell: bash 25 | env: 26 | GITHUB_TOKEN: ${{ inputs.token }} 27 | run: gh release create ${{ format('v{0}', inputs.milestone) }} --notes-file changelog.md ${{ inputs.pre-release == 'true' && '--prerelease' || '' }} 28 | -------------------------------------------------------------------------------- /.github/actions/create-github-release/changelog-generator.yml: -------------------------------------------------------------------------------- 1 | changelog: 2 | sections: 3 | - title: ":star: New Features" 4 | labels: 5 | - "type: enhancement" 6 | - title: ":lady_beetle: Bug Fixes" 7 | labels: 8 | - "type: bug" 9 | - "type: regression" 10 | - title: ":notebook_with_decorative_cover: Documentation" 11 | labels: 12 | - "type: documentation" 13 | - title: ":hammer: Dependency Upgrades" 14 | sort: "title" 15 | labels: 16 | - "type: dependency-upgrade" 17 | issues: 18 | ports: 19 | - label: "status: forward-port" 20 | bodyExpression: 'Forward port of issue #(\d+).*' 21 | - label: "status: back-port" 22 | bodyExpression: 'Back port of issue #(\d+).*' 23 | -------------------------------------------------------------------------------- /.github/actions/print-jvm-thread-dumps/action.yml: -------------------------------------------------------------------------------- 1 | name: Print JVM thread dumps 2 | description: 'Prints a thread dump for all running JVMs' 3 | runs: 4 | using: composite 5 | steps: 6 | - if: ${{ runner.os == 'Linux' }} 7 | shell: bash 8 | run: | 9 | for jvm_pid in $(jps -q -J-XX:+PerfDisableSharedMem); do 10 | jcmd $jvm_pid Thread.print 11 | done 12 | - if: ${{ runner.os == 'Windows' }} 13 | shell: powershell 14 | run: | 15 | foreach ($jvm_pid in $(jps -q -J-XX:+PerfDisableSharedMem)) { 16 | jcmd $jvm_pid Thread.print 17 | } 18 | -------------------------------------------------------------------------------- /.github/actions/sync-to-maven-central/artifacts.spec: -------------------------------------------------------------------------------- 1 | { 2 | "files": [ 3 | { 4 | "aql": { 5 | "items.find": { 6 | "$and": [ 7 | { 8 | "@build.name": "${buildName}", 9 | "@build.number": "${buildNumber}", 10 | "path": { 11 | "$nmatch": "org/springframework/restdocs/spring-restdocs/*" 12 | } 13 | } 14 | ] 15 | } 16 | }, 17 | "target": "nexus/" 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /.github/dco.yml: -------------------------------------------------------------------------------- 1 | require: 2 | members: false 3 | -------------------------------------------------------------------------------- /.github/workflows/build-pull-request.yml: -------------------------------------------------------------------------------- 1 | name: Build Pull Request 2 | on: pull_request 3 | permissions: 4 | contents: read 5 | jobs: 6 | build: 7 | name: Build Pull Request 8 | if: ${{ github.repository == 'spring-projects/spring-restdocs' }} 9 | runs-on: ${{ vars.UBUNTU_MEDIUM || 'ubuntu-latest' }} 10 | steps: 11 | - name: Check Out Code 12 | uses: actions/checkout@v4 13 | - name: Build 14 | id: build 15 | uses: ./.github/actions/build 16 | - name: Print JVM Thread Dumps When Cancelled 17 | if: cancelled() 18 | uses: ./.github/actions/print-jvm-thread-dumps 19 | - name: Upload Build Reports 20 | if: failure() 21 | uses: actions/upload-artifact@v4 22 | with: 23 | name: build-reports 24 | path: '**/build/reports/' 25 | -------------------------------------------------------------------------------- /.github/workflows/delete-staged-release.yml: -------------------------------------------------------------------------------- 1 | name: Delete Staged Release 2 | on: 3 | workflow_dispatch: 4 | inputs: 5 | build-version: 6 | description: 'Version of the build to delete' 7 | required: true 8 | jobs: 9 | delete-staged-release: 10 | name: Delete Staged Release 11 | runs-on: ubuntu-latest 12 | steps: 13 | - name: Set up JFrog CLI 14 | uses: jfrog/setup-jfrog-cli@9fe0f98bd45b19e6e931d457f4e98f8f84461fb5 # v4.4.1 15 | env: 16 | JF_ENV_SPRING: ${{ secrets.JF_ARTIFACTORY_SPRING }} 17 | - name: Delete Build 18 | run: jfrog rt delete --build spring-restdocs-${{ github.event.inputs.build-version }} 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .classpath 2 | .gradle 3 | .project 4 | .settings 5 | bin 6 | build 7 | !buildSrc/src/main/groovy/org/springframework/restdocs/build/ 8 | target 9 | .idea/* 10 | !.idea/icon.svg 11 | *.iml -------------------------------------------------------------------------------- /.sdkmanrc: -------------------------------------------------------------------------------- 1 | # Enable auto-env through the sdkman_auto_env config 2 | # Add key=value pairs of SDKs to use below 3 | java=17.0.12-librca 4 | -------------------------------------------------------------------------------- /buildSrc/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "java-gradle-plugin" 3 | } 4 | -------------------------------------------------------------------------------- /buildSrc/src/main/resources/META-INF/gradle-plugins/optional-dependencies.properties: -------------------------------------------------------------------------------- 1 | implementation-class:org.springframework.restdocs.build.optional.OptionalDependenciesPlugin 2 | -------------------------------------------------------------------------------- /ci/README.adoc: -------------------------------------------------------------------------------- 1 | == Concourse pipeline 2 | 3 | Ensure that you've setup the spring-restdocs target and can login 4 | 5 | [source] 6 | ---- 7 | $ fly -t spring-restdocs login -n spring-restdocs -c https://ci.spring.io 8 | ---- 9 | 10 | The pipeline can be deployed using the following command: 11 | 12 | [source] 13 | ---- 14 | $ fly -t spring-restdocs set-pipeline -p spring-restdocs-3.0.x -c ci/pipeline.yml -l ci/parameters.yml 15 | ---- 16 | 17 | NOTE: This assumes that you have Vault integration configured with the appropriate secrets. 18 | -------------------------------------------------------------------------------- /ci/config/changelog-generator.yml: -------------------------------------------------------------------------------- 1 | changelog: 2 | repository: spring-projects/spring-restdocs 3 | sections: 4 | - title: ":star: New Features" 5 | labels: 6 | - "type: enhancement" 7 | - title: ":lady_beetle: Bug Fixes" 8 | labels: 9 | - "type: bug" 10 | - "type: regression" 11 | - title: ":notebook_with_decorative_cover: Documentation" 12 | labels: 13 | - "type: documentation" 14 | - title: ":hammer: Dependency Upgrades" 15 | sort: "title" 16 | labels: 17 | - "type: dependency-upgrade" 18 | issues: 19 | ports: 20 | - label: "status: forward-port" 21 | bodyExpression: 'Forward port of issue #(\d+).*' 22 | - label: "status: back-port" 23 | bodyExpression: 'Back port of issue #(\d+).*' 24 | -------------------------------------------------------------------------------- /ci/config/release-scripts.yml: -------------------------------------------------------------------------------- 1 | logging: 2 | level: 3 | io.spring.concourse: DEBUG 4 | spring: 5 | main: 6 | banner-mode: off 7 | sonatype: 8 | exclude: 9 | - 'build-info\.json' 10 | - 'org/springframework/restdocs/spring-restdocs/.*' 11 | -------------------------------------------------------------------------------- /ci/images/README.adoc: -------------------------------------------------------------------------------- 1 | == CI Images 2 | 3 | These images are used by CI to run the actual builds. 4 | 5 | To build the image locally run the following from this directory: 6 | 7 | ---- 8 | $ docker build --no-cache -f /Dockerfile . 9 | ---- 10 | 11 | For example 12 | 13 | ---- 14 | $ docker build --no-cache -f ci-image/Dockerfile . 15 | ---- 16 | 17 | To test run: 18 | 19 | ---- 20 | $ docker run -it --entrypoint /bin/bash 21 | ---- 22 | -------------------------------------------------------------------------------- /ci/images/ci-image/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:focal-20220531 2 | 3 | ADD setup.sh /setup.sh 4 | ADD get-jdk-url.sh /get-jdk-url.sh 5 | RUN ./setup.sh java17 6 | 7 | ENV JAVA_HOME /opt/openjdk 8 | ENV PATH $JAVA_HOME/bin:$PATH 9 | -------------------------------------------------------------------------------- /ci/images/get-jdk-url.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | case "$1" in 5 | java17) 6 | echo "https://github.com/bell-sw/Liberica/releases/download/17.0.3.1+2/bellsoft-jdk17.0.3.1+2-linux-amd64.tar.gz" 7 | ;; 8 | *) 9 | echo $"Unknown java version" 10 | exit 1 11 | esac 12 | -------------------------------------------------------------------------------- /ci/images/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -ex 3 | 4 | ########################################################### 5 | # UTILS 6 | ########################################################### 7 | 8 | export DEBIAN_FRONTEND=noninteractive 9 | apt-get update 10 | apt-get install --no-install-recommends -y tzdata ca-certificates net-tools libxml2-utils git curl libudev1 libxml2-utils iptables iproute2 jq unzip 11 | ln -fs /usr/share/zoneinfo/UTC /etc/localtime 12 | dpkg-reconfigure --frontend noninteractive tzdata 13 | rm -rf /var/lib/apt/lists/* 14 | 15 | curl https://raw.githubusercontent.com/spring-io/concourse-java-scripts/v0.0.4/concourse-java.sh > /opt/concourse-java.sh 16 | 17 | ########################################################### 18 | # JAVA 19 | ########################################################### 20 | JDK_URL=$( ./get-jdk-url.sh $1 ) 21 | 22 | mkdir -p /opt/openjdk 23 | cd /opt/openjdk 24 | curl -L ${JDK_URL} | tar zx --strip-components=1 25 | test -f /opt/openjdk/bin/java 26 | test -f /opt/openjdk/bin/javac 27 | 28 | ########################################################### 29 | # GRADLE ENTERPRISE 30 | ########################################################### 31 | mkdir ~/.gradle 32 | echo 'systemProp.user.name=concourse' > ~/.gradle/gradle.properties -------------------------------------------------------------------------------- /ci/parameters.yml: -------------------------------------------------------------------------------- 1 | github-organization: "spring-projects" 2 | github-repository: "spring-restdocs" 3 | docker-hub-organization: "springci" 4 | artifactory-server: "https://repo.spring.io" 5 | branch: "main" 6 | milestone: "3.0.x" 7 | build-name: "spring-restdocs" 8 | concourse-url: "https://ci.spring.io" 9 | task-timeout: 1h00m 10 | registry-mirror-host: docker.repo.spring.io 11 | registry-mirror-username: ((artifactory-username)) 12 | registry-mirror-password: ((artifactory-password)) -------------------------------------------------------------------------------- /ci/scripts/build-project-windows.bat: -------------------------------------------------------------------------------- 1 | SET "JAVA_HOME=C:\opt\jdk-17" 2 | SET PATH=%PATH%;C:\Program Files\Git\usr\bin 3 | cd git-repo 4 | .\gradlew -Dorg.gradle.internal.launcher.welcomeMessageEnabled=false --no-daemon --max-workers=4 build 5 | -------------------------------------------------------------------------------- /ci/scripts/build-project.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | source $(dirname $0)/common.sh 5 | repository=$(pwd)/distribution-repository 6 | 7 | pushd git-repo > /dev/null 8 | ./gradlew -Dorg.gradle.internal.launcher.welcomeMessageEnabled=false --no-daemon --max-workers=4 -PdeploymentRepository=${repository} build publishAllPublicationsToDeploymentRepository 9 | popd > /dev/null 10 | -------------------------------------------------------------------------------- /ci/scripts/common.sh: -------------------------------------------------------------------------------- 1 | source /opt/concourse-java.sh 2 | 3 | setup_symlinks 4 | cleanup_maven_repo "org.springframework.restdocs" 5 | -------------------------------------------------------------------------------- /ci/scripts/generate-changelog.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | CONFIG_DIR=git-repo/ci/config 5 | version=$( cat artifactory-repo/build-info.json | jq -r '.buildInfo.modules[0].id' | sed 's/.*:.*:\(.*\)/\1/' ) 6 | 7 | java -jar /github-changelog-generator.jar \ 8 | --spring.config.location=${CONFIG_DIR}/changelog-generator.yml \ 9 | ${version} generated-changelog/changelog.md 10 | 11 | echo ${version} > generated-changelog/version 12 | echo v${version} > generated-changelog/tag 13 | -------------------------------------------------------------------------------- /ci/scripts/promote.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | CONFIG_DIR=git-repo/ci/config 4 | 5 | version=$( cat artifactory-repo/build-info.json | jq -r '.buildInfo.modules[0].id' | sed 's/.*:.*:\(.*\)/\1/' ) 6 | export BUILD_INFO_LOCATION=$(pwd)/artifactory-repo/build-info.json 7 | 8 | java -jar /concourse-release-scripts.jar \ 9 | --spring.config.location=${CONFIG_DIR}/release-scripts.yml \ 10 | publishToCentral $RELEASE_TYPE $BUILD_INFO_LOCATION artifactory-repo || { exit 1; } 11 | 12 | java -jar /concourse-release-scripts.jar \ 13 | --spring.config.location=${CONFIG_DIR}/release-scripts.yml \ 14 | promote $RELEASE_TYPE $BUILD_INFO_LOCATION || { exit 1; } 15 | 16 | echo "Promotion complete" 17 | echo $version > version/version 18 | -------------------------------------------------------------------------------- /ci/tasks/build-ci-image.yml: -------------------------------------------------------------------------------- 1 | --- 2 | platform: linux 3 | image_resource: 4 | type: registry-image 5 | source: 6 | repository: concourse/oci-build-task 7 | tag: 0.9.0 8 | registry_mirror: 9 | host: ((registry-mirror-host)) 10 | username: ((registry-mirror-username)) 11 | password: ((registry-mirror-password)) 12 | inputs: 13 | - name: ci-images-git-repo 14 | outputs: 15 | - name: image 16 | caches: 17 | - path: ci-image-cache 18 | params: 19 | CONTEXT: ci-images-git-repo/ci/images 20 | DOCKERFILE: ci-images-git-repo/ci/images/((ci-image-name))/Dockerfile 21 | DOCKER_HUB_AUTH: ((docker-hub-auth)) 22 | run: 23 | path: /bin/sh 24 | args: 25 | - "-c" 26 | - | 27 | mkdir -p /root/.docker 28 | cat > /root/.docker/config.json < 2 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /config/checkstyle/checkstyle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /docs/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "org.asciidoctor.jvm.convert" version "3.3.2" 3 | id "java-library" 4 | } 5 | 6 | configurations { 7 | asciidoctorExt 8 | } 9 | 10 | dependencies { 11 | asciidoctorExt("io.spring.asciidoctor.backends:spring-asciidoctor-backends:0.0.5") 12 | 13 | internal(platform(project(":spring-restdocs-platform"))) 14 | internal(enforcedPlatform("org.springframework:spring-framework-bom:$springFrameworkVersion")) 15 | 16 | testImplementation(project(":spring-restdocs-mockmvc")) 17 | testImplementation(project(":spring-restdocs-restassured")) 18 | testImplementation(project(":spring-restdocs-webtestclient")) 19 | testImplementation("jakarta.servlet:jakarta.servlet-api") 20 | testImplementation("jakarta.validation:jakarta.validation-api") 21 | testImplementation("junit:junit") 22 | testImplementation("org.testng:testng:6.9.10") 23 | testImplementation("org.junit.jupiter:junit-jupiter-api") 24 | } 25 | 26 | tasks.findByPath("artifactoryPublish")?.enabled = false 27 | 28 | tasks.withType(org.asciidoctor.gradle.jvm.AbstractAsciidoctorTask) { 29 | baseDirFollowsSourceDir() 30 | } 31 | 32 | jar { 33 | enabled = false 34 | } 35 | 36 | javadoc { 37 | enabled = false 38 | } 39 | 40 | asciidoctor { 41 | configurations 'asciidoctorExt' 42 | sources { 43 | include "index.adoc" 44 | } 45 | attributes "revnumber": project.version, 46 | "spring-Framework-version": springFrameworkVersion, 47 | "branch-or-tag": project.version.endsWith("SNAPSHOT") ? "main": "v${project.version}" 48 | inputs.files(sourceSets.test.java) 49 | outputOptions { 50 | backends "spring-html" 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /docs/src/docs/asciidoc/contributing.adoc: -------------------------------------------------------------------------------- 1 | [[contributing]] 2 | == Contributing 3 | 4 | Spring REST Docs is intended to make it easy for you to produce high-quality documentation for your RESTful services. 5 | However, we cannot achieve that goal without your contributions. 6 | 7 | 8 | 9 | [[contributing-questions]] 10 | === Questions 11 | 12 | You can ask questions about Spring REST Docs on https://stackoverflow.com[Stack Overflow] by using the `spring-restdocs` tag. 13 | Similarly, we encourage you to help your fellow Spring REST Docs users by answering questions. 14 | 15 | 16 | 17 | [[contributing-bugs]] 18 | === Bugs 19 | 20 | If you believe you have found a bug, please take a moment to search the {github}/issues?q=is%3Aissue[existing issues]. 21 | If no one else has reported the problem, please {github}/issues/new[open a new issue] that describes the problem in detail and, ideally, includes a test that reproduces it. 22 | 23 | 24 | 25 | [[contributing-enhancements]] 26 | === Enhancements 27 | 28 | If you would like an enhancement to be made to Spring REST Docs, pull requests are most welcome. 29 | The source code is on {github}[GitHub]. 30 | You may want to search the {github}/issues?q=is%3Aissue[existing issues] and {github}/pulls?q=is%3Apr[pull requests] to see if the enhancement has already been proposed. 31 | You may also want to {github}/issues/new[open a new issue] to discuss a possible enhancement before work on it begins. 32 | 33 | 34 | -------------------------------------------------------------------------------- /docs/src/docs/asciidoc/index.adoc: -------------------------------------------------------------------------------- 1 | = Spring REST Docs 2 | Andy Wilkinson; Jay Bryant 3 | :doctype: book 4 | :icons: font 5 | :source-highlighter: highlightjs 6 | :toc: left 7 | :toclevels: 3 8 | :sectlinks: 9 | 10 | :examples-dir: ../../test/java 11 | :github: https://github.com/spring-projects/spring-restdocs 12 | :source: {github}/tree/{branch-or-tag} 13 | :samples: https://github.com/spring-projects/spring-restdocs-samples/tree/main 14 | :templates: {source}spring-restdocs/src/main/resources/org/springframework/restdocs/templates 15 | :spring-boot-docs: https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle 16 | :spring-framework-docs: https://docs.spring.io/spring-framework/docs/{spring-framework-version}/reference/html/ 17 | :spring-framework-api: https://docs.spring.io/spring-framework/docs/{spring-framework-version}/javadoc-api 18 | 19 | [[abstract]] 20 | 21 | Document RESTful services by combining hand-written documentation with auto-generated snippets produced with Spring MVC Test or WebTestClient. 22 | 23 | include::introduction.adoc[] 24 | include::getting-started.adoc[] 25 | include::documenting-your-api.adoc[] 26 | include::customizing-requests-and-responses.adoc[] 27 | include::configuration.adoc[] 28 | include::working-with-asciidoctor.adoc[] 29 | include::working-with-markdown.adoc[] 30 | include::contributing.adoc[] 31 | -------------------------------------------------------------------------------- /docs/src/docs/asciidoc/introduction.adoc: -------------------------------------------------------------------------------- 1 | [[introduction]] 2 | == Introduction 3 | 4 | The aim of Spring REST Docs is to help you produce accurate and readable documentation for your RESTful services. 5 | 6 | Writing high-quality documentation is difficult. 7 | One way to ease that difficulty is to use tools that are well-suited to the job. 8 | To this end, Spring REST Docs uses https://asciidoctor.org[Asciidoctor] by default. 9 | Asciidoctor processes plain text and produces HTML, styled and laid out to suit your needs. 10 | If you prefer, you can also configure Spring REST Docs to use Markdown. 11 | 12 | Spring REST Docs uses snippets produced by tests written with Spring MVC's {spring-framework-docs}/testing.html#spring-mvc-test-framework[test framework], Spring WebFlux's {spring-framework-docs}/testing.html#webtestclient[`WebTestClient`] or https://rest-assured.io/[REST Assured 5]. 13 | This test-driven approach helps to guarantee the accuracy of your service's documentation. 14 | If a snippet is incorrect, the test that produces it fails. 15 | 16 | Documenting a RESTful service is largely about describing its resources. 17 | Two key parts of each resource's description are the details of the HTTP requests that it consumes and the HTTP responses that it produces. 18 | Spring REST Docs lets you work with these resources and the HTTP requests and responses, shielding your documentation from the inner-details of your service's implementation. 19 | This separation helps you document your service's API rather than its implementation. 20 | It also frees you to evolve the implementation without having to rework the documentation. 21 | 22 | 23 | -------------------------------------------------------------------------------- /docs/src/docs/asciidoc/working-with-markdown.adoc: -------------------------------------------------------------------------------- 1 | [[working-with-markdown]] 2 | == Working with Markdown 3 | 4 | This section describes the aspects of working with Markdown that are particularly relevant to Spring REST Docs. 5 | 6 | 7 | 8 | [[working-with-markdown-limitations]] 9 | === Limitations 10 | 11 | Markdown was originally designed for people writing for the web and, as such, is not as well-suited to writing documentation as Asciidoctor. 12 | Typically, these limitations are overcome by using another tool that builds on top of Markdown. 13 | 14 | Markdown has no official support for tables. 15 | Spring REST Docs' default Markdown snippet templates use https://michelf.ca/projects/php-markdown/extra/#table[Markdown Extra's table format]. 16 | 17 | 18 | 19 | [[working-with-markdown-including-snippets]] 20 | === Including Snippets 21 | 22 | Markdown has no built-in support for including one Markdown file in another. 23 | To include the generated snippets of Markdown in your documentation, you should use an additional tool that supports this functionality. 24 | One example that is particularly well-suited to documenting APIs is https://github.com/tripit/slate[Slate]. 25 | 26 | 27 | -------------------------------------------------------------------------------- /docs/src/test/java/com/example/Constraints.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.example; 18 | 19 | import java.util.List; 20 | 21 | import jakarta.validation.constraints.NotNull; 22 | import jakarta.validation.constraints.Size; 23 | 24 | import org.springframework.restdocs.constraints.ConstraintDescriptions; 25 | 26 | public class Constraints { 27 | 28 | @SuppressWarnings("unused") 29 | // tag::constraints[] 30 | public void example() { 31 | ConstraintDescriptions userConstraints = new ConstraintDescriptions(UserInput.class); // <1> 32 | List descriptions = userConstraints.descriptionsForProperty("name"); // <2> 33 | } 34 | 35 | static class UserInput { 36 | 37 | @NotNull 38 | @Size(min = 1) 39 | String name; 40 | 41 | @NotNull 42 | @Size(min = 8) 43 | String password; 44 | 45 | } 46 | // end::constraints[] 47 | 48 | } 49 | -------------------------------------------------------------------------------- /docs/src/test/java/com/example/Hypermedia.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2023 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.example; 18 | 19 | import org.springframework.restdocs.hypermedia.HypermediaDocumentation; 20 | import org.springframework.restdocs.hypermedia.LinkDescriptor; 21 | import org.springframework.restdocs.hypermedia.LinksSnippet; 22 | 23 | import static org.springframework.restdocs.hypermedia.HypermediaDocumentation.linkWithRel; 24 | 25 | public final class Hypermedia { 26 | 27 | private Hypermedia() { 28 | 29 | } 30 | 31 | // tag::ignore-links[] 32 | public static LinksSnippet links(LinkDescriptor... descriptors) { 33 | return HypermediaDocumentation.links(linkWithRel("self").ignored().optional(), linkWithRel("curies").ignored()) 34 | .and(descriptors); 35 | } 36 | // end::ignore-links[] 37 | 38 | } 39 | -------------------------------------------------------------------------------- /docs/src/test/java/com/example/Payload.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2021 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.example; 18 | 19 | import org.springframework.restdocs.payload.FieldDescriptor; 20 | 21 | import static org.springframework.restdocs.payload.PayloadDocumentation.beneathPath; 22 | import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath; 23 | import static org.springframework.restdocs.payload.PayloadDocumentation.responseBody; 24 | 25 | public class Payload { 26 | 27 | @SuppressWarnings("unused") 28 | public void bookFieldDescriptors() { 29 | // tag::book-descriptors[] 30 | FieldDescriptor[] book = new FieldDescriptor[] { fieldWithPath("title").description("Title of the book"), 31 | fieldWithPath("author").description("Author of the book") }; 32 | // end::book-descriptors[] 33 | } 34 | 35 | public void customSubsectionId() { 36 | // tag::custom-subsection-id[] 37 | responseBody(beneathPath("weather.temperature").withSubsectionId("temp")); 38 | // end::custom-subsection-id[] 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /docs/src/test/java/com/example/SnippetReuse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2021 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.example; 18 | 19 | import org.springframework.restdocs.hypermedia.LinksSnippet; 20 | 21 | import static org.springframework.restdocs.hypermedia.HypermediaDocumentation.linkWithRel; 22 | import static org.springframework.restdocs.hypermedia.HypermediaDocumentation.links; 23 | 24 | public class SnippetReuse { 25 | 26 | // tag::field[] 27 | protected final LinksSnippet pagingLinks = links( 28 | linkWithRel("first").optional().description("The first page of results"), 29 | linkWithRel("last").optional().description("The last page of results"), 30 | linkWithRel("next").optional().description("The next page of results"), 31 | linkWithRel("prev").optional().description("The previous page of results")); 32 | 33 | // end::field[] 34 | 35 | } 36 | -------------------------------------------------------------------------------- /docs/src/test/java/com/example/mockmvc/FormParameters.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2023 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.example.mockmvc; 18 | 19 | import org.springframework.test.web.servlet.MockMvc; 20 | 21 | import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; 22 | import static org.springframework.restdocs.request.RequestDocumentation.formParameters; 23 | import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName; 24 | import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; 25 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; 26 | 27 | public class FormParameters { 28 | 29 | private MockMvc mockMvc; 30 | 31 | public void postFormDataSnippet() throws Exception { 32 | // tag::form-parameters[] 33 | this.mockMvc.perform(post("/users").param("username", "Tester")) // <1> 34 | .andExpect(status().isCreated()) 35 | .andDo(document("create-user", formParameters(// <2> 36 | parameterWithName("username").description("The user's username") // <3> 37 | ))); 38 | // end::form-parameters[] 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /docs/src/test/java/com/example/mockmvc/InvokeService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2023 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.example.mockmvc; 18 | 19 | import org.springframework.http.MediaType; 20 | import org.springframework.test.web.servlet.MockMvc; 21 | 22 | import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; 23 | import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; 24 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; 25 | 26 | public class InvokeService { 27 | 28 | private MockMvc mockMvc; 29 | 30 | public void invokeService() throws Exception { 31 | // tag::invoke-service[] 32 | this.mockMvc.perform(get("/").accept(MediaType.APPLICATION_JSON)) // <1> 33 | .andExpect(status().isOk()) // <2> 34 | .andDo(document("index")); // <3> 35 | // end::invoke-service[] 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /docs/src/test/java/com/example/mockmvc/RequestParts.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2023 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.example.mockmvc; 18 | 19 | import org.springframework.test.web.servlet.MockMvc; 20 | 21 | import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; 22 | import static org.springframework.restdocs.request.RequestDocumentation.partWithName; 23 | import static org.springframework.restdocs.request.RequestDocumentation.requestParts; 24 | import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.multipart; 25 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; 26 | 27 | public class RequestParts { 28 | 29 | private MockMvc mockMvc; 30 | 31 | public void upload() throws Exception { 32 | // tag::request-parts[] 33 | this.mockMvc.perform(multipart("/upload").file("file", "example".getBytes())) // <1> 34 | .andExpect(status().isOk()) 35 | .andDo(document("upload", requestParts(// <2> 36 | partWithName("file").description("The file to upload")) // <3> 37 | )); 38 | // end::request-parts[] 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /docs/src/test/java/com/example/restassured/CustomDefaultSnippets.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2023 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.example.restassured; 18 | 19 | import io.restassured.builder.RequestSpecBuilder; 20 | import io.restassured.specification.RequestSpecification; 21 | import org.junit.Before; 22 | import org.junit.Rule; 23 | 24 | import org.springframework.restdocs.JUnitRestDocumentation; 25 | 26 | import static org.springframework.restdocs.cli.CliDocumentation.curlRequest; 27 | import static org.springframework.restdocs.restassured.RestAssuredRestDocumentation.documentationConfiguration; 28 | 29 | public class CustomDefaultSnippets { 30 | 31 | @Rule 32 | public final JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation(); 33 | 34 | @SuppressWarnings("unused") 35 | private RequestSpecification spec; 36 | 37 | @Before 38 | public void setUp() { 39 | // tag::custom-default-snippets[] 40 | this.spec = new RequestSpecBuilder() 41 | .addFilter(documentationConfiguration(this.restDocumentation).snippets().withDefaults(curlRequest())) 42 | .build(); 43 | // end::custom-default-snippets[] 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /docs/src/test/java/com/example/restassured/CustomEncoding.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2023 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.example.restassured; 18 | 19 | import io.restassured.builder.RequestSpecBuilder; 20 | import io.restassured.specification.RequestSpecification; 21 | import org.junit.Before; 22 | import org.junit.Rule; 23 | 24 | import org.springframework.restdocs.JUnitRestDocumentation; 25 | 26 | import static org.springframework.restdocs.restassured.RestAssuredRestDocumentation.documentationConfiguration; 27 | 28 | public class CustomEncoding { 29 | 30 | @Rule 31 | public final JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation(); 32 | 33 | @SuppressWarnings("unused") 34 | private RequestSpecification spec; 35 | 36 | @Before 37 | public void setUp() { 38 | // tag::custom-encoding[] 39 | this.spec = new RequestSpecBuilder() 40 | .addFilter(documentationConfiguration(this.restDocumentation).snippets().withEncoding("ISO-8859-1")) 41 | .build(); 42 | // end::custom-encoding[] 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /docs/src/test/java/com/example/restassured/CustomFormat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2023 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.example.restassured; 18 | 19 | import io.restassured.builder.RequestSpecBuilder; 20 | import io.restassured.specification.RequestSpecification; 21 | import org.junit.Before; 22 | import org.junit.Rule; 23 | 24 | import org.springframework.restdocs.JUnitRestDocumentation; 25 | import org.springframework.restdocs.templates.TemplateFormats; 26 | 27 | import static org.springframework.restdocs.restassured.RestAssuredRestDocumentation.documentationConfiguration; 28 | 29 | public class CustomFormat { 30 | 31 | @Rule 32 | public final JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation(); 33 | 34 | @SuppressWarnings("unused") 35 | private RequestSpecification spec; 36 | 37 | @Before 38 | public void setUp() { 39 | // tag::custom-format[] 40 | this.spec = new RequestSpecBuilder() 41 | .addFilter(documentationConfiguration(this.restDocumentation).snippets() 42 | .withTemplateFormat(TemplateFormats.markdown())) 43 | .build(); 44 | // end::custom-format[] 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /docs/src/test/java/com/example/restassured/ExampleApplicationJUnit5Tests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2023 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.example.restassured; 18 | 19 | import io.restassured.builder.RequestSpecBuilder; 20 | import io.restassured.specification.RequestSpecification; 21 | import org.junit.jupiter.api.BeforeEach; 22 | import org.junit.jupiter.api.extension.ExtendWith; 23 | 24 | import org.springframework.restdocs.RestDocumentationContextProvider; 25 | import org.springframework.restdocs.RestDocumentationExtension; 26 | 27 | import static org.springframework.restdocs.restassured.RestAssuredRestDocumentation.documentationConfiguration; 28 | 29 | @ExtendWith(RestDocumentationExtension.class) 30 | class ExampleApplicationJUnit5Tests { 31 | 32 | @SuppressWarnings("unused") 33 | // tag::setup[] 34 | private RequestSpecification spec; 35 | 36 | @BeforeEach 37 | void setUp(RestDocumentationContextProvider restDocumentation) { 38 | this.spec = new RequestSpecBuilder().addFilter(documentationConfiguration(restDocumentation)) // <1> 39 | .build(); 40 | } 41 | // end::setup[] 42 | 43 | } 44 | -------------------------------------------------------------------------------- /docs/src/test/java/com/example/restassured/ExampleApplicationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2023 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.example.restassured; 18 | 19 | import io.restassured.builder.RequestSpecBuilder; 20 | import io.restassured.specification.RequestSpecification; 21 | import org.junit.Before; 22 | import org.junit.Rule; 23 | 24 | import org.springframework.restdocs.JUnitRestDocumentation; 25 | 26 | import static org.springframework.restdocs.restassured.RestAssuredRestDocumentation.documentationConfiguration; 27 | 28 | public class ExampleApplicationTests { 29 | 30 | @Rule 31 | public final JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation(); 32 | 33 | @SuppressWarnings("unused") 34 | // tag::setup[] 35 | private RequestSpecification spec; 36 | 37 | @Before 38 | public void setUp() { 39 | this.spec = new RequestSpecBuilder().addFilter(documentationConfiguration(this.restDocumentation)) // <1> 40 | .build(); 41 | } 42 | // end::setup[] 43 | 44 | } 45 | -------------------------------------------------------------------------------- /docs/src/test/java/com/example/restassured/FormParameters.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2023 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.example.restassured; 18 | 19 | import io.restassured.RestAssured; 20 | import io.restassured.specification.RequestSpecification; 21 | 22 | import static org.hamcrest.CoreMatchers.is; 23 | import static org.springframework.restdocs.request.RequestDocumentation.formParameters; 24 | import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName; 25 | import static org.springframework.restdocs.restassured.RestAssuredRestDocumentation.document; 26 | 27 | public class FormParameters { 28 | 29 | private RequestSpecification spec; 30 | 31 | public void postFormDataSnippet() { 32 | // tag::form-parameters[] 33 | RestAssured.given(this.spec) 34 | .filter(document("create-user", formParameters(// <1> 35 | parameterWithName("username").description("The user's username")))) // <2> 36 | .formParam("username", "Tester") 37 | .when() 38 | .post("/users") // <3> 39 | .then() 40 | .assertThat() 41 | .statusCode(is(200)); 42 | // end::form-parameters[] 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /docs/src/test/java/com/example/restassured/InvokeService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2023 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.example.restassured; 18 | 19 | import io.restassured.RestAssured; 20 | import io.restassured.specification.RequestSpecification; 21 | 22 | import static org.hamcrest.CoreMatchers.is; 23 | import static org.springframework.restdocs.restassured.RestAssuredRestDocumentation.document; 24 | 25 | public class InvokeService { 26 | 27 | private RequestSpecification spec; 28 | 29 | public void invokeService() { 30 | // tag::invoke-service[] 31 | RestAssured.given(this.spec) // <1> 32 | .accept("application/json") // <2> 33 | .filter(document("index")) // <3> 34 | .when() 35 | .get("/") // <4> 36 | .then() 37 | .assertThat() 38 | .statusCode(is(200)); // <5> 39 | // end::invoke-service[] 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /docs/src/test/java/com/example/restassured/ParameterizedOutput.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2023 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.example.restassured; 18 | 19 | import io.restassured.builder.RequestSpecBuilder; 20 | import io.restassured.specification.RequestSpecification; 21 | import org.junit.Before; 22 | import org.junit.Rule; 23 | 24 | import org.springframework.restdocs.JUnitRestDocumentation; 25 | 26 | import static org.springframework.restdocs.restassured.RestAssuredRestDocumentation.document; 27 | import static org.springframework.restdocs.restassured.RestAssuredRestDocumentation.documentationConfiguration; 28 | 29 | public class ParameterizedOutput { 30 | 31 | @Rule 32 | public final JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation(); 33 | 34 | @SuppressWarnings("unused") 35 | private RequestSpecification spec; 36 | 37 | // tag::parameterized-output[] 38 | @Before 39 | public void setUp() { 40 | this.spec = new RequestSpecBuilder().addFilter(documentationConfiguration(this.restDocumentation)) 41 | .addFilter(document("{method-name}/{step}")) 42 | .build(); 43 | } 44 | // end::parameterized-output[] 45 | 46 | } 47 | -------------------------------------------------------------------------------- /docs/src/test/java/com/example/restassured/RequestParts.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2023 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.example.restassured; 18 | 19 | import io.restassured.RestAssured; 20 | import io.restassured.specification.RequestSpecification; 21 | 22 | import static org.hamcrest.CoreMatchers.is; 23 | import static org.springframework.restdocs.request.RequestDocumentation.partWithName; 24 | import static org.springframework.restdocs.request.RequestDocumentation.requestParts; 25 | import static org.springframework.restdocs.restassured.RestAssuredRestDocumentation.document; 26 | 27 | public class RequestParts { 28 | 29 | private RequestSpecification spec; 30 | 31 | public void upload() { 32 | // tag::request-parts[] 33 | RestAssured.given(this.spec) 34 | .filter(document("users", requestParts(// <1> 35 | partWithName("file").description("The file to upload")))) // <2> 36 | .multiPart("file", "example") // <3> 37 | .when() 38 | .post("/upload") // <4> 39 | .then() 40 | .statusCode(is(200)); 41 | // end::request-parts[] 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /docs/src/test/java/com/example/restassured/RestAssuredSnippetReuse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2023 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.example.restassured; 18 | 19 | import com.example.SnippetReuse; 20 | import io.restassured.RestAssured; 21 | import io.restassured.specification.RequestSpecification; 22 | 23 | import static org.hamcrest.CoreMatchers.is; 24 | import static org.springframework.restdocs.hypermedia.HypermediaDocumentation.linkWithRel; 25 | import static org.springframework.restdocs.restassured.RestAssuredRestDocumentation.document; 26 | 27 | public class RestAssuredSnippetReuse extends SnippetReuse { 28 | 29 | private RequestSpecification spec; 30 | 31 | public void documentation() { 32 | // tag::use[] 33 | RestAssured.given(this.spec) 34 | .accept("application/json") 35 | .filter(document("example", this.pagingLinks.and(// <1> 36 | linkWithRel("alpha").description("Link to the alpha resource"), 37 | linkWithRel("bravo").description("Link to the bravo resource")))) 38 | .get("/") 39 | .then() 40 | .assertThat() 41 | .statusCode(is(200)); 42 | // end::use[] 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /docs/src/test/java/com/example/webtestclient/InvokeService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2023 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.example.webtestclient; 18 | 19 | import org.springframework.http.MediaType; 20 | import org.springframework.test.web.reactive.server.WebTestClient; 21 | 22 | import static org.springframework.restdocs.webtestclient.WebTestClientRestDocumentation.document; 23 | 24 | public class InvokeService { 25 | 26 | private WebTestClient webTestClient; 27 | 28 | public void invokeService() { 29 | // tag::invoke-service[] 30 | this.webTestClient.get() 31 | .uri("/") 32 | .accept(MediaType.APPLICATION_JSON) // <1> 33 | .exchange() 34 | .expectStatus() 35 | .isOk() // <2> 36 | .expectBody() 37 | .consumeWith(document("index")); // <3> 38 | // end::invoke-service[] 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /docs/src/test/java/com/example/webtestclient/PathParameters.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.example.webtestclient; 18 | 19 | import org.springframework.test.web.reactive.server.WebTestClient; 20 | 21 | import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName; 22 | import static org.springframework.restdocs.request.RequestDocumentation.pathParameters; 23 | import static org.springframework.restdocs.webtestclient.WebTestClientRestDocumentation.document; 24 | 25 | public class PathParameters { 26 | 27 | // @formatter:off 28 | 29 | private WebTestClient webTestClient; 30 | 31 | public void pathParametersSnippet() { 32 | // tag::path-parameters[] 33 | this.webTestClient.get().uri("/locations/{latitude}/{longitude}", 51.5072, 0.1275) // <1> 34 | .exchange().expectStatus().isOk().expectBody() 35 | .consumeWith(document("locations", 36 | pathParameters(// <2> 37 | parameterWithName("latitude").description("The location's latitude"), // <3> 38 | parameterWithName("longitude").description("The location's longitude")))); // <4> 39 | // end::path-parameters[] 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /docs/src/test/java/com/example/webtestclient/QueryParameters.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.example.webtestclient; 18 | 19 | import org.springframework.test.web.reactive.server.WebTestClient; 20 | 21 | import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName; 22 | import static org.springframework.restdocs.request.RequestDocumentation.queryParameters; 23 | import static org.springframework.restdocs.webtestclient.WebTestClientRestDocumentation.document; 24 | 25 | public class QueryParameters { 26 | 27 | // @formatter:off 28 | 29 | private WebTestClient webTestClient; 30 | 31 | public void getQueryStringSnippet() { 32 | // tag::query-parameters[] 33 | this.webTestClient.get().uri("/users?page=2&per_page=100") // <1> 34 | .exchange().expectStatus().isOk().expectBody() 35 | .consumeWith(document("users", queryParameters(// <2> 36 | parameterWithName("page").description("The page to retrieve"), // <3> 37 | parameterWithName("per_page").description("Entries per page") // <4> 38 | ))); 39 | // end::query-parameters[] 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /docs/src/test/java/com/example/webtestclient/WebTestClientSnippetReuse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.example.webtestclient; 18 | 19 | import com.example.SnippetReuse; 20 | 21 | import org.springframework.http.MediaType; 22 | import org.springframework.test.web.reactive.server.WebTestClient; 23 | 24 | import static org.springframework.restdocs.hypermedia.HypermediaDocumentation.linkWithRel; 25 | import static org.springframework.restdocs.webtestclient.WebTestClientRestDocumentation.document; 26 | 27 | public class WebTestClientSnippetReuse extends SnippetReuse { 28 | 29 | // @formatter:off 30 | 31 | private WebTestClient webTestClient; 32 | 33 | public void documentation() { 34 | // tag::use[] 35 | this.webTestClient.get().uri("/").accept(MediaType.APPLICATION_JSON).exchange() 36 | .expectStatus().isOk().expectBody() 37 | .consumeWith(document("example", this.pagingLinks.and(// <1> 38 | linkWithRel("alpha").description("Link to the alpha resource"), 39 | linkWithRel("bravo").description("Link to the bravo resource")))); 40 | // end::use[] 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | version=4.0.0-SNAPSHOT 2 | 3 | org.gradle.caching=true 4 | org.gradle.jvmargs=-Xmx2g -Dfile.encoding=UTF-8 5 | org.gradle.parallel=true 6 | 7 | javaFormatVersion=0.0.43 8 | jmustacheVersion=1.15 9 | springFrameworkVersion=7.0.0-M1 10 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spring-projects/spring-restdocs/1d34bcb53c770d523deddfa9588c74759db4fbb5/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | mavenCentral() 4 | gradlePluginPortal() 5 | maven { url 'https://repo.spring.io/snapshot' } 6 | } 7 | resolutionStrategy { 8 | eachPlugin { 9 | if (requested.id.id == "io.spring.javaformat") { 10 | useModule "io.spring.javaformat:spring-javaformat-gradle-plugin:${requested.version}" 11 | } 12 | } 13 | } 14 | } 15 | 16 | plugins { 17 | id "io.spring.develocity.conventions" version "0.0.21" 18 | } 19 | 20 | rootProject.name = "spring-restdocs" 21 | 22 | include "docs" 23 | include "spring-restdocs-asciidoctor" 24 | include "spring-restdocs-bom" 25 | include "spring-restdocs-core" 26 | include "spring-restdocs-mockmvc" 27 | include "spring-restdocs-platform" 28 | include "spring-restdocs-restassured" 29 | include "spring-restdocs-webtestclient" 30 | -------------------------------------------------------------------------------- /spring-restdocs-asciidoctor/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "java-library" 3 | id "maven-publish" 4 | } 5 | 6 | description = "Spring REST Docs Asciidoctor Extension" 7 | 8 | dependencies { 9 | implementation("org.asciidoctor:asciidoctorj") 10 | 11 | internal(platform(project(":spring-restdocs-platform"))) 12 | 13 | testImplementation("junit:junit") 14 | testImplementation("org.apache.pdfbox:pdfbox") 15 | testImplementation("org.assertj:assertj-core") 16 | testImplementation("org.springframework:spring-core") 17 | 18 | testRuntimeOnly("org.asciidoctor:asciidoctorj-pdf") 19 | } 20 | -------------------------------------------------------------------------------- /spring-restdocs-asciidoctor/src/main/java/org/springframework/restdocs/asciidoctor/DefaultAttributesPreprocessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.restdocs.asciidoctor; 18 | 19 | import org.asciidoctor.ast.Document; 20 | import org.asciidoctor.extension.Preprocessor; 21 | import org.asciidoctor.extension.PreprocessorReader; 22 | import org.asciidoctor.extension.Reader; 23 | 24 | /** 25 | * {@link Preprocessor} that sets defaults for REST Docs-related {@link Document} 26 | * attributes. 27 | * 28 | * @author Andy Wilkinson 29 | */ 30 | final class DefaultAttributesPreprocessor extends Preprocessor { 31 | 32 | private final SnippetsDirectoryResolver snippetsDirectoryResolver = new SnippetsDirectoryResolver(); 33 | 34 | @Override 35 | public Reader process(Document document, PreprocessorReader reader) { 36 | document.setAttribute("snippets", this.snippetsDirectoryResolver.getSnippetsDirectory(document.getAttributes()), 37 | false); 38 | return reader; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /spring-restdocs-asciidoctor/src/main/java/org/springframework/restdocs/asciidoctor/RestDocsExtensionRegistry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2023 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.restdocs.asciidoctor; 18 | 19 | import org.asciidoctor.Asciidoctor; 20 | import org.asciidoctor.jruby.extension.spi.ExtensionRegistry; 21 | 22 | /** 23 | * {@link ExtensionRegistry} for Spring REST Docs. 24 | * 25 | * @author Andy Wilkinson 26 | */ 27 | public final class RestDocsExtensionRegistry implements ExtensionRegistry { 28 | 29 | @Override 30 | public void register(Asciidoctor asciidoctor) { 31 | asciidoctor.javaExtensionRegistry().preprocessor(new DefaultAttributesPreprocessor()); 32 | asciidoctor.rubyExtensionRegistry() 33 | .loadClass(RestDocsExtensionRegistry.class.getResourceAsStream("/extensions/operation_block_macro.rb")) 34 | .blockMacro("operation", "OperationBlockMacro"); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /spring-restdocs-asciidoctor/src/main/java/org/springframework/restdocs/asciidoctor/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Support for Asciidoctor. 19 | */ 20 | package org.springframework.restdocs.asciidoctor; 21 | -------------------------------------------------------------------------------- /spring-restdocs-asciidoctor/src/main/resources/META-INF/services/org.asciidoctor.jruby.extension.spi.ExtensionRegistry: -------------------------------------------------------------------------------- 1 | org.springframework.restdocs.asciidoctor.RestDocsExtensionRegistry 2 | -------------------------------------------------------------------------------- /spring-restdocs-asciidoctor/src/test/java/org/springframework/restdocs/asciidoctor/CapturingLogHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.restdocs.asciidoctor; 18 | 19 | import java.util.ArrayList; 20 | import java.util.List; 21 | 22 | import org.asciidoctor.log.LogHandler; 23 | import org.asciidoctor.log.LogRecord; 24 | 25 | public class CapturingLogHandler implements LogHandler { 26 | 27 | private static final List logRecords = new ArrayList(); 28 | 29 | @Override 30 | public void log(LogRecord logRecord) { 31 | logRecords.add(logRecord); 32 | } 33 | 34 | static List getLogRecords() { 35 | return logRecords; 36 | } 37 | 38 | static void clear() { 39 | logRecords.clear(); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /spring-restdocs-asciidoctor/src/test/resources/META-INF/services/org.asciidoctor.log.LogHandler: -------------------------------------------------------------------------------- 1 | org.springframework.restdocs.asciidoctor.CapturingLogHandler -------------------------------------------------------------------------------- /spring-restdocs-asciidoctor/src/test/resources/operations/built-in-snippet-custom-title.html: -------------------------------------------------------------------------------- 1 |
2 |

Example request

3 |
4 |
5 |
6 |
$ curl 'http://localhost:8080/' -i
7 |
8 |
9 |
10 |
-------------------------------------------------------------------------------- /spring-restdocs-asciidoctor/src/test/resources/operations/custom-snippet-custom-title.html: -------------------------------------------------------------------------------- 1 |
2 |

Customized title

3 |
4 |
5 |
6 |
mycustomsnippet-äöü
7 |
8 |
9 |
10 |
-------------------------------------------------------------------------------- /spring-restdocs-asciidoctor/src/test/resources/operations/custom-snippet-default-title.html: -------------------------------------------------------------------------------- 1 |
2 |

Custom snippet

3 |
4 |
5 |
6 |
mycustomsnippet-äöü
7 |
8 |
9 |
10 |
-------------------------------------------------------------------------------- /spring-restdocs-asciidoctor/src/test/resources/operations/missing-operation.html: -------------------------------------------------------------------------------- 1 |
2 |

No snippets found for operation::missing-operation

3 |
-------------------------------------------------------------------------------- /spring-restdocs-asciidoctor/src/test/resources/operations/missing-snippet.html: -------------------------------------------------------------------------------- 1 |
2 |

Missing snippet

3 |
4 |
5 |

Snippet missing-snippet not found for operation::some-operation

6 |
7 |
8 |
-------------------------------------------------------------------------------- /spring-restdocs-asciidoctor/src/test/resources/operations/multiple-snippets.html: -------------------------------------------------------------------------------- 1 |
2 |

Curl request

3 |
4 |
5 |
6 |
$ curl 'http://localhost:8080/' -i
7 |
8 |
9 |
10 |
11 |
12 |

HTTP request

13 |
14 |
15 |
16 |
GET / HTTP/1.1
17 | Host: localhost:8080
18 |
19 |
20 |
21 |
-------------------------------------------------------------------------------- /spring-restdocs-asciidoctor/src/test/resources/operations/snippet-in-section.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |

Alpha

5 |
6 |
7 |
8 |
9 |

1. B

10 |
11 |
12 |

Bravo

13 |
14 |
15 |

1.1. Curl request

16 |
17 |
18 |
$ curl 'http://localhost:8080/' -i
19 |
20 |
21 |
22 |
23 |
24 |
25 |

2. C

26 |
27 | 28 |
29 |
-------------------------------------------------------------------------------- /spring-restdocs-asciidoctor/src/test/resources/operations/snippet-simple.html: -------------------------------------------------------------------------------- 1 |
2 |

Curl request

3 |
4 |
5 |
6 |
$ curl 'http://localhost:8080/' -i
7 |
8 |
9 |
10 |
-------------------------------------------------------------------------------- /spring-restdocs-asciidoctor/src/test/resources/operations/snippet-table.html: -------------------------------------------------------------------------------- 1 |
2 |

Response fields

3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 |
PathTypeDescription

a

Object

one

a.b

Number

two

a.c

String

three

35 |
36 |
-------------------------------------------------------------------------------- /spring-restdocs-asciidoctor/src/test/resources/operations/snippet-with-level.html: -------------------------------------------------------------------------------- 1 |
2 |

Curl request

3 |
4 |
5 |
$ curl 'http://localhost:8080/' -i
6 |
7 |
8 |
-------------------------------------------------------------------------------- /spring-restdocs-asciidoctor/src/test/resources/sample-snippet.adoc: -------------------------------------------------------------------------------- 1 | [source,bash] 2 | ---- 3 | $ curl 'http://localhost:8080/' -i -H 'Accept: application/hal+json' 4 | ---- -------------------------------------------------------------------------------- /spring-restdocs-asciidoctor/src/test/resources/some-operation/curl-request.adoc: -------------------------------------------------------------------------------- 1 | [source,bash] 2 | ---- 3 | $ curl 'http://localhost:8080/' -i 4 | ---- -------------------------------------------------------------------------------- /spring-restdocs-asciidoctor/src/test/resources/some-operation/custom-snippet.adoc: -------------------------------------------------------------------------------- 1 | [source,http,options="nowrap"] 2 | ---- 3 | mycustomsnippet-äöü 4 | ---- -------------------------------------------------------------------------------- /spring-restdocs-asciidoctor/src/test/resources/some-operation/http-request.adoc: -------------------------------------------------------------------------------- 1 | [source,http,options="nowrap"] 2 | ---- 3 | GET / HTTP/1.1 4 | Host: localhost:8080 5 | 6 | ---- -------------------------------------------------------------------------------- /spring-restdocs-asciidoctor/src/test/resources/some-operation/response-fields.adoc: -------------------------------------------------------------------------------- 1 | |=== 2 | |Path|Type|Description 3 | 4 | |`a` 5 | |`Object` 6 | |one 7 | 8 | |`a.b` 9 | |`Number` 10 | |two 11 | 12 | |`a.c` 13 | |`String` 14 | |three 15 | 16 | |=== -------------------------------------------------------------------------------- /spring-restdocs-bom/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "java-platform" 3 | id "maven-publish" 4 | } 5 | 6 | description = "Spring REST Docs Bill of Materials" 7 | 8 | dependencies { 9 | constraints { 10 | api(project(":spring-restdocs-asciidoctor")) 11 | api(project(":spring-restdocs-core")) 12 | api(project(":spring-restdocs-mockmvc")) 13 | api(project(":spring-restdocs-restassured")) 14 | api(project(":spring-restdocs-webtestclient")) 15 | } 16 | } -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/RestDocumentationContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.restdocs; 18 | 19 | import java.io.File; 20 | 21 | /** 22 | * {@code RestDocumentationContext} encapsulates the context in which the documentation of 23 | * a RESTful API is being performed. 24 | * 25 | * @author Andy Wilkinson 26 | */ 27 | public interface RestDocumentationContext { 28 | 29 | /** 30 | * Returns the class whose tests are currently executing. 31 | * @return the test class 32 | */ 33 | Class getTestClass(); 34 | 35 | /** 36 | * Returns the name of the test method that is currently executing. 37 | * @return the name of the test method 38 | */ 39 | String getTestMethodName(); 40 | 41 | /** 42 | * Returns the current step count. 43 | * @return the current step count 44 | */ 45 | int getStepCount(); 46 | 47 | /** 48 | * Returns the output directory to which generated snippets should be written. 49 | * @return the output directory 50 | */ 51 | File getOutputDirectory(); 52 | 53 | } 54 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/RestDocumentationContextProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.restdocs; 18 | 19 | /** 20 | * A {@code RestDocumentationContextProvider} is used to provide access to the 21 | * {@link RestDocumentationContext}. 22 | * 23 | * @author Andy Wilkinson 24 | * @since 1.1.0 25 | */ 26 | public interface RestDocumentationContextProvider { 27 | 28 | /** 29 | * Returns a {@link RestDocumentationContext} for the operation that is about to be 30 | * performed. 31 | * @return the context for the operation 32 | */ 33 | RestDocumentationContext beforeOperation(); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/cli/CommandFormatter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.restdocs.cli; 18 | 19 | import java.util.List; 20 | 21 | /** 22 | * Formatter for CLI commands such as those included in {@link CurlRequestSnippet} and 23 | * {@link HttpieRequestSnippet}. 24 | * 25 | * @author Tomasz Kopczynski 26 | * @since 1.2.0 27 | */ 28 | public interface CommandFormatter { 29 | 30 | /** 31 | * Formats a list of {@code elements} into a single {@code String}. 32 | * @param elements the {@code String} elements to be formatted 33 | * @return a single formatted {@code String} 34 | */ 35 | String format(List elements); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/cli/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Documenting CLI commands required to make a request to a RESTful API. 19 | */ 20 | package org.springframework.restdocs.cli; 21 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/config/AbstractConfigurer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.restdocs.config; 18 | 19 | import java.util.Map; 20 | 21 | import org.springframework.restdocs.RestDocumentationContext; 22 | 23 | /** 24 | * Abstract configurer that declares methods that are internal to the documentation 25 | * configuration implementation. 26 | * 27 | * @author Andy Wilkinson 28 | * @since 1.1.0 29 | */ 30 | public abstract class AbstractConfigurer { 31 | 32 | /** 33 | * Applies the configurer to the given {@code configuration}. 34 | * @param configuration the configuration to be configured 35 | * @param context the current documentation context 36 | */ 37 | public abstract void apply(Map configuration, RestDocumentationContext context); 38 | 39 | } 40 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/config/AbstractNestedConfigurer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.restdocs.config; 18 | 19 | /** 20 | * Base class for {@link NestedConfigurer} implementations. 21 | * 22 | * @param the type of the configurer's parent 23 | * @author Andy Wilkinson 24 | * @since 1.1.0 25 | */ 26 | public abstract class AbstractNestedConfigurer extends AbstractConfigurer implements NestedConfigurer { 27 | 28 | private final PARENT parent; 29 | 30 | /** 31 | * Creates a new {@code AbstractNestedConfigurer} with the given {@code parent}. 32 | * @param parent the parent 33 | */ 34 | protected AbstractNestedConfigurer(PARENT parent) { 35 | this.parent = parent; 36 | } 37 | 38 | @Override 39 | public final PARENT and() { 40 | return this.parent; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/config/NestedConfigurer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.restdocs.config; 18 | 19 | /** 20 | * A configurer that is nested and, therefore, has a parent. 21 | * 22 | * @param the parent's type 23 | * @author Andy Wilkinson 24 | * @since 1.1.0 25 | */ 26 | interface NestedConfigurer { 27 | 28 | /** 29 | * Returns the configurer's parent. 30 | * @return the parent 31 | */ 32 | PARENT and(); 33 | 34 | } 35 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/config/SnippetConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.restdocs.config; 18 | 19 | import org.springframework.restdocs.templates.TemplateFormat; 20 | 21 | /** 22 | * An encapsulation of the configuration for documentation snippets. 23 | * 24 | * @author Andy Wilkinson 25 | * @since 1.1.0 26 | */ 27 | class SnippetConfiguration { 28 | 29 | private final String encoding; 30 | 31 | private final TemplateFormat format; 32 | 33 | SnippetConfiguration(String encoding, TemplateFormat templateFormat) { 34 | this.encoding = encoding; 35 | this.format = templateFormat; 36 | } 37 | 38 | String getEncoding() { 39 | return this.encoding; 40 | } 41 | 42 | TemplateFormat getTemplateFormat() { 43 | return this.format; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/config/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Classes for configuring Spring REST Docs. 19 | */ 20 | package org.springframework.restdocs.config; 21 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/constraints/ConstraintDescriptionResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.restdocs.constraints; 18 | 19 | /** 20 | * Resolves a description for a {@link Constraint}. 21 | * 22 | * @author Andy Wilkinson 23 | */ 24 | public interface ConstraintDescriptionResolver { 25 | 26 | /** 27 | * Resolves the description for the given {@code constraint}. 28 | * @param constraint the constraint 29 | * @return the description 30 | */ 31 | String resolveDescription(Constraint constraint); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/constraints/ConstraintResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.restdocs.constraints; 18 | 19 | import java.util.List; 20 | 21 | /** 22 | * An abstraction for resolving a class's constraints. 23 | * 24 | * @author Andy Wilkinson 25 | */ 26 | public interface ConstraintResolver { 27 | 28 | /** 29 | * Resolves and returns the constraints for the given {@code property} on the given 30 | * {@code clazz}. If there are no constraints, an empty list is returned. 31 | * @param property the property 32 | * @param clazz the class 33 | * @return the list of constraints, never {@code null} 34 | */ 35 | List resolveForProperty(String property, Class clazz); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/constraints/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Documenting a RESTful API's constraints. 19 | */ 20 | package org.springframework.restdocs.constraints; 21 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/cookies/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Documenting the cookies of a RESTful API's requests and responses. 19 | */ 20 | package org.springframework.restdocs.cookies; 21 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/generate/RestDocumentationGenerationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.restdocs.generate; 18 | 19 | /** 20 | * An exception that can be thrown when a failure occurs during REST documentation 21 | * generation. 22 | * 23 | * @author Andy Wilkinson 24 | * @since 1.1.0 25 | */ 26 | public class RestDocumentationGenerationException extends RuntimeException { 27 | 28 | /** 29 | * Creates a new {@code RestDocumentationException} with the given {@code cause}. 30 | * @param cause the cause 31 | */ 32 | public RestDocumentationGenerationException(Throwable cause) { 33 | super(cause); 34 | } 35 | 36 | /** 37 | * Creates a new {@code RestDocumentationException} with the given {@code message} and 38 | * {@code cause}. 39 | * @param message the message 40 | * @param cause the cause 41 | */ 42 | public RestDocumentationGenerationException(String message, Throwable cause) { 43 | super(message, cause); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/generate/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Classes that drive the generation of the documentation snippets. 19 | */ 20 | package org.springframework.restdocs.generate; 21 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/headers/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Documenting the headers of a RESTful API's requests and responses. 19 | */ 20 | package org.springframework.restdocs.headers; 21 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/http/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Documenting the HTTP request sent to a RESTful API and the HTTP response that is 19 | * returned. 20 | */ 21 | package org.springframework.restdocs.http; 22 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/AbstractJsonLinkExtractor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.restdocs.hypermedia; 18 | 19 | import java.io.IOException; 20 | import java.util.List; 21 | import java.util.Map; 22 | 23 | import com.fasterxml.jackson.databind.ObjectMapper; 24 | 25 | import org.springframework.restdocs.operation.OperationResponse; 26 | 27 | /** 28 | * Abstract base class for a {@link LinkExtractor} that extracts links from JSON. 29 | * 30 | * @author Andy Wilkinson 31 | */ 32 | abstract class AbstractJsonLinkExtractor implements LinkExtractor { 33 | 34 | private final ObjectMapper objectMapper = new ObjectMapper(); 35 | 36 | @Override 37 | @SuppressWarnings("unchecked") 38 | public Map> extractLinks(OperationResponse response) throws IOException { 39 | Map jsonContent = this.objectMapper.readValue(response.getContent(), Map.class); 40 | return extractLinks(jsonContent); 41 | } 42 | 43 | protected abstract Map> extractLinks(Map json); 44 | 45 | } 46 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/LinkExtractor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.restdocs.hypermedia; 18 | 19 | import java.io.IOException; 20 | import java.util.List; 21 | import java.util.Map; 22 | 23 | import org.springframework.restdocs.operation.OperationResponse; 24 | 25 | /** 26 | * A {@code LinkExtractor} is used to extract {@link Link links} from a JSON response. The 27 | * expected format of the links in the response is determined by the implementation. 28 | * 29 | * @author Andy Wilkinson 30 | * 31 | */ 32 | public interface LinkExtractor { 33 | 34 | /** 35 | * Extract the links from the given {@code response}, returning a {@code Map} of links 36 | * where the keys are the link rels. 37 | * @param response the response from which the links are to be extracted 38 | * @return the extracted links, keyed by rel 39 | * @throws IOException if link extraction fails 40 | */ 41 | Map> extractLinks(OperationResponse response) throws IOException; 42 | 43 | } 44 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Documenting a RESTful API that uses hypermedia. 19 | */ 20 | package org.springframework.restdocs.hypermedia; 21 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/ConversionException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.restdocs.operation; 18 | 19 | /** 20 | * An exception that can be thrown by {@link RequestConverter} and 21 | * {@link ResponseConverter} implementations to indicate that a failure has occurred 22 | * during conversion. 23 | * 24 | * @author Andy Wilkinson 25 | * @since 1.1.0 26 | * @see RequestConverter#convert(Object) 27 | * @see ResponseConverter#convert(Object) 28 | */ 29 | public class ConversionException extends RuntimeException { 30 | 31 | /** 32 | * Creates a new {@code ConversionException} with the given {@code cause}. 33 | * @param cause the cause 34 | */ 35 | public ConversionException(Throwable cause) { 36 | super(cause); 37 | } 38 | 39 | /** 40 | * Creates a new {@code ConversionException} with the given {@code message} and 41 | * {@code cause}. 42 | * @param message the message 43 | * @param cause the cause 44 | */ 45 | public ConversionException(String message, Throwable cause) { 46 | super(message, cause); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/Operation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.restdocs.operation; 18 | 19 | import java.util.Map; 20 | 21 | /** 22 | * Describes an operation performed on a RESTful service. 23 | * 24 | * @author Andy Wilkinson 25 | */ 26 | public interface Operation { 27 | 28 | /** 29 | * Returns a {@code Map} of attributes associated with the operation. 30 | * @return the attributes 31 | */ 32 | Map getAttributes(); 33 | 34 | /** 35 | * Returns the name of the operation. 36 | * @return the name 37 | */ 38 | String getName(); 39 | 40 | /** 41 | * Returns the request that was sent. 42 | * @return the request 43 | */ 44 | OperationRequest getRequest(); 45 | 46 | /** 47 | * Returns the response that was received. 48 | * @return the response 49 | */ 50 | OperationResponse getResponse(); 51 | 52 | } 53 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/OperationMessage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.restdocs.operation; 18 | 19 | import org.springframework.http.HttpHeaders; 20 | 21 | /** 22 | * Base contract for operation requests, request parts, and responses. 23 | * 24 | * @author Andy Wilkinson 25 | */ 26 | interface OperationMessage { 27 | 28 | byte[] getContent(); 29 | 30 | String getContentAsString(); 31 | 32 | HttpHeaders getHeaders(); 33 | 34 | } 35 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/RequestConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.restdocs.operation; 18 | 19 | /** 20 | * A {@code RequestConverter} is used to convert an implementation-specific request into 21 | * an {@link OperationRequest}. 22 | * 23 | * @param the implementation-specific request type 24 | * @author Andy Wilkinson 25 | * @since 1.1.0 26 | */ 27 | public interface RequestConverter { 28 | 29 | /** 30 | * Converts the given {@code request} into an {@code OperationRequest}. 31 | * @param request the request 32 | * @return the operation request 33 | * @throws ConversionException if the conversion fails 34 | */ 35 | OperationRequest convert(R request); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/RequestCookie.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.restdocs.operation; 18 | 19 | /** 20 | * A representation of a Cookie received in a request. 21 | * 22 | * @author Andy Wilkinson 23 | * @since 1.2.0 24 | */ 25 | public final class RequestCookie { 26 | 27 | private final String name; 28 | 29 | private final String value; 30 | 31 | /** 32 | * Creates a new {@code RequestCookie} with the given {@code name} and {@code value}. 33 | * @param name the name of the cookie 34 | * @param value the value of the cookie 35 | */ 36 | public RequestCookie(String name, String value) { 37 | this.name = name; 38 | this.value = value; 39 | } 40 | 41 | /** 42 | * Returns the name of the cookie. 43 | * @return the name 44 | */ 45 | public String getName() { 46 | return this.name; 47 | } 48 | 49 | /** 50 | * Returns the value of the cookie. 51 | * @return the value 52 | */ 53 | public String getValue() { 54 | return this.value; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/ResponseConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.restdocs.operation; 18 | 19 | /** 20 | * A {@code ResponseConverter} is used to convert an implementation-specific response into 21 | * an {@link OperationResponse}. 22 | * 23 | * @param the implementation-specific response type 24 | * @author Andy Wilkinson 25 | * @since 1.1.0 26 | */ 27 | public interface ResponseConverter { 28 | 29 | /** 30 | * Converts the given {@code response} into an {@code OperationResponse}. 31 | * @param response the response 32 | * @return the operation response 33 | * @throws ConversionException if the conversion fails 34 | */ 35 | OperationResponse convert(R response); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/ResponseCookie.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.restdocs.operation; 18 | 19 | /** 20 | * A representation of a Cookie returned in a response. 21 | * 22 | * @author Clyde Stubbs 23 | * @since 3.0 24 | */ 25 | public final class ResponseCookie { 26 | 27 | private final String name; 28 | 29 | private final String value; 30 | 31 | /** 32 | * Creates a new {@code ResponseCookie} with the given {@code name} and {@code value}. 33 | * @param name the name of the cookie 34 | * @param value the value of the cookie 35 | */ 36 | public ResponseCookie(String name, String value) { 37 | this.name = name; 38 | this.value = value; 39 | } 40 | 41 | /** 42 | * Returns the name of the cookie. 43 | * @return the name 44 | */ 45 | public String getName() { 46 | return this.name; 47 | } 48 | 49 | /** 50 | * Returns the value of the cookie. 51 | * @return the value 52 | */ 53 | public String getValue() { 54 | return this.value; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Operation API that describes a request that was sent and the response that was received 19 | * when calling a RESTful API. 20 | */ 21 | package org.springframework.restdocs.operation; 22 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/ContentModifier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.restdocs.operation.preprocess; 18 | 19 | import org.springframework.http.MediaType; 20 | import org.springframework.restdocs.operation.OperationRequest; 21 | import org.springframework.restdocs.operation.OperationResponse; 22 | 23 | /** 24 | * A {@code ContentModifier} modifies the content of an {@link OperationRequest} or 25 | * {@link OperationResponse} during the preprocessing that is performed prior to 26 | * documentation generation. 27 | * 28 | * @author Andy Wilkinson 29 | * @see ContentModifyingOperationPreprocessor 30 | */ 31 | public interface ContentModifier { 32 | 33 | /** 34 | * Returns modified content based on the given {@code originalContent}. 35 | * @param originalContent the original content 36 | * @param contentType the type of the original content, may be {@code null} 37 | * @return the modified content 38 | */ 39 | byte[] modifyContent(byte[] originalContent, MediaType contentType); 40 | 41 | } 42 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/ExactMatchHeaderFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.restdocs.operation.preprocess; 18 | 19 | import java.util.Arrays; 20 | import java.util.HashSet; 21 | import java.util.Set; 22 | 23 | /** 24 | * A {@link HeaderFilter} that excludes a header if its name is an exact match. 25 | * 26 | * @author Andy Wilkinson 27 | */ 28 | class ExactMatchHeaderFilter implements HeaderFilter { 29 | 30 | private final Set headersToExclude; 31 | 32 | ExactMatchHeaderFilter(String... headersToExclude) { 33 | this.headersToExclude = new HashSet<>(Arrays.asList(headersToExclude)); 34 | } 35 | 36 | @Override 37 | public boolean excludeHeader(String name) { 38 | return this.headersToExclude.contains(name); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/HeaderFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.restdocs.operation.preprocess; 18 | 19 | /** 20 | * A strategy for determining whether or not a header should be excluded. 21 | * 22 | * @author Andy Wilkinson 23 | */ 24 | interface HeaderFilter { 25 | 26 | /** 27 | * Called to determine whether a header should be excluded. Return {@code true} to 28 | * exclude a header, otherwise {@code false}. 29 | * @param name the name of the header 30 | * @return {@code true} to exclude the header, otherwise {@code false} 31 | */ 32 | boolean excludeHeader(String name); 33 | 34 | } 35 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/OperationPreprocessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.restdocs.operation.preprocess; 18 | 19 | import org.springframework.restdocs.operation.Operation; 20 | import org.springframework.restdocs.operation.OperationRequest; 21 | import org.springframework.restdocs.operation.OperationResponse; 22 | 23 | /** 24 | * An {@code OperationPreprocessor} processes the {@link OperationRequest} and 25 | * {@link OperationResponse} of an {@link Operation} prior to it being documented. 26 | * 27 | * @author Andy Wilkinson 28 | */ 29 | public interface OperationPreprocessor { 30 | 31 | /** 32 | * Processes the given {@code request}. 33 | * @param request the request to process 34 | * @return the processed request 35 | */ 36 | OperationRequest preprocess(OperationRequest request); 37 | 38 | /** 39 | * Processes the given {@code response}. 40 | * @param response the response to process 41 | * @return the processed response 42 | */ 43 | OperationResponse preprocess(OperationResponse response); 44 | 45 | } 46 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/OperationRequestPreprocessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.restdocs.operation.preprocess; 18 | 19 | import org.springframework.restdocs.operation.OperationRequest; 20 | 21 | /** 22 | * An {@code OperationRequestPreprocessor} is used to modify an {@code OperationRequest} 23 | * prior to it being documented. 24 | * 25 | * @author Andy Wilkinson 26 | */ 27 | public interface OperationRequestPreprocessor { 28 | 29 | /** 30 | * Processes and potentially modifies the given {@code request} before it is 31 | * documented. 32 | * @param request the request 33 | * @return the modified request 34 | */ 35 | OperationRequest preprocess(OperationRequest request); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/OperationResponsePreprocessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.restdocs.operation.preprocess; 18 | 19 | import org.springframework.restdocs.operation.OperationResponse; 20 | 21 | /** 22 | * An {@code OperationResponsePreprocessor} is used to modify an {@code OperationResponse} 23 | * prior to it being documented. 24 | * 25 | * @author Andy Wilkinson 26 | */ 27 | public interface OperationResponsePreprocessor { 28 | 29 | /** 30 | * Processes and potentially modifies the given {@code response} before it is 31 | * documented. 32 | * @param response the response 33 | * @return the modified response 34 | */ 35 | OperationResponse preprocess(OperationResponse response); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/PatternMatchHeaderFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.restdocs.operation.preprocess; 18 | 19 | import java.util.HashSet; 20 | import java.util.Set; 21 | import java.util.regex.Pattern; 22 | 23 | /** 24 | * A {@link HeaderFilter} that excludes a header if its name matches a {@link Pattern}. 25 | * 26 | * @author Andy Wilkinson 27 | * @author Roland Huss 28 | */ 29 | class PatternMatchHeaderFilter implements HeaderFilter { 30 | 31 | private Set exclusionPatterns; 32 | 33 | PatternMatchHeaderFilter(String... exclusionPatterns) { 34 | this.exclusionPatterns = new HashSet<>(); 35 | for (String exclusionPattern : exclusionPatterns) { 36 | this.exclusionPatterns.add(Pattern.compile(exclusionPattern)); 37 | } 38 | } 39 | 40 | @Override 41 | public boolean excludeHeader(String name) { 42 | for (Pattern pattern : this.exclusionPatterns) { 43 | if (pattern.matcher(name).matches()) { 44 | return true; 45 | } 46 | } 47 | return false; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Support for preprocessing an operation prior to it being documented. 19 | */ 20 | package org.springframework.restdocs.operation.preprocess; 21 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Core Spring REST Docs classes. 19 | */ 20 | package org.springframework.restdocs; 21 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/FieldDoesNotExistException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.restdocs.payload; 18 | 19 | /** 20 | * A {@code FieldDoesNotExistException} is thrown when a requested field does not exist in 21 | * a payload. 22 | * 23 | * @author Andy Wilkinson 24 | */ 25 | @SuppressWarnings("serial") 26 | public class FieldDoesNotExistException extends RuntimeException { 27 | 28 | /** 29 | * Creates a new {@code FieldDoesNotExistException} that indicates that the field with 30 | * the given {@code fieldPath} does not exist. 31 | * @param fieldPath the path of the field that does not exist 32 | */ 33 | public FieldDoesNotExistException(String fieldPath) { 34 | super("The payload does not contain a field with the path '" + fieldPath + "'"); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/FieldTypeRequiredException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.restdocs.payload; 18 | 19 | /** 20 | * A {@code FieldTypeRequiredException} is thrown when a field's type cannot be determined 21 | * automatically and, therefore, must be explicitly provided. 22 | * 23 | * @author Andy Wilkinson 24 | */ 25 | @SuppressWarnings("serial") 26 | public class FieldTypeRequiredException extends RuntimeException { 27 | 28 | /** 29 | * Creates a new {@code FieldTypeRequiredException} indicating that a type is required 30 | * for the reason described in the given {@code message}. 31 | * @param message the message 32 | */ 33 | public FieldTypeRequiredException(String message) { 34 | super(message); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/FieldTypesDoNotMatchException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.restdocs.payload; 18 | 19 | /** 20 | * A {@code FieldTypesDoNotMatchException} is thrown when the documented and actual types 21 | * of a field do not match. 22 | * 23 | * @author Andy Wilkinson 24 | */ 25 | class FieldTypesDoNotMatchException extends RuntimeException { 26 | 27 | /** 28 | * Creates a new {@code FieldTypesDoNotMatchException} for the field described by the 29 | * given {@code fieldDescriptor} that has the given {@code actualType}. 30 | * @param fieldDescriptor the field 31 | * @param actualType the actual type of the field 32 | */ 33 | FieldTypesDoNotMatchException(FieldDescriptor fieldDescriptor, Object actualType) { 34 | super("The documented type of the field '" + fieldDescriptor.getPath() + "' is " + fieldDescriptor.getType() 35 | + " but the actual type is " + actualType); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/JsonFieldType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.restdocs.payload; 18 | 19 | import java.util.Locale; 20 | 21 | import org.springframework.util.StringUtils; 22 | 23 | /** 24 | * An enumeration of the possible types for a field in a JSON request or response payload. 25 | * 26 | * @author Andy Wilkinson 27 | */ 28 | public enum JsonFieldType { 29 | 30 | /** 31 | * An array. 32 | */ 33 | ARRAY, 34 | 35 | /** 36 | * A boolean value. 37 | */ 38 | BOOLEAN, 39 | 40 | /** 41 | * An object (map). 42 | */ 43 | OBJECT, 44 | 45 | /** 46 | * A number. 47 | */ 48 | NUMBER, 49 | 50 | /** 51 | * {@code null}. 52 | */ 53 | NULL, 54 | 55 | /** 56 | * A string. 57 | */ 58 | STRING, 59 | 60 | /** 61 | * A variety of different types. 62 | */ 63 | VARIES; 64 | 65 | @Override 66 | public String toString() { 67 | return StringUtils.capitalize(this.name().toLowerCase(Locale.ENGLISH)); 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/PayloadHandlingException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.restdocs.payload; 18 | 19 | /** 20 | * Thrown to indicate that a failure has occurred during payload handling. 21 | * 22 | * @author Andy Wilkinson 23 | * 24 | */ 25 | @SuppressWarnings("serial") 26 | class PayloadHandlingException extends RuntimeException { 27 | 28 | /** 29 | * Creates a new {@code PayloadHandlingException} with the given {@code message}. 30 | * @param message the message 31 | * @since 1.2.0 32 | */ 33 | PayloadHandlingException(String message) { 34 | super(message); 35 | } 36 | 37 | /** 38 | * Creates a new {@code PayloadHandlingException} with the given {@code cause}. 39 | * @param cause the cause of the failure 40 | */ 41 | PayloadHandlingException(Throwable cause) { 42 | super(cause); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/SubsectionDescriptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.restdocs.payload; 18 | 19 | /** 20 | * A description of a subsection, i.e. a field and all of its descendants, in a request or 21 | * response payload. 22 | * 23 | * @author Andy Wilkinson 24 | * @since 1.2.0 25 | */ 26 | public class SubsectionDescriptor extends FieldDescriptor { 27 | 28 | /** 29 | * Creates a new {@code SubsectionDescriptor} describing the subsection with the given 30 | * {@code path}. 31 | * @param path the path 32 | */ 33 | protected SubsectionDescriptor(String path) { 34 | super(path); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Documenting the payload of a RESTful API's requests and responses. 19 | */ 20 | package org.springframework.restdocs.payload; 21 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/request/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Documenting query and path parameters of requests sent to a RESTful API. 19 | */ 20 | package org.springframework.restdocs.request; 21 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/IgnorableDescriptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.restdocs.snippet; 18 | 19 | /** 20 | * Base class for descriptors for items that can be ignored. 21 | * 22 | * @param the type of the descriptor 23 | * @author Andy Wilkinson 24 | */ 25 | public abstract class IgnorableDescriptor> extends AbstractDescriptor { 26 | 27 | private boolean ignored = false; 28 | 29 | /** 30 | * Marks the described item as being ignored. Ignored items are not included in the 31 | * generated documentation. 32 | * @return the descriptor 33 | */ 34 | @SuppressWarnings("unchecked") 35 | public final T ignored() { 36 | this.ignored = true; 37 | return (T) this; 38 | } 39 | 40 | /** 41 | * Returns whether or not the item being described should be ignored and, therefore, 42 | * should not be included in the documentation. 43 | * @return {@code true} if the item should be ignored, otherwise {@code false}. 44 | */ 45 | public final boolean isIgnored() { 46 | return this.ignored; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/ModelCreationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.restdocs.snippet; 18 | 19 | /** 20 | * An exception that can be thrown by a {@link TemplatedSnippet} to indicate that a 21 | * failure has occurred during model creation. 22 | * 23 | * @author Andy Wilkinson 24 | * @see TemplatedSnippet#createModel(org.springframework.restdocs.operation.Operation) 25 | */ 26 | @SuppressWarnings("serial") 27 | public class ModelCreationException extends RuntimeException { 28 | 29 | /** 30 | * Creates a new {@code ModelCreationException} with the given {@code cause}. 31 | * @param cause the cause 32 | */ 33 | public ModelCreationException(Throwable cause) { 34 | super(cause); 35 | } 36 | 37 | /** 38 | * Creates a new {@code ModelCreationException} with the given {@code message} and 39 | * {@code cause}. 40 | * @param message the message 41 | * @param cause the cause 42 | */ 43 | public ModelCreationException(String message, Throwable cause) { 44 | super(message, cause); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/PlaceholderResolverFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.restdocs.snippet; 18 | 19 | import org.springframework.restdocs.RestDocumentationContext; 20 | import org.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver; 21 | 22 | /** 23 | * A factory for creating {@link PlaceholderResolver} instances. 24 | * 25 | * @author Andy Wilkinson 26 | * @since 1.1.0 27 | */ 28 | public interface PlaceholderResolverFactory { 29 | 30 | /** 31 | * Creates a new {@link PlaceholderResolver} using the given {@code context}. 32 | * @param context the context 33 | * @return the placeholder resolver 34 | */ 35 | PlaceholderResolver create(RestDocumentationContext context); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/RestDocumentationContextPlaceholderResolverFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.restdocs.snippet; 18 | 19 | import org.springframework.restdocs.RestDocumentationContext; 20 | import org.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver; 21 | 22 | /** 23 | * A {@link PlaceholderResolverFactory} that creates 24 | * {@link RestDocumentationContextPlaceholderResolver} instances. 25 | * 26 | * @author Andy Wilkinson 27 | * @since 1.1.0 28 | */ 29 | public final class RestDocumentationContextPlaceholderResolverFactory implements PlaceholderResolverFactory { 30 | 31 | @Override 32 | public PlaceholderResolver create(RestDocumentationContext context) { 33 | return new RestDocumentationContextPlaceholderResolver(context); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/Snippet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.restdocs.snippet; 18 | 19 | import java.io.IOException; 20 | 21 | import org.springframework.restdocs.operation.Operation; 22 | 23 | /** 24 | * A {@link Snippet} is used to document aspects of a call to a RESTful API. 25 | * 26 | * @author Andy Wilkinson 27 | */ 28 | public interface Snippet { 29 | 30 | /** 31 | * Documents the call to the RESTful API described by the given {@code operation}. 32 | * @param operation the API operation 33 | * @throws IOException if a failure occurs will documenting the operation 34 | */ 35 | void document(Operation operation) throws IOException; 36 | 37 | } 38 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/SnippetException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.restdocs.snippet; 18 | 19 | /** 20 | * A {@link RuntimeException} thrown to indicate a problem with the generation of a 21 | * documentation snippet. 22 | * 23 | * @author Andy Wilkinson 24 | */ 25 | @SuppressWarnings("serial") 26 | public class SnippetException extends RuntimeException { 27 | 28 | /** 29 | * Creates a new {@code SnippetException} described by the given {@code message}. 30 | * @param message the message that describes the problem 31 | */ 32 | public SnippetException(String message) { 33 | super(message); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Snippet generation. 19 | */ 20 | package org.springframework.restdocs.snippet; 21 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/Template.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.restdocs.templates; 18 | 19 | import java.util.Map; 20 | 21 | /** 22 | * A compiled {@code Template} that can be rendered to a {@link String}. 23 | * 24 | * @author Andy Wilkinson 25 | * 26 | */ 27 | public interface Template { 28 | 29 | /** 30 | * Renders the template to a {@link String} using the given {@code context} for 31 | * variable/property resolution. 32 | * @param context the context to use 33 | * @return the rendered template 34 | */ 35 | String render(Map context); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/TemplateEngine.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.restdocs.templates; 18 | 19 | import java.io.IOException; 20 | 21 | import org.springframework.restdocs.templates.mustache.MustacheTemplateEngine; 22 | 23 | /** 24 | * A {@code TemplateEngine} is used to render documentation snippets. 25 | * 26 | * @author Andy Wilkinson 27 | * @see MustacheTemplateEngine 28 | */ 29 | public interface TemplateEngine { 30 | 31 | /** 32 | * Compiles the template at the given {@code path}. Typically, a 33 | * {@link TemplateResourceResolver} will be used to resolve the path into a resource 34 | * that can be read and compiled. 35 | * @param path the path of the template 36 | * @return the compiled {@code Template} 37 | * @throws IOException if compilation fails 38 | */ 39 | Template compileTemplate(String path) throws IOException; 40 | 41 | } 42 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/TemplateFormat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.restdocs.templates; 18 | 19 | /** 20 | * A {@link TemplateFormat} provides information about a particular template format, such 21 | * as Asciidoctor or Markdown. 22 | * 23 | * @author Andy Wilkinson 24 | * @since 1.1.0 25 | */ 26 | public interface TemplateFormat { 27 | 28 | /** 29 | * Returns the id of this template format. 30 | * @return the id 31 | */ 32 | String getId(); 33 | 34 | /** 35 | * Returns the file extension to use for files generated from templates in this 36 | * format. 37 | * @return the file extension 38 | */ 39 | String getFileExtension(); 40 | 41 | } 42 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/TemplateResourceResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.restdocs.templates; 18 | 19 | import org.springframework.core.io.Resource; 20 | 21 | /** 22 | * A {@code TemplateResourceResolver} is responsible for resolving a name for a template 23 | * into a {@link Resource} from which the template can be read. 24 | * 25 | * @author Andy Wilkinson 26 | */ 27 | public interface TemplateResourceResolver { 28 | 29 | /** 30 | * Resolves a {@link Resource} for the template with the given {@code name}. 31 | * @param name the name of the template 32 | * @return the {@code Resource} from which the template can be read 33 | */ 34 | Resource resolveTemplateResource(String name); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/mustache/AsciidoctorTableCellContentLambda.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.restdocs.templates.mustache; 18 | 19 | import java.io.IOException; 20 | import java.io.Writer; 21 | 22 | import org.springframework.restdocs.mustache.Mustache.Lambda; 23 | import org.springframework.restdocs.mustache.Template.Fragment; 24 | 25 | /** 26 | * A {@link Lambda} that escapes {@code |} characters so that the do not break the table's 27 | * formatting. 28 | * 29 | * @author Andy Wilkinson 30 | * @since 1.1.0 31 | */ 32 | public final class AsciidoctorTableCellContentLambda implements Lambda { 33 | 34 | @Override 35 | public void execute(Fragment fragment, Writer writer) throws IOException { 36 | String output = fragment.execute(); 37 | for (int i = 0; i < output.length(); i++) { 38 | char current = output.charAt(i); 39 | if (current == '|' && (i == 0 || output.charAt(i - 1) != '\\')) { 40 | writer.append('\\'); 41 | } 42 | writer.append(current); 43 | } 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/mustache/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * JMustache-based implementation of the template API. 19 | */ 20 | package org.springframework.restdocs.templates.mustache; 21 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Template API used to render documentation snippets. 19 | */ 20 | package org.springframework.restdocs.templates; 21 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/resources/org/springframework/restdocs/templates/asciidoctor/default-curl-request.snippet: -------------------------------------------------------------------------------- 1 | [source,bash] 2 | ---- 3 | $ curl {{url}} {{options}} 4 | ---- -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/resources/org/springframework/restdocs/templates/asciidoctor/default-form-parameters.snippet: -------------------------------------------------------------------------------- 1 | |=== 2 | |Parameter|Description 3 | 4 | {{#parameters}} 5 | |{{#tableCellContent}}`+{{name}}+`{{/tableCellContent}} 6 | |{{#tableCellContent}}{{description}}{{/tableCellContent}} 7 | 8 | {{/parameters}} 9 | |=== -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/resources/org/springframework/restdocs/templates/asciidoctor/default-http-request.snippet: -------------------------------------------------------------------------------- 1 | [source,http,options="nowrap"] 2 | ---- 3 | {{method}} {{path}} HTTP/1.1 4 | {{#headers}} 5 | {{name}}: {{value}} 6 | {{/headers}} 7 | {{requestBody}} 8 | ---- -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/resources/org/springframework/restdocs/templates/asciidoctor/default-http-response.snippet: -------------------------------------------------------------------------------- 1 | [source,http,options="nowrap"] 2 | ---- 3 | HTTP/1.1 {{statusCode}} {{statusReason}} 4 | {{#headers}} 5 | {{name}}: {{value}} 6 | {{/headers}} 7 | {{responseBody}} 8 | ---- -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/resources/org/springframework/restdocs/templates/asciidoctor/default-httpie-request.snippet: -------------------------------------------------------------------------------- 1 | [source,bash] 2 | ---- 3 | $ {{echoContent}}http {{options}} {{url}}{{requestItems}} 4 | ---- -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/resources/org/springframework/restdocs/templates/asciidoctor/default-links.snippet: -------------------------------------------------------------------------------- 1 | |=== 2 | |Relation|Description 3 | 4 | {{#links}} 5 | |{{#tableCellContent}}`+{{rel}}+`{{/tableCellContent}} 6 | |{{#tableCellContent}}{{description}}{{/tableCellContent}} 7 | 8 | {{/links}} 9 | |=== -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/resources/org/springframework/restdocs/templates/asciidoctor/default-path-parameters.snippet: -------------------------------------------------------------------------------- 1 | .+{{path}}+ 2 | |=== 3 | |Parameter|Description 4 | 5 | {{#parameters}} 6 | |{{#tableCellContent}}`+{{name}}+`{{/tableCellContent}} 7 | |{{#tableCellContent}}{{description}}{{/tableCellContent}} 8 | 9 | {{/parameters}} 10 | |=== -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/resources/org/springframework/restdocs/templates/asciidoctor/default-query-parameters.snippet: -------------------------------------------------------------------------------- 1 | |=== 2 | |Parameter|Description 3 | 4 | {{#parameters}} 5 | |{{#tableCellContent}}`+{{name}}+`{{/tableCellContent}} 6 | |{{#tableCellContent}}{{description}}{{/tableCellContent}} 7 | 8 | {{/parameters}} 9 | |=== -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/resources/org/springframework/restdocs/templates/asciidoctor/default-request-body.snippet: -------------------------------------------------------------------------------- 1 | [source{{#language}},{{language}}{{/language}},options="nowrap"] 2 | ---- 3 | {{body}} 4 | ---- -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/resources/org/springframework/restdocs/templates/asciidoctor/default-request-cookies.snippet: -------------------------------------------------------------------------------- 1 | |=== 2 | |Name|Description 3 | 4 | {{#cookies}} 5 | |{{#tableCellContent}}`+{{name}}+`{{/tableCellContent}} 6 | |{{#tableCellContent}}{{description}}{{/tableCellContent}} 7 | 8 | {{/cookies}} 9 | |=== -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/resources/org/springframework/restdocs/templates/asciidoctor/default-request-fields.snippet: -------------------------------------------------------------------------------- 1 | |=== 2 | |Path|Type|Description 3 | 4 | {{#fields}} 5 | |{{#tableCellContent}}`+{{path}}+`{{/tableCellContent}} 6 | |{{#tableCellContent}}`+{{type}}+`{{/tableCellContent}} 7 | |{{#tableCellContent}}{{description}}{{/tableCellContent}} 8 | 9 | {{/fields}} 10 | |=== -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/resources/org/springframework/restdocs/templates/asciidoctor/default-request-headers.snippet: -------------------------------------------------------------------------------- 1 | |=== 2 | |Name|Description 3 | 4 | {{#headers}} 5 | |{{#tableCellContent}}`+{{name}}+`{{/tableCellContent}} 6 | |{{#tableCellContent}}{{description}}{{/tableCellContent}} 7 | 8 | {{/headers}} 9 | |=== -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/resources/org/springframework/restdocs/templates/asciidoctor/default-request-parameters.snippet: -------------------------------------------------------------------------------- 1 | |=== 2 | |Parameter|Description 3 | 4 | {{#parameters}} 5 | |{{#tableCellContent}}`+{{name}}+`{{/tableCellContent}} 6 | |{{#tableCellContent}}{{description}}{{/tableCellContent}} 7 | 8 | {{/parameters}} 9 | |=== -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/resources/org/springframework/restdocs/templates/asciidoctor/default-request-part-body.snippet: -------------------------------------------------------------------------------- 1 | [source{{#language}},{{language}}{{/language}},options="nowrap"] 2 | ---- 3 | {{body}} 4 | ---- -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/resources/org/springframework/restdocs/templates/asciidoctor/default-request-part-fields.snippet: -------------------------------------------------------------------------------- 1 | |=== 2 | |Path|Type|Description 3 | 4 | {{#fields}} 5 | |{{#tableCellContent}}`+{{path}}+`{{/tableCellContent}} 6 | |{{#tableCellContent}}`+{{type}}+`{{/tableCellContent}} 7 | |{{#tableCellContent}}{{description}}{{/tableCellContent}} 8 | 9 | {{/fields}} 10 | |=== -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/resources/org/springframework/restdocs/templates/asciidoctor/default-request-parts.snippet: -------------------------------------------------------------------------------- 1 | |=== 2 | |Part|Description 3 | 4 | {{#requestParts}} 5 | |{{#tableCellContent}}`+{{name}}+`{{/tableCellContent}} 6 | |{{#tableCellContent}}{{description}}{{/tableCellContent}} 7 | 8 | {{/requestParts}} 9 | |=== -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/resources/org/springframework/restdocs/templates/asciidoctor/default-response-body.snippet: -------------------------------------------------------------------------------- 1 | [source{{#language}},{{language}}{{/language}},options="nowrap"] 2 | ---- 3 | {{body}} 4 | ---- -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/resources/org/springframework/restdocs/templates/asciidoctor/default-response-cookies.snippet: -------------------------------------------------------------------------------- 1 | |=== 2 | |Name|Description 3 | 4 | {{#cookies}} 5 | |{{#tableCellContent}}`+{{name}}+`{{/tableCellContent}} 6 | |{{#tableCellContent}}{{description}}{{/tableCellContent}} 7 | 8 | {{/cookies}} 9 | |=== -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/resources/org/springframework/restdocs/templates/asciidoctor/default-response-fields.snippet: -------------------------------------------------------------------------------- 1 | |=== 2 | |Path|Type|Description 3 | 4 | {{#fields}} 5 | |{{#tableCellContent}}`+{{path}}+`{{/tableCellContent}} 6 | |{{#tableCellContent}}`+{{type}}+`{{/tableCellContent}} 7 | |{{#tableCellContent}}{{description}}{{/tableCellContent}} 8 | 9 | {{/fields}} 10 | |=== -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/resources/org/springframework/restdocs/templates/asciidoctor/default-response-headers.snippet: -------------------------------------------------------------------------------- 1 | |=== 2 | |Name|Description 3 | 4 | {{#headers}} 5 | |{{#tableCellContent}}`+{{name}}+`{{/tableCellContent}} 6 | |{{#tableCellContent}}{{description}}{{/tableCellContent}} 7 | 8 | {{/headers}} 9 | |=== -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/resources/org/springframework/restdocs/templates/markdown/default-curl-request.snippet: -------------------------------------------------------------------------------- 1 | ```bash 2 | $ curl {{url}} {{options}} 3 | ``` -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/resources/org/springframework/restdocs/templates/markdown/default-form-parameters.snippet: -------------------------------------------------------------------------------- 1 | Parameter | Description 2 | --------- | ----------- 3 | {{#parameters}} 4 | `{{name}}` | {{description}} 5 | {{/parameters}} -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/resources/org/springframework/restdocs/templates/markdown/default-http-request.snippet: -------------------------------------------------------------------------------- 1 | ```http 2 | {{method}} {{path}} HTTP/1.1 3 | {{#headers}} 4 | {{name}}: {{value}} 5 | {{/headers}} 6 | {{requestBody}} 7 | ``` -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/resources/org/springframework/restdocs/templates/markdown/default-http-response.snippet: -------------------------------------------------------------------------------- 1 | ```http 2 | HTTP/1.1 {{statusCode}} {{statusReason}} 3 | {{#headers}} 4 | {{name}}: {{value}} 5 | {{/headers}} 6 | {{responseBody}} 7 | ``` -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/resources/org/springframework/restdocs/templates/markdown/default-httpie-request.snippet: -------------------------------------------------------------------------------- 1 | ```bash 2 | $ {{echoContent}}http {{options}} {{url}}{{requestItems}} 3 | ``` -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/resources/org/springframework/restdocs/templates/markdown/default-links.snippet: -------------------------------------------------------------------------------- 1 | Relation | Description 2 | -------- | ----------- 3 | {{#links}} 4 | `{{rel}}` | {{description}} 5 | {{/links}} -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/resources/org/springframework/restdocs/templates/markdown/default-path-parameters.snippet: -------------------------------------------------------------------------------- 1 | `{{path}}` 2 | 3 | Parameter | Description 4 | --------- | ----------- 5 | {{#parameters}} 6 | `{{name}}` | {{description}} 7 | {{/parameters}} -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/resources/org/springframework/restdocs/templates/markdown/default-query-parameters.snippet: -------------------------------------------------------------------------------- 1 | Parameter | Description 2 | --------- | ----------- 3 | {{#parameters}} 4 | `{{name}}` | {{description}} 5 | {{/parameters}} -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/resources/org/springframework/restdocs/templates/markdown/default-request-body.snippet: -------------------------------------------------------------------------------- 1 | ```{{#language}}{{language}}{{/language}} 2 | {{body}} 3 | ``` -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/resources/org/springframework/restdocs/templates/markdown/default-request-cookies.snippet: -------------------------------------------------------------------------------- 1 | Name | Description 2 | ---- | ----------- 3 | {{#cookies}} 4 | `{{name}}` | {{description}} 5 | {{/cookies}} 6 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/resources/org/springframework/restdocs/templates/markdown/default-request-fields.snippet: -------------------------------------------------------------------------------- 1 | Path | Type | Description 2 | ---- | ---- | ----------- 3 | {{#fields}} 4 | `{{path}}` | `{{type}}` | {{description}} 5 | {{/fields}} -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/resources/org/springframework/restdocs/templates/markdown/default-request-headers.snippet: -------------------------------------------------------------------------------- 1 | Name | Description 2 | ---- | ----------- 3 | {{#headers}} 4 | `{{name}}` | {{description}} 5 | {{/headers}} -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/resources/org/springframework/restdocs/templates/markdown/default-request-parameters.snippet: -------------------------------------------------------------------------------- 1 | Parameter | Description 2 | --------- | ----------- 3 | {{#parameters}} 4 | `{{name}}` | {{description}} 5 | {{/parameters}} -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/resources/org/springframework/restdocs/templates/markdown/default-request-part-body.snippet: -------------------------------------------------------------------------------- 1 | ```{{#language}}{{language}}{{/language}} 2 | {{body}} 3 | ``` -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/resources/org/springframework/restdocs/templates/markdown/default-request-part-fields.snippet: -------------------------------------------------------------------------------- 1 | Path | Type | Description 2 | ---- | ---- | ----------- 3 | {{#fields}} 4 | `{{path}}` | `{{type}}` | {{description}} 5 | {{/fields}} -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/resources/org/springframework/restdocs/templates/markdown/default-request-parts.snippet: -------------------------------------------------------------------------------- 1 | Part | Description 2 | ---- | ----------- 3 | {{#requestParts}} 4 | `{{name}}` | {{description}} 5 | {{/requestParts}} -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/resources/org/springframework/restdocs/templates/markdown/default-response-body.snippet: -------------------------------------------------------------------------------- 1 | ```{{#language}}{{language}}{{/language}} 2 | {{body}} 3 | ``` -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/resources/org/springframework/restdocs/templates/markdown/default-response-cookies.snippet: -------------------------------------------------------------------------------- 1 | Name | Description 2 | ---- | ----------- 3 | {{#cookies}} 4 | `{{name}}` | {{description}} 5 | {{/cookies}} 6 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/resources/org/springframework/restdocs/templates/markdown/default-response-fields.snippet: -------------------------------------------------------------------------------- 1 | Path | Type | Description 2 | ---- | ---- | ----------- 3 | {{#fields}} 4 | `{{path}}` | `{{type}}` | {{description}} 5 | {{/fields}} -------------------------------------------------------------------------------- /spring-restdocs-core/src/main/resources/org/springframework/restdocs/templates/markdown/default-response-headers.snippet: -------------------------------------------------------------------------------- 1 | Name | Description 2 | ---- | ----------- 3 | {{#headers}} 4 | `{{name}}` | {{description}} 5 | {{/headers}} -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/java/org/springframework/restdocs/hypermedia/StubLinkExtractor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.restdocs.hypermedia; 18 | 19 | import java.io.IOException; 20 | 21 | import org.springframework.restdocs.operation.OperationResponse; 22 | import org.springframework.util.LinkedMultiValueMap; 23 | import org.springframework.util.MultiValueMap; 24 | 25 | /** 26 | * Stub implementation of {@code LinkExtractor} for testing. 27 | * 28 | * @author Andy Wilkinson 29 | */ 30 | class StubLinkExtractor implements LinkExtractor { 31 | 32 | private MultiValueMap linksByRel = new LinkedMultiValueMap<>(); 33 | 34 | @Override 35 | public MultiValueMap extractLinks(OperationResponse response) throws IOException { 36 | return this.linksByRel; 37 | } 38 | 39 | StubLinkExtractor withLinks(Link... links) { 40 | for (Link link : links) { 41 | this.linksByRel.add(link.getRel(), link); 42 | } 43 | return this; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/asciidoctor/curl-request-with-title.snippet: -------------------------------------------------------------------------------- 1 | [source,bash] 2 | .{{title}} 3 | ---- 4 | $ curl {{url}} {{options}} 5 | ---- -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/asciidoctor/form-parameters-with-extra-column.snippet: -------------------------------------------------------------------------------- 1 | |=== 2 | |Parameter|Description|Foo 3 | 4 | {{#parameters}} 5 | |{{name}} 6 | |{{description}} 7 | |{{foo}} 8 | 9 | {{/parameters}} 10 | |=== -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/asciidoctor/form-parameters-with-optional-column.snippet: -------------------------------------------------------------------------------- 1 | |=== 2 | |Parameter|Optional|Description 3 | 4 | {{#parameters}} 5 | |{{name}} 6 | |{{optional}} 7 | |{{description}} 8 | 9 | {{/parameters}} 10 | |=== -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/asciidoctor/form-parameters-with-title.snippet: -------------------------------------------------------------------------------- 1 | .{{title}} 2 | |=== 3 | |Parameter|Description 4 | 5 | {{#parameters}} 6 | |{{name}} 7 | |{{description}} 8 | 9 | {{/parameters}} 10 | |=== -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/asciidoctor/http-request-with-title.snippet: -------------------------------------------------------------------------------- 1 | [source,http] 2 | .{{title}} 3 | ---- 4 | {{method}} {{path}} HTTP/1.1 5 | {{#headers}} 6 | {{name}}: {{value}} 7 | {{/headers}} 8 | {{requestBody}} 9 | ---- -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/asciidoctor/http-response-with-title.snippet: -------------------------------------------------------------------------------- 1 | [source,http] 2 | .{{title}} 3 | ---- 4 | HTTP/1.1 {{statusCode}} {{statusReason}} 5 | {{#headers}} 6 | {{name}}: {{value}} 7 | {{/headers}} 8 | {{responseBody}} 9 | ---- -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/asciidoctor/httpie-request-with-title.snippet: -------------------------------------------------------------------------------- 1 | [source,bash] 2 | .{{title}} 3 | ---- 4 | $ {{echoContent}}http {{options}} {{url}}{{requestItems}} 5 | ---- -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/asciidoctor/links-with-extra-column.snippet: -------------------------------------------------------------------------------- 1 | |=== 2 | |Relation|Description|Foo 3 | 4 | {{#links}} 5 | |{{rel}} 6 | |{{description}} 7 | |{{foo}} 8 | 9 | {{/links}} 10 | |=== -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/asciidoctor/links-with-title.snippet: -------------------------------------------------------------------------------- 1 | .{{title}} 2 | |=== 3 | |Relation|Description 4 | 5 | {{#links}} 6 | |{{rel}} 7 | |{{description}} 8 | 9 | {{/links}} 10 | |=== -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/asciidoctor/path-parameters-with-extra-column.snippet: -------------------------------------------------------------------------------- 1 | |=== 2 | |Parameter|Description|Foo 3 | 4 | {{#parameters}} 5 | |{{name}} 6 | |{{description}} 7 | |{{foo}} 8 | 9 | {{/parameters}} 10 | |=== -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/asciidoctor/path-parameters-with-title.snippet: -------------------------------------------------------------------------------- 1 | .{{title}} 2 | |=== 3 | |Parameter|Description 4 | 5 | {{#parameters}} 6 | |{{name}} 7 | |{{description}} 8 | 9 | {{/parameters}} 10 | |=== -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/asciidoctor/query-parameters-with-extra-column.snippet: -------------------------------------------------------------------------------- 1 | |=== 2 | |Parameter|Description|Foo 3 | 4 | {{#parameters}} 5 | |{{name}} 6 | |{{description}} 7 | |{{foo}} 8 | 9 | {{/parameters}} 10 | |=== -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/asciidoctor/query-parameters-with-optional-column.snippet: -------------------------------------------------------------------------------- 1 | |=== 2 | |Parameter|Optional|Description 3 | 4 | {{#parameters}} 5 | |{{name}} 6 | |{{optional}} 7 | |{{description}} 8 | 9 | {{/parameters}} 10 | |=== -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/asciidoctor/query-parameters-with-title.snippet: -------------------------------------------------------------------------------- 1 | .{{title}} 2 | |=== 3 | |Parameter|Description 4 | 5 | {{#parameters}} 6 | |{{name}} 7 | |{{description}} 8 | 9 | {{/parameters}} 10 | |=== -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/asciidoctor/request-body-with-language.snippet: -------------------------------------------------------------------------------- 1 | [source,{{language}},options="nowrap"] 2 | ---- 3 | {{body}} 4 | ---- -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/asciidoctor/request-cookies-with-extra-column.snippet: -------------------------------------------------------------------------------- 1 | |=== 2 | |Name|Description|Foo 3 | 4 | {{#cookies}} 5 | |{{name}} 6 | |{{description}} 7 | |{{foo}} 8 | 9 | {{/cookies}} 10 | |=== -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/asciidoctor/request-cookies-with-title.snippet: -------------------------------------------------------------------------------- 1 | .{{title}} 2 | |=== 3 | |Name|Description 4 | 5 | {{#cookies}} 6 | |{{name}} 7 | |{{description}} 8 | 9 | {{/cookies}} 10 | |=== -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/asciidoctor/request-fields-with-extra-column.snippet: -------------------------------------------------------------------------------- 1 | |=== 2 | |Path|Type|Description|Foo 3 | 4 | {{#fields}} 5 | |{{path}} 6 | |{{type}} 7 | |{{description}} 8 | |{{foo}} 9 | 10 | {{/fields}} 11 | |=== -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/asciidoctor/request-fields-with-list-description.snippet: -------------------------------------------------------------------------------- 1 | [cols="1,1,1a"] 2 | |=== 3 | |Path|Type|Description 4 | 5 | {{#fields}} 6 | |{{path}} 7 | |{{type}} 8 | |{{#description}} - {{.}} 9 | {{/description}} 10 | 11 | {{/fields}} 12 | |=== -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/asciidoctor/request-fields-with-title.snippet: -------------------------------------------------------------------------------- 1 | .{{title}} 2 | |=== 3 | |Path|Type|Description 4 | 5 | {{#fields}} 6 | |{{path}} 7 | |{{type}} 8 | |{{description}} 9 | 10 | {{/fields}} 11 | |=== -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/asciidoctor/request-headers-with-extra-column.snippet: -------------------------------------------------------------------------------- 1 | |=== 2 | |Name|Description|Foo 3 | 4 | {{#headers}} 5 | |{{name}} 6 | |{{description}} 7 | |{{foo}} 8 | 9 | {{/headers}} 10 | |=== -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/asciidoctor/request-headers-with-title.snippet: -------------------------------------------------------------------------------- 1 | .{{title}} 2 | |=== 3 | |Name|Description 4 | 5 | {{#headers}} 6 | |{{name}} 7 | |{{description}} 8 | 9 | {{/headers}} 10 | |=== -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/asciidoctor/request-part-body-with-language.snippet: -------------------------------------------------------------------------------- 1 | [source,{{language}},options="nowrap"] 2 | ---- 3 | {{body}} 4 | ---- -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/asciidoctor/request-parts-with-extra-column.snippet: -------------------------------------------------------------------------------- 1 | |=== 2 | |Part|Description|Foo 3 | 4 | {{#requestParts}} 5 | |{{name}} 6 | |{{description}} 7 | |{{foo}} 8 | 9 | {{/requestParts}} 10 | |=== -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/asciidoctor/request-parts-with-optional-column.snippet: -------------------------------------------------------------------------------- 1 | |=== 2 | |Part|Optional|Description 3 | 4 | {{#requestParts}} 5 | |{{name}} 6 | |{{optional}} 7 | |{{description}} 8 | 9 | {{/requestParts}} 10 | |=== -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/asciidoctor/request-parts-with-title.snippet: -------------------------------------------------------------------------------- 1 | .{{title}} 2 | |=== 3 | |Part|Description 4 | 5 | {{#requestParts}} 6 | |{{name}} 7 | |{{description}} 8 | 9 | {{/requestParts}} 10 | |=== -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/asciidoctor/response-body-with-language.snippet: -------------------------------------------------------------------------------- 1 | [source,{{language}},options="nowrap"] 2 | ---- 3 | {{body}} 4 | ---- -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/asciidoctor/response-cookies-with-extra-column.snippet: -------------------------------------------------------------------------------- 1 | |=== 2 | |Name|Description|Foo 3 | 4 | {{#cookies}} 5 | |{{name}} 6 | |{{description}} 7 | |{{foo}} 8 | 9 | {{/cookies}} 10 | |=== -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/asciidoctor/response-cookies-with-title.snippet: -------------------------------------------------------------------------------- 1 | .{{title}} 2 | |=== 3 | |Name|Description 4 | 5 | {{#cookies}} 6 | |{{name}} 7 | |{{description}} 8 | 9 | {{/cookies}} 10 | |=== -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/asciidoctor/response-fields-with-extra-column.snippet: -------------------------------------------------------------------------------- 1 | |=== 2 | |Path|Type|Description|Foo 3 | 4 | {{#fields}} 5 | |{{path}} 6 | |{{type}} 7 | |{{description}} 8 | |{{foo}} 9 | 10 | {{/fields}} 11 | |=== -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/asciidoctor/response-fields-with-title.snippet: -------------------------------------------------------------------------------- 1 | .{{title}} 2 | |=== 3 | |Path|Type|Description 4 | 5 | {{#fields}} 6 | |{{path}} 7 | |{{type}} 8 | |{{description}} 9 | 10 | {{/fields}} 11 | |=== -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/asciidoctor/response-headers-with-extra-column.snippet: -------------------------------------------------------------------------------- 1 | |=== 2 | |Name|Description|Foo 3 | 4 | {{#headers}} 5 | |{{name}} 6 | |{{description}} 7 | |{{foo}} 8 | 9 | {{/headers}} 10 | |=== -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/asciidoctor/response-headers-with-title.snippet: -------------------------------------------------------------------------------- 1 | .{{title}} 2 | |=== 3 | |Name|Description 4 | 5 | {{#headers}} 6 | |{{name}} 7 | |{{description}} 8 | 9 | {{/headers}} 10 | |=== -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/markdown/curl-request-with-title.snippet: -------------------------------------------------------------------------------- 1 | {{title}} 2 | ```bash 3 | $ curl {{url}} {{options}} 4 | ``` -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/markdown/form-parameters-with-extra-column.snippet: -------------------------------------------------------------------------------- 1 | Parameter | Description | Foo 2 | --------- | ----------- | --- 3 | {{#parameters}} 4 | {{name}} | {{description}} | {{foo}} 5 | {{/parameters}} -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/markdown/form-parameters-with-optional-column.snippet: -------------------------------------------------------------------------------- 1 | Parameter | Optional | Description 2 | --------- | -------- | ----------- 3 | {{#parameters}} 4 | {{name}} | {{optional}} | {{description}} 5 | {{/parameters}} -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/markdown/form-parameters-with-title.snippet: -------------------------------------------------------------------------------- 1 | {{title}} 2 | Parameter | Description 3 | --------- | ----------- 4 | {{#parameters}} 5 | {{name}} | {{description}} 6 | {{/parameters}} -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/markdown/http-request-with-title.snippet: -------------------------------------------------------------------------------- 1 | {{title}} 2 | ```http 3 | {{method}} {{path}} HTTP/1.1 4 | {{#headers}} 5 | {{name}}: {{value}} 6 | {{/headers}} 7 | {{requestBody}} 8 | ``` -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/markdown/http-response-with-title.snippet: -------------------------------------------------------------------------------- 1 | {{title}} 2 | ```http 3 | HTTP/1.1 {{statusCode}} {{statusReason}} 4 | {{#headers}} 5 | {{name}}: {{value}} 6 | {{/headers}} 7 | {{responseBody}} 8 | ``` -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/markdown/httpie-request-with-title.snippet: -------------------------------------------------------------------------------- 1 | {{title}} 2 | ```bash 3 | $ {{echoContent}}http {{options}} {{url}}{{requestItems}} 4 | ``` -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/markdown/links-with-extra-column.snippet: -------------------------------------------------------------------------------- 1 | Relation | Description | Foo 2 | -------- | ----------- | --- 3 | {{#links}} 4 | {{rel}} | {{description}} | {{foo}} 5 | {{/links}} -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/markdown/links-with-title.snippet: -------------------------------------------------------------------------------- 1 | {{title}} 2 | Relation | Description 3 | -------- | ----------- 4 | {{#links}} 5 | {{rel}} | {{description}} 6 | {{/links}} -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/markdown/path-parameters-with-extra-column.snippet: -------------------------------------------------------------------------------- 1 | Parameter | Description | Foo 2 | --------- | ----------- | --- 3 | {{#parameters}} 4 | {{name}} | {{description}} | {{foo}} 5 | {{/parameters}} -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/markdown/path-parameters-with-title.snippet: -------------------------------------------------------------------------------- 1 | {{title}} 2 | Parameter | Description 3 | --------- | ----------- 4 | {{#parameters}} 5 | {{name}} | {{description}} 6 | {{/parameters}} -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/markdown/query-parameters-with-extra-column.snippet: -------------------------------------------------------------------------------- 1 | Parameter | Description | Foo 2 | --------- | ----------- | --- 3 | {{#parameters}} 4 | {{name}} | {{description}} | {{foo}} 5 | {{/parameters}} -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/markdown/query-parameters-with-optional-column.snippet: -------------------------------------------------------------------------------- 1 | Parameter | Optional | Description 2 | --------- | -------- | ----------- 3 | {{#parameters}} 4 | {{name}} | {{optional}} | {{description}} 5 | {{/parameters}} -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/markdown/query-parameters-with-title.snippet: -------------------------------------------------------------------------------- 1 | {{title}} 2 | Parameter | Description 3 | --------- | ----------- 4 | {{#parameters}} 5 | {{name}} | {{description}} 6 | {{/parameters}} -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/markdown/request-body-with-language.snippet: -------------------------------------------------------------------------------- 1 | ```{{language}} 2 | {{body}} 3 | ``` -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/markdown/request-cookies-with-extra-column.snippet: -------------------------------------------------------------------------------- 1 | Name | Description | Foo 2 | ---- | ----------- | --- 3 | {{#cookies}} 4 | {{name}} | {{description}} | {{foo}} 5 | {{/cookies}} -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/markdown/request-cookies-with-title.snippet: -------------------------------------------------------------------------------- 1 | {{title}} 2 | Name | Description 3 | ---- | ----------- 4 | {{#cookies}} 5 | {{name}} | {{description}} 6 | {{/cookies}} -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/markdown/request-fields-with-extra-column.snippet: -------------------------------------------------------------------------------- 1 | Path | Type | Description | Foo 2 | ---- | ---- | ----------- | --- 3 | {{#fields}} 4 | {{path}} | {{type}} | {{description}} | {{foo}} 5 | {{/fields}} -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/markdown/request-fields-with-title.snippet: -------------------------------------------------------------------------------- 1 | {{title}} 2 | Path | Type | Description 3 | ---- | ---- | ----------- 4 | {{#fields}} 5 | {{path}} | {{type}} | {{description}} 6 | {{/fields}} -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/markdown/request-headers-with-extra-column.snippet: -------------------------------------------------------------------------------- 1 | Name | Description | Foo 2 | ---- | ----------- | --- 3 | {{#headers}} 4 | {{name}} | {{description}} | {{foo}} 5 | {{/headers}} -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/markdown/request-headers-with-title.snippet: -------------------------------------------------------------------------------- 1 | {{title}} 2 | Name | Description 3 | ---- | ----------- 4 | {{#headers}} 5 | {{name}} | {{description}} 6 | {{/headers}} -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/markdown/request-part-body-with-language.snippet: -------------------------------------------------------------------------------- 1 | ```{{language}} 2 | {{body}} 3 | ``` -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/markdown/request-parts-with-extra-column.snippet: -------------------------------------------------------------------------------- 1 | Part | Description | Foo 2 | ---- | ----------- | --- 3 | {{#requestParts}} 4 | {{name}} | {{description}} | {{foo}} 5 | {{/requestParts}} -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/markdown/request-parts-with-optional-column.snippet: -------------------------------------------------------------------------------- 1 | Part | Optional | Description 2 | ---- | -------- | ----------- 3 | {{#requestParts}} 4 | {{name}} | {{optional}} | {{description}} 5 | {{/requestParts}} -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/markdown/request-parts-with-title.snippet: -------------------------------------------------------------------------------- 1 | {{title}} 2 | Part | Description 3 | ---- | ----------- 4 | {{#requestParts}} 5 | {{name}} | {{description}} 6 | {{/requestParts}} -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/markdown/response-body-with-language.snippet: -------------------------------------------------------------------------------- 1 | ```{{language}} 2 | {{body}} 3 | ``` -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/markdown/response-cookies-with-extra-column.snippet: -------------------------------------------------------------------------------- 1 | Name | Description | Foo 2 | ---- | ----------- | --- 3 | {{#cookies}} 4 | {{name}} | {{description}} | {{foo}} 5 | {{/cookies}} -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/markdown/response-cookies-with-title.snippet: -------------------------------------------------------------------------------- 1 | {{title}} 2 | Name | Description 3 | ---- | ----------- 4 | {{#cookies}} 5 | {{name}} | {{description}} 6 | {{/cookies}} -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/markdown/response-fields-with-extra-column.snippet: -------------------------------------------------------------------------------- 1 | Path | Type | Description | Foo 2 | ---- | ---- | ----------- | --- 3 | {{#fields}} 4 | {{path}} | {{type}} | {{description}} | {{foo}} 5 | {{/fields}} -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/markdown/response-fields-with-title.snippet: -------------------------------------------------------------------------------- 1 | {{title}} 2 | Path | Type | Description 3 | ---- | ---- | ----------- 4 | {{#fields}} 5 | {{path}} | {{type}} | {{description}} 6 | {{/fields}} -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/markdown/response-headers-with-extra-column.snippet: -------------------------------------------------------------------------------- 1 | Name | Description | Foo 2 | ---- | ----------- | --- 3 | {{#headers}} 4 | {{name}} | {{description}} | {{foo}} 5 | {{/headers}} -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/custom-snippet-templates/markdown/response-headers-with-title.snippet: -------------------------------------------------------------------------------- 1 | {{title}} 2 | Name | Description 3 | ---- | ----------- 4 | {{#headers}} 5 | {{name}} | {{description}} 6 | {{/headers}} -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/field-payloads/multiple-fields-and-embedded-and-links.json: -------------------------------------------------------------------------------- 1 | { 2 | "_links": { 3 | "alpha": "https://alpha.example.com", 4 | "bravo": "https://bravo.example.com" 5 | }, 6 | "_embedded": "embedded-test", 7 | "beta": "beta-value", 8 | "charlie": "charlie-value" 9 | } -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/field-payloads/multiple-fields-and-embedded.json: -------------------------------------------------------------------------------- 1 | { 2 | "_embedded": "embedded-test", 3 | "beta": "beta-value", 4 | "charlie": "charlie-value" 5 | } -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/field-payloads/multiple-fields-and-links.json: -------------------------------------------------------------------------------- 1 | { 2 | "_links": { 3 | "alpha": "https://alpha.example.com", 4 | "bravo": "https://bravo.example.com" 5 | }, 6 | "beta": "beta-value", 7 | "charlie": "charlie-value" 8 | } -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/field-payloads/multiple-fields.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": "alpha-value", 3 | "bravo": 123, 4 | "charlie": { 5 | "one": 456, 6 | "two": "two-value" 7 | }, 8 | "delta": [ 9 | "delta-value-1", 10 | "delta-value-2" 11 | ], 12 | "echo": [{ 13 | "one": 789, 14 | "two": "two-value" 15 | },{ 16 | "one": 987, 17 | "two": "value-two" 18 | }] 19 | } -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/field-payloads/no-fields.json: -------------------------------------------------------------------------------- 1 | { } -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/field-payloads/single-field.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": "alpha-value" 3 | } -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/link-payloads/atom/multiple-links-different-rels.json: -------------------------------------------------------------------------------- 1 | { 2 | "links": [ { 3 | "rel": "alpha", 4 | "href": "https://alpha.example.com", 5 | "title": "Alpha" 6 | }, { 7 | "rel": "bravo", 8 | "href": "https://bravo.example.com" 9 | } ] 10 | } -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/link-payloads/atom/multiple-links-same-rels.json: -------------------------------------------------------------------------------- 1 | { 2 | "links": [ { 3 | "rel": "alpha", 4 | "href": "https://alpha.example.com/one", 5 | "title": "Alpha one" 6 | }, { 7 | "rel": "alpha", 8 | "href": "https://alpha.example.com/two" 9 | } ] 10 | } -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/link-payloads/atom/no-links.json: -------------------------------------------------------------------------------- 1 | { } -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/link-payloads/atom/single-link.json: -------------------------------------------------------------------------------- 1 | { 2 | "links": [ { 3 | "rel": "alpha", 4 | "href": "https://alpha.example.com", 5 | "title": "Alpha" 6 | } ] 7 | } -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/link-payloads/atom/wrong-format.json: -------------------------------------------------------------------------------- 1 | { 2 | "links": { 3 | "alpha": [{ 4 | "href": "https://alpha.example.com/one" 5 | }, { 6 | "href": "https://alpha.example.com/two" 7 | }] 8 | } 9 | } -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/link-payloads/hal/multiple-links-different-rels.json: -------------------------------------------------------------------------------- 1 | { 2 | "_links": { 3 | "alpha": { 4 | "href": "https://alpha.example.com", 5 | "title": "Alpha" 6 | }, 7 | "bravo": { 8 | "href": "https://bravo.example.com" 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/link-payloads/hal/multiple-links-same-rels.json: -------------------------------------------------------------------------------- 1 | { 2 | "_links": { 3 | "alpha": [{ 4 | "href": "https://alpha.example.com/one", 5 | "title": "Alpha one" 6 | }, { 7 | "href": "https://alpha.example.com/two" 8 | }] 9 | } 10 | } -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/link-payloads/hal/no-links.json: -------------------------------------------------------------------------------- 1 | { } -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/link-payloads/hal/single-link.json: -------------------------------------------------------------------------------- 1 | { 2 | "_links": { 3 | "alpha": { 4 | "href": "https://alpha.example.com", 5 | "title": "Alpha" 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/link-payloads/hal/wrong-format.json: -------------------------------------------------------------------------------- 1 | { 2 | "_links": [ { 3 | "rel": "alpha", 4 | "href": "https://alpha.example.com/one" 5 | }, { 6 | "rel": "alpha", 7 | "href": "https://alpha.example.com/two" 8 | } ] 9 | } -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/org/springframework/restdocs/constraints/TestConstraintDescriptions.properties: -------------------------------------------------------------------------------- 1 | jakarta.validation.constraints.NotNull.description=Should not be null -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/org/springframework/restdocs/templates/multiple-snippets.snippet: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spring-projects/spring-restdocs/1d34bcb53c770d523deddfa9588c74759db4fbb5/spring-restdocs-core/src/test/resources/org/springframework/restdocs/templates/multiple-snippets.snippet -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/org/springframework/restdocs/templates/test-custom.snippet: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spring-projects/spring-restdocs/1d34bcb53c770d523deddfa9588c74759db4fbb5/spring-restdocs-core/src/test/resources/org/springframework/restdocs/templates/test-custom.snippet -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/org/springframework/restdocs/templates/test-default.snippet: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spring-projects/spring-restdocs/1d34bcb53c770d523deddfa9588c74759db4fbb5/spring-restdocs-core/src/test/resources/org/springframework/restdocs/templates/test-default.snippet -------------------------------------------------------------------------------- /spring-restdocs-core/src/test/resources/org/springframework/restdocs/templates/test-format-specific-custom.snippet: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spring-projects/spring-restdocs/1d34bcb53c770d523deddfa9588c74759db4fbb5/spring-restdocs-core/src/test/resources/org/springframework/restdocs/templates/test-format-specific-custom.snippet -------------------------------------------------------------------------------- /spring-restdocs-mockmvc/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "io.spring.compatibility-test" version "0.0.3" 3 | id "java-library" 4 | id "maven-publish" 5 | id "optional-dependencies" 6 | } 7 | 8 | description = "Spring REST Docs MockMvc" 9 | 10 | dependencies { 11 | api(project(":spring-restdocs-core")) 12 | api("org.springframework:spring-webmvc") 13 | api("org.springframework:spring-test") 14 | 15 | implementation("jakarta.servlet:jakarta.servlet-api") 16 | 17 | internal(platform(project(":spring-restdocs-platform"))) 18 | 19 | testImplementation(testFixtures(project(":spring-restdocs-core"))) 20 | testImplementation("junit:junit") 21 | testImplementation("org.assertj:assertj-core") 22 | testImplementation("org.hamcrest:hamcrest-library") 23 | testImplementation("org.mockito:mockito-core") 24 | } 25 | -------------------------------------------------------------------------------- /spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Core classes for using Spring REST Docs with Spring Test's MockMvc. 19 | */ 20 | package org.springframework.restdocs.mockmvc; 21 | -------------------------------------------------------------------------------- /spring-restdocs-mockmvc/src/test/resources/custom-snippet-templates/org/springframework/restdocs/templates/curl-request.snippet: -------------------------------------------------------------------------------- 1 | Custom curl request -------------------------------------------------------------------------------- /spring-restdocs-mockmvc/src/test/resources/org/springframework/restdocs/templates/request-parts.snippet: -------------------------------------------------------------------------------- 1 | |=== 2 | |Request part|Description 3 | 4 | {{#requestParts}} 5 | |`{{name}}` 6 | |{{description}} 7 | 8 | {{/requestParts}} 9 | |=== -------------------------------------------------------------------------------- /spring-restdocs-platform/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java-platform' 3 | } 4 | 5 | javaPlatform { 6 | allowDependencies() 7 | } 8 | 9 | dependencies { 10 | constraints { 11 | api("com.samskivert:jmustache:$jmustacheVersion") 12 | api("jakarta.servlet:jakarta.servlet-api:6.1.0") 13 | api("jakarta.validation:jakarta.validation-api:3.1.0") 14 | api("junit:junit:4.13.1") 15 | api("org.apache.pdfbox:pdfbox:2.0.27") 16 | api("org.apache.tomcat.embed:tomcat-embed-core:11.0.2") 17 | api("org.apache.tomcat.embed:tomcat-embed-el:11.0.2") 18 | api("org.asciidoctor:asciidoctorj:3.0.0") 19 | api("org.asciidoctor:asciidoctorj-pdf:2.3.19") 20 | api("org.assertj:assertj-core:3.23.1") 21 | api("org.hamcrest:hamcrest-core:1.3") 22 | api("org.hamcrest:hamcrest-library:1.3") 23 | api("org.hibernate.validator:hibernate-validator:9.0.0.CR1") 24 | api("org.javamoney:moneta:1.4.2") 25 | api("org.junit.jupiter:junit-jupiter-api:5.0.0") 26 | } 27 | api(enforcedPlatform("com.fasterxml.jackson:jackson-bom:2.14.0")) 28 | api(enforcedPlatform("io.rest-assured:rest-assured-bom:5.2.1")) 29 | api(enforcedPlatform("org.mockito:mockito-bom:4.9.0")) 30 | api(enforcedPlatform("org.springframework:spring-framework-bom:$springFrameworkVersion")) 31 | } 32 | -------------------------------------------------------------------------------- /spring-restdocs-restassured/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "io.spring.compatibility-test" version "0.0.3" 3 | id "java-library" 4 | id "maven-publish" 5 | } 6 | 7 | description = "Spring REST Docs REST Assured" 8 | 9 | dependencies { 10 | api(project(":spring-restdocs-core")) 11 | api("io.rest-assured:rest-assured") 12 | implementation("org.springframework:spring-web") 13 | 14 | internal(platform(project(":spring-restdocs-platform"))) 15 | 16 | testImplementation(testFixtures(project(":spring-restdocs-core"))) 17 | testImplementation("com.fasterxml.jackson.core:jackson-databind") 18 | testImplementation("junit:junit") 19 | testImplementation("org.apache.tomcat.embed:tomcat-embed-core") 20 | testImplementation("org.assertj:assertj-core") 21 | testImplementation("org.hamcrest:hamcrest-library") 22 | testImplementation("org.mockito:mockito-core") 23 | } 24 | 25 | compatibilityTest { 26 | dependency("REST Assured") { restAssured -> 27 | restAssured.groupId = "io.rest-assured" 28 | restAssured.versions = ["5.3.+", "5.4.+", "5.5.+"] 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Core classes for using Spring REST Docs with REST Assured. 19 | */ 20 | package org.springframework.restdocs.restassured; 21 | -------------------------------------------------------------------------------- /spring-restdocs-restassured/src/test/resources/body.txt: -------------------------------------------------------------------------------- 1 | file -------------------------------------------------------------------------------- /spring-restdocs-restassured/src/test/resources/custom-snippet-templates/org/springframework/restdocs/templates/curl-request.snippet: -------------------------------------------------------------------------------- 1 | Custom curl request -------------------------------------------------------------------------------- /spring-restdocs-webtestclient/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "io.spring.compatibility-test" version "0.0.3" 3 | id "java-library" 4 | id "maven-publish" 5 | } 6 | 7 | description = "Spring REST Docs WebFlux" 8 | 9 | dependencies { 10 | api(project(":spring-restdocs-core")) 11 | api("org.springframework:spring-test") 12 | api("org.springframework:spring-webflux") 13 | 14 | internal(platform(project(":spring-restdocs-platform"))) 15 | 16 | testImplementation(testFixtures(project(":spring-restdocs-core"))) 17 | testImplementation("junit:junit") 18 | testImplementation("org.assertj:assertj-core") 19 | testImplementation("org.hamcrest:hamcrest-library") 20 | testImplementation("org.mockito:mockito-core") 21 | 22 | testRuntimeOnly("org.springframework:spring-context") 23 | } 24 | -------------------------------------------------------------------------------- /spring-restdocs-webtestclient/src/main/java/org/springframework/restdocs/webtestclient/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Core classes for using Spring REST Docs with Spring Framework's WebTestClient. 19 | */ 20 | package org.springframework.restdocs.webtestclient; 21 | --------------------------------------------------------------------------------