public function testSerialize() { $parameter = new Parameter('query', 'count', 'Count parameter', true); $parameter->setAllowMultiple(false); $parameter->setType('Pet'); $content = <<<JSON { "paramType": "query", "name": "count", "description": "Count parameter", "required": true, "allowMultiple": false, "type": "Pet" } JSON; $this->assertRecordEqualsContent($parameter, $content); $this->assertEquals('query', $parameter->getParamType()); $this->assertEquals('count', $parameter->getName()); $this->assertEquals('Count parameter', $parameter->getDescription()); $this->assertEquals(true, $parameter->getRequired()); $this->assertEquals(false, $parameter->getAllowMultiple()); $this->assertEquals('Pet', $parameter->getType()); }
protected function setParameterType(PropertyInterface $parameter, Parameter $param) { switch (true) { case $parameter instanceof Property\IntegerType: $param->setType('integer'); break; case $parameter instanceof Property\FloatType: $param->setType('number'); break; case $parameter instanceof Property\BooleanType: $param->setType('boolean'); break; case $parameter instanceof Property\DateType: $param->setType('string'); $param->setFormat('date'); break; case $parameter instanceof Property\DateTimeType: $param->setType('string'); $param->setFormat('date-time'); break; default: $param->setType('string'); break; } $param->setDescription($parameter->getDescription()); $param->setRequired($parameter->isRequired()); if ($parameter instanceof Property\DecimalType) { $param->setMinimum($parameter->getMin()); $param->setMaximum($parameter->getMax()); } elseif ($parameter instanceof Property\StringType) { $param->setMinimum($parameter->getMinLength()); $param->setMaximum($parameter->getMaxLength()); $param->setEnum($parameter->getEnumeration()); } }