From 2805b8ea2c7111ee22dffafa66ea540730e9c13e Mon Sep 17 00:00:00 2001 From: Heikki Kurhinen Date: Fri, 5 May 2017 14:42:33 +0300 Subject: [PATCH] Added support for HEAD requests. Technically HEAD should return 204 but since wordpress return 200, went with it. --- lib/class-wp-rest-swagger-controller.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/class-wp-rest-swagger-controller.php b/lib/class-wp-rest-swagger-controller.php index 57d4314..715c693 100644 --- a/lib/class-wp-rest-swagger-controller.php +++ b/lib/class-wp-rest-swagger-controller.php @@ -294,6 +294,23 @@ function ($matches) use (&$defaultidParams){ ,'responses'=>$responses ); + + if($methodName=='GET') { + $swagger['paths'][$endpointName]['head'] = array( + 'parameters'=>$parameters + ,'security'=>$security + ,'responses'=>array( + 200=>array( + 'description'=> "successful operation" + ) + ,'default'=>array( + 'description'=> "error" + ,'schema'=>array('$ref'=>'#/definitions/error') + ) + ) + + ); + } } }