示例#1
0
 /**
  * Create a new WebFormObject from an array
  *
  * @param string $key The valid media type to use as the key
  * @param array $data The array of data to create \NamedParameter objects from
  *
  * @return \Raml\WebFormBody
  */
 public static function createFromArray($key, array $data = [])
 {
     $webFormBody = new static($key);
     if ($data['formParameters']) {
         foreach ($data['formParameters'] as $namedParam => $namedParamData) {
             $webFormBody->addParameter(NamedParameter::createFromArray($namedParam, $namedParamData));
         }
     }
     return $webFormBody;
 }
 /**
  * Add a new base uri parameter
  *
  * @param NamedParameter $namedParameter
  */
 public function addBaseUriParameter(NamedParameter $namedParameter)
 {
     $this->baseUriParameters[$namedParameter->getKey()] = $namedParameter;
 }
 /**
  * Add a query parameter
  *
  * @param NamedParameter $queryParameter
  */
 public function addQueryParameter(NamedParameter $queryParameter)
 {
     $this->queryParameters[$queryParameter->getKey()] = $queryParameter;
 }
 /** @test */
 public function shouldParseResponseHeaders()
 {
     $headersRaml = $this->parser->parse(__DIR__ . '/fixture/headers.raml');
     $resource = $headersRaml->getResourceByUri('/jobs');
     $this->assertEquals(['X-waiting-period' => \Raml\NamedParameter::createFromArray('X-waiting-period', ['description' => 'The number of seconds to wait before you can attempt to make a request again.' . "\n", 'type' => 'integer', 'required' => 'yes', 'minimum' => 1, 'maximum' => 3600, 'example' => 34])], $resource->getMethod('post')->getResponse(503)->getHeaders());
 }