/**
  * Create a new SecuritySchemeDescribedBy from an array of data
  *
  * @param string    $key
  * @param array     $data
  * [
  *  headers:            ?array
  *  queryParameters:    ?array
  *  responses:          ?array
  * ]
  *
  * @return SecuritySchemeDescribedBy
  */
 public static function createFromArray($key, array $data = [])
 {
     $describedBy = new static($key);
     if (isset($data['body'])) {
         foreach ($data['body'] as $key => $bodyData) {
             if (in_array($key, \Raml\WebFormBody::$validMediaTypes)) {
                 $body = \Raml\WebFormBody::createFromArray($key, $bodyData);
             } else {
                 $body = \Raml\Body::createFromArray($key, $bodyData);
             }
             $describedBy->addBody($body);
         }
     }
     if (isset($data['headers'])) {
         foreach ($data['headers'] as $key => $header) {
             $describedBy->addHeader(NamedParameter::createFromArray($key, $header));
         }
     }
     if (isset($data['queryParameters'])) {
         foreach ($data['queryParameters'] as $key => $queryParameterData) {
             $describedBy->addQueryParameter(NamedParameter::createFromArray($key, $queryParameterData));
         }
     }
     if (isset($data['responses']) && is_array($data['responses'])) {
         foreach ($data['responses'] as $responseCode => $response) {
             $describedBy->addResponse(Response::createFromArray($responseCode, $response ?: []));
         }
     }
     return $describedBy;
 }
 /**
  * Validate a certain formats against their schema.
  * 
  * @param \Raml\Body $body_obj	The body object to pull the schema from
  * @param mixed $data			The data used as the body
  * @param string $body_type		The mime type of the chosen RAML body
  * 
  * @return boolean True if the validation succeeded or wasn't performed, or false if validation failed
  */
 protected function validate_schema(\Raml\Body $body_obj, $data, $body_type)
 {
     $format = \Utility::get_format($body_type);
     /*
      * If they've explicitly specified the request in the remote server's format, then we'll validate it.
      * If they've posted an array of data, then we'll just hope for the best later on when we auto-convert it.
      */
     if (is_string($data) && !empty($schema = $body_obj->getSchema())) {
         // Validate it against types we can validate against.
         switch ($format) {
             case 'json':
                 // No break
             // No break
             case 'xml':
                 try {
                     $schema->validate($data);
                 } catch (\Raml\Exception\InvalidSchemaException $e) {
                     return false;
                 }
                 break;
             case 'csv':
                 /**
                  * We don't yet have a way to check this type.
                  * 
                  * @TODO Get one.
                  */
                 break;
         }
     }
     /*
      * Either it was successful, or we can't validate it due to the specified data not falling into
      * our limited 3x3 mindspace. :p
      * 
      * You can't process everything, so you've got to process... some. Hmmm.
      */
     return true;
 }