Spring
Why Spring
Overview Microservices Reactive Event Driven Cloud Web Applications Serverless Batch
Learn
Overview Quickstart Guides Blog
Projects
Overview Spring Boot Spring Framework Spring Cloud Spring Cloud Data Flow Spring Data Spring Integration Spring Batch Spring Security View all projects
  • DEVELOPMENT TOOLS
  • Spring Tools 4 Spring Initializr
    Academy
    Courses Get Certified
    Solutions
    Overview Spring Runtime Spring Consulting Spring Academy For Teams Security Advisories
    Community
    Overview Events Team
    spring-cloud-contract 4.2.1
      • Spring Cloud Contract Reference Documentation
      • Legal
      • Getting Started
        • Introducing Spring Cloud Contract
        • A Three-second Tour
        • Developing Your First Spring Cloud Contract-based Application
        • Step-by-step Guide to Consumer Driven Contracts (CDC) with Contracts on the Producer Side
        • Next Steps
      • Using Spring Cloud Contract
        • Provider Contract Testing with Stubs in Nexus or Artifactory
        • Provider Contract Testing with Stubs in Git
        • Consumer Driven Contracts with Contracts on the Producer Side
        • Consumer Driven Contracts with Contracts in an External Repository
        • Consumer-driven Contracts with Contracts on the Producer Side, Pushed to Git
        • Provider Contract Testing with Stubs in Artifactory for a non-Spring Application
        • Provider Contract Testing with Stubs in Artifactory in a Non-JVM World
        • Provider Contract Testing with REST Docs and Stubs in Nexus or Artifactory
      • Spring Cloud Contract Features
        • Contract DSL
          • Common Top-Level Elements
          • Dynamic properties
        • Spring Cloud Contract Integrations
          • JAX-RS
          • WebFlux with WebTestClient
          • WebFlux with Explicit Mode
          • Custom Mode
          • Working with Context Paths
          • Working with REST Docs
          • GraphQL
          • GRPC
        • Messaging
        • Spring Cloud Contract Stub Runner
          • Snapshot Versions
          • Publishing Stubs as JARs
          • Stub Runner Core
          • Stub Runner JUnit Rule and Stub Runner JUnit5 Extension
          • Stub Runner Spring Cloud
          • Using the Stub Runner Boot Application
          • Consumer-Driven Contracts: Stubs Per Consumer
          • Fetching Stubs or Contract Definitions From A Location
          • Generating Stubs at Runtime
          • Fail On No Stubs
          • Common Properties
        • Spring Cloud Contract WireMock
      • Build Tools
        • Docker Project
        • Gradle Project
        • Maven Project
      • “How-to” Guides
        • Why use Spring Cloud Contract?
        • How Can I Write Contracts in a Language Other than Groovy?
        • How Can I Provide Dynamic Values to a Contract?
        • How to Do Stubs versioning?
        • How Can I use a Common Repository with Contracts Instead of Storing Them with the Producer?
        • How Can I Use Git as the Storage for Contracts and Stubs?
        • How Can I Debug the Request/Response Being Sent by the Generated Tests Client?
        • How Can I Debug the Mapping, Request, or Response Being Sent by WireMock?
        • How Can I See What Got Registered in the HTTP Server Stub?
        • How Can I Reference Text from File?
        • How Can I Generate YAML, or X files from Spring Cloud Contract Contracts?
        • How Can I Work with Transitive Dependencies?
        • How Can I Generate Spring REST Docs Snippets from the Contracts?
        • How Can I Use Stubs from a Location
        • How Can I Generate Stubs at Runtime
        • How Can I Make The Build Pass if There Are No Contracts or Stubs
        • How Can I Mark that a Contract Is in Progress
      • Spring Cloud Contract customization
        • DSL Customization
        • WireMock Customization
        • Using the Pluggable Architecture
      • Common application properties
        • How to Build Spring Cloud Contract
        • Configuration Properties
        • YML Schema
    Edit this Page GitHub Project Stack Overflow
    • spring-cloud-contract
    • “How-to” Guides
    • How Can I Reference Text from File?

    How Can I Reference Text from File?

    In version 1.2.0, we added this ability. You can call a file(…​) method in the DSL and provide a path relative to where the contract lies. If you use YAML, you can use the bodyFromFile property.

    How Can I See What Got Registered in the HTTP Server Stub? How Can I Generate YAML, or X files from Spring Cloud Contract Contracts?
    • spring-cloud-contract
      • 4.3.0-SNAPSHOT
      • 4.3.0-RC1
      • 4.2.1current
      • 4.1.6-SNAPSHOT
      • 4.1.5
    • Related Spring Documentation
      • Spring Boot
      • Spring Framework
      • Spring Cloud
        • Spring Cloud Build
        • Spring Cloud Bus
        • Spring Cloud Circuit Breaker
        • Spring Cloud Commons
        • Spring Cloud Config
        • Spring Cloud Consul
        • Spring Cloud Contract
        • Spring Cloud Function
        • Spring Cloud Gateway
        • Spring Cloud Kubernetes
        • Spring Cloud Netflix
        • Spring Cloud OpenFeign
        • Spring Cloud Stream
        • Spring Cloud Task
        • Spring Cloud Vault
        • Spring Cloud Zookeeper
      • Spring Data
        • Spring Data Cassandra
        • Spring Data Commons
        • Spring Data Couchbase
        • Spring Data Elasticsearch
        • Spring Data JPA
        • Spring Data KeyValue
        • Spring Data LDAP
        • Spring Data MongoDB
        • Spring Data Neo4j
        • Spring Data Redis
        • Spring Data JDBC & R2DBC
        • Spring Data REST
      • Spring Integration
      • Spring Batch
      • Spring Security
        • Spring Authorization Server
        • Spring LDAP
        • Spring Security Kerberos
        • Spring Session
        • Spring Vault
      • Spring AI
      • Spring AMQP
      • Spring CLI
      • Spring GraphQL
      • Spring for Apache Kafka
      • Spring Modulith
      • Spring for Apache Pulsar
      • Spring Shell
    • All Docs...
    Spring

    Copyright © 2005 - Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
    Terms of Use • Privacy • Trademark Guidelines • Thank you • Your California Privacy Rights • Cookie Settings

    Apache®, Apache Tomcat®, Apache Kafka®, Apache Cassandra™, and Apache Geode™ are trademarks or registered trademarks of the Apache Software Foundation in the United States and/or other countries. Java™, Java™ SE, Java™ EE, and OpenJDK™ are trademarks of Oracle and/or its affiliates. Kubernetes® is a registered trademark of the Linux Foundation in the United States and other countries. Linux® is the registered trademark of Linus Torvalds in the United States and other countries. Windows® and Microsoft® Azure are registered trademarks of Microsoft Corporation. “AWS” and “Amazon Web Services” are trademarks or registered trademarks of Amazon.com Inc. or its affiliates. All other trademarks and copyrights are property of their respective owners and are only mentioned for informative purposes. Other names may be trademarks of their respective owners.

    Search in all Spring Docs