1

I've created a contract on a provider side:

Contract.make { 
    request {
        method 'GET'
        url('/cars/car?id=3')
        headers {
            header(accept(), "application/hal+json")
            header(SOME OTHER HEADER)
        }
    }
    response {
        ...
    }
}

Unfortunately one of my customers do not send request with "header(SOME OTHER HEADER)". My question is how can I mark "header(SOME OTHER HEADER)" as optional?

jb27
  • 93
  • 1
  • 1
  • 7

2 Answers2

0

You can have the value optional. Not the header itself. If the header is optional then create two separate contracts. One with the header and one without it.

Marcin Grzejszczak
  • 10,624
  • 1
  • 16
  • 32
0

I'm experiencing the same issue here. I need to include Access-Control-Allow-Origin header to the generated stub but if I add it to the contract the tests begins to fail becouse of:

Expecting:
 <null>
to be equal to:
 <"\"Access-Control-Allow-Origin\": \"*\"">

even if I annotate the RestController class with @CrossOrigin(value = "*")

PRF
  • 821
  • 1
  • 9
  • 16