@@ -237,6 +237,19 @@ public void headerParamsParseIntoIndexToName() throws Exception {
237237
238238 assertThat (md .indexToName ())
239239 .containsExactly (entry (0 , asList ("authToken" )));
240+ assertThat (md .formParams ()).isEmpty ();
241+ }
242+
243+ @ Test
244+ public void headerParamsParseIntoIndexToNameNotAtStart () throws Exception {
245+ MethodMetadata md = parseAndValidateMetadata (HeaderParamsNotAtStart .class , "logout" , String .class );
246+
247+ assertThat (md .template ())
248+ .hasHeaders (entry ("Authorization" , asList ("Bearer {authToken}" , "Foo" )));
249+
250+ assertThat (md .indexToName ())
251+ .containsExactly (entry (0 , asList ("authToken" )));
252+ assertThat (md .formParams ()).isEmpty ();
240253 }
241254
242255 @ Test
@@ -358,6 +371,13 @@ interface HeaderParams {
358371 void logout (@ Param ("authToken" ) String token );
359372 }
360373
374+ interface HeaderParamsNotAtStart {
375+
376+ @ RequestLine ("POST /" )
377+ @ Headers ({"Authorization: Bearer {authToken}" , "Authorization: Foo" })
378+ void logout (@ Param ("authToken" ) String token );
379+ }
380+
361381 interface CustomExpander {
362382
363383 @ RequestLine ("POST /?date={date}" )
@@ -528,6 +548,34 @@ public void parameterizedHeaderExpandApi() throws Exception {
528548 .isEmpty ();
529549 }
530550
551+ @ Test
552+ public void parameterizedHeaderNotStartingWithCurlyBraceExpandApi () throws Exception {
553+ List <MethodMetadata >
554+ md =
555+ contract .parseAndValidatateMetadata (
556+ ParameterizedHeaderNotStartingWithCurlyBraceExpandApi .class );
557+
558+ assertThat (md ).hasSize (1 );
559+
560+ assertThat (md .get (0 ).configKey ())
561+ .isEqualTo ("ParameterizedHeaderNotStartingWithCurlyBraceExpandApi#getZone(String,String)" );
562+ assertThat (md .get (0 ).returnType ())
563+ .isEqualTo (String .class );
564+ assertThat (md .get (0 ).template ())
565+ .hasHeaders (entry ("Authorization" , asList ("Bearer {authHdr}" )),
566+ entry ("Accept" , asList ("application/json" )));
567+ // Ensure that the authHdr expansion was properly detected and did not create a formParam
568+ assertThat (md .get (0 ).formParams ())
569+ .isEmpty ();
570+ }
571+
572+ @ Headers ("Authorization: Bearer {authHdr}" )
573+ interface ParameterizedHeaderNotStartingWithCurlyBraceExpandApi {
574+ @ RequestLine ("GET /api/{zoneId}" )
575+ @ Headers ("Accept: application/json" )
576+ String getZone (@ Param ("zoneId" ) String vhost , @ Param ("authHdr" ) String authHdr );
577+ }
578+
531579 @ Headers ("Authorization: {authHdr}" )
532580 interface ParameterizedHeaderBase {
533581 }
0 commit comments