示例#1
0
 public function testCreatesParamFromArray()
 {
     $p = new Parameter($this->data);
     $this->assertEquals('foo', $p->getName());
     $this->assertEquals('bar', $p->getType());
     $this->assertEquals(true, $p->getRequired());
     $this->assertEquals('123', $p->getDefault());
     $this->assertEquals('456', $p->getDescription());
     $this->assertEquals(2, $p->getMinLength());
     $this->assertEquals(5, $p->getMaxLength());
     $this->assertEquals('body', $p->getLocation());
     $this->assertEquals('static!', $p->getStatic());
     $this->assertEquals(array('trim', 'json_encode'), $p->getFilters());
     $p->setName('abc');
     $this->assertEquals('abc', $p->getName());
 }
示例#2
0
 private function visitOuterObject(Parameter $model, array &$result, CommandInterface $command, ResponseInterface $response, array &$context)
 {
     $parentLocation = $model->getLocation();
     // If top-level additionalProperties is a schema, then visit it
     $additional = $model->getAdditionalProperties();
     if ($additional instanceof Parameter) {
         // Use the model location if none set on additionalProperties.
         $location = $additional->getLocation() ?: $parentLocation;
         //Changed:
         if ($additional->getName()) {
             $model->setName($additional->getName());
         }
         $this->triggerBeforeVisitor($location, $model, $result, $command, $response, $context);
     }
     // Use 'location' from all individual defined properties, but fall back
     // to the model location if no per-property location is set. Collect
     // the properties that need to be visited into an array.
     $visitProperties = [];
     foreach ($model->getProperties() as $schema) {
         $location = $schema->getLocation() ?: $parentLocation;
         if ($location) {
             $visitProperties[] = [$location, $schema];
             // Trigger the before method on each unique visitor location
             if (!isset($context['visitors'][$location])) {
                 $this->triggerBeforeVisitor($location, $model, $result, $command, $response, $context);
             }
         }
     }
     // Actually visit each response element
     foreach ($visitProperties as $prop) {
         $this->responseLocations[$prop[0]]->visit($command, $response, $prop[1], $result, $context);
     }
 }