@@ -491,6 +491,59 @@ public void testSecurityDefinitionWithMissingAttribute() {
491
491
assertTrue (messages .contains ("attribute components.securitySchemes.api_key.type is missing" ));
492
492
}
493
493
494
+ @ Test
495
+ public void testSecurityDefinitionApiKeyWithMissingAttributeIn () {
496
+ String yaml = "openapi: 3.0.0\n " +
497
+ "components:\n " +
498
+ " securitySchemes:\n " +
499
+ " api_key:\n " +
500
+ " type: apiKey\n " +
501
+ " name: X-API-KEY" ;
502
+
503
+ OpenAPIV3Parser parser = new OpenAPIV3Parser ();
504
+ SwaggerParseResult result = parser .readContents (yaml , null , null );
505
+ List <String > messageList = result .getMessages ();
506
+ Set <String > messages = new HashSet <>(messageList );
507
+
508
+ assertTrue (messages .contains ("attribute components.securitySchemes.api_key.in is missing" ));
509
+ }
510
+
511
+ @ Test
512
+ public void testSecurityDefinitionApiKeyWithInvalidAttributeIn () {
513
+ String yaml = "openapi: 3.0.0\n " +
514
+ "components:\n " +
515
+ " securitySchemes:\n " +
516
+ " api_key:\n " +
517
+ " type: apiKey\n " +
518
+ " name: X-API-KEY\n " +
519
+ " in: cukie" ;
520
+
521
+ OpenAPIV3Parser parser = new OpenAPIV3Parser ();
522
+ SwaggerParseResult result = parser .readContents (yaml , null , null );
523
+ List <String > messageList = result .getMessages ();
524
+ Set <String > messages = new HashSet <>(messageList );
525
+
526
+ assertTrue (messages .contains ("attribute components.securitySchemes.api_key.in is not of type `cookie|header|query`" ));
527
+ }
528
+
529
+ @ Test
530
+ public void testSecurityDefinitionApiKeyValid () {
531
+ String yaml = "openapi: 3.0.0\n " +
532
+ "components:\n " +
533
+ " securitySchemes:\n " +
534
+ " api_key:\n " +
535
+ " type: apiKey\n " +
536
+ " name: X-API-KEY\n " +
537
+ " in: cookie" ;
538
+
539
+ OpenAPIV3Parser parser = new OpenAPIV3Parser ();
540
+ SwaggerParseResult result = parser .readContents (yaml , null , null );
541
+ List <String > messageList = result .getMessages ();
542
+ Set <String > messages = new HashSet <>(messageList );
543
+
544
+ assertFalse (messages .contains ("attribute components.securitySchemes.api_key.in is not of type `cookie|header|query`" ));
545
+ }
546
+
494
547
@ Test
495
548
public void testRootInfo () {
496
549
String json = "{\n " +
0 commit comments