diff --git a/spring-cloud-contract-spec/src/main/groovy/org/springframework/cloud/contract/spec/internal/FromFileProperty.groovy b/spring-cloud-contract-spec/src/main/groovy/org/springframework/cloud/contract/spec/internal/FromFileProperty.groovy index b3416238cc..593dd19f1a 100644 --- a/spring-cloud-contract-spec/src/main/groovy/org/springframework/cloud/contract/spec/internal/FromFileProperty.groovy +++ b/spring-cloud-contract-spec/src/main/groovy/org/springframework/cloud/contract/spec/internal/FromFileProperty.groovy @@ -66,4 +66,14 @@ class FromFileProperty implements Serializable { return this.file.bytes } + public T asType(T type) { + switch (type) { + case String: + return (T) asString() + case byte[]: + return (T) asBytes() + } + throw new UnsupportedOperationException("Can't cast to type [${type}]") + } + }