| @@ 63-79 (lines=17) @@ | ||
| 60 | /** |
|
| 61 | * @test |
|
| 62 | */ |
|
| 63 | public function canOmitParameterWhenNotExplicitlyMarkedAsRequired() |
|
| 64 | { |
|
| 65 | $operationDefinition = (object)[ |
|
| 66 | 'parameters' => [ |
|
| 67 | (object)[ |
|
| 68 | 'name' => 'foo', |
|
| 69 | 'in' => 'body', |
|
| 70 | 'schema' => (object)[ |
|
| 71 | 'type' => 'integer' |
|
| 72 | ] |
|
| 73 | ] |
|
| 74 | ] |
|
| 75 | ]; |
|
| 76 | $validator = new RequestValidator(OperationObject::createFromOperationDefinition($operationDefinition)); |
|
| 77 | $request = new Request(); |
|
| 78 | $validator->validateRequest($request); |
|
| 79 | } |
|
| 80 | ||
| 81 | /** |
|
| 82 | * @test |
|
| @@ 85-101 (lines=17) @@ | ||
| 82 | * @test |
|
| 83 | * @expectedException \KleijnWeb\SwaggerBundle\Exception\InvalidParametersException |
|
| 84 | */ |
|
| 85 | public function cannotOmitParameterWhenExplicitlyMarkedAsRequired() |
|
| 86 | { |
|
| 87 | $request = new Request(); |
|
| 88 | ||
| 89 | $operationDefinition = (object)[ |
|
| 90 | 'parameters' => [ |
|
| 91 | (object)[ |
|
| 92 | 'name' => 'foo', |
|
| 93 | 'required' => true, |
|
| 94 | 'in' => 'query', |
|
| 95 | 'type' => 'int' |
|
| 96 | ] |
|
| 97 | ] |
|
| 98 | ]; |
|
| 99 | $validator = new RequestValidator(OperationObject::createFromOperationDefinition($operationDefinition)); |
|
| 100 | $validator->validateRequest($request); |
|
| 101 | } |
|
| 102 | ||
| 103 | /** |
|
| 104 | * @test |
|
| @@ 107-123 (lines=17) @@ | ||
| 104 | * @test |
|
| 105 | * @expectedException \KleijnWeb\SwaggerBundle\Exception\InvalidParametersException |
|
| 106 | */ |
|
| 107 | public function cannotOmitBodyWhenExplicitlyMarkedAsRequired() |
|
| 108 | { |
|
| 109 | $request = new Request(); |
|
| 110 | ||
| 111 | $operationDefinition = (object)[ |
|
| 112 | 'parameters' => [ |
|
| 113 | (object)[ |
|
| 114 | 'name' => 'foo', |
|
| 115 | 'required' => true, |
|
| 116 | 'in' => 'query', |
|
| 117 | 'type' => 'int' |
|
| 118 | ] |
|
| 119 | ] |
|
| 120 | ]; |
|
| 121 | $validator = new RequestValidator(OperationObject::createFromOperationDefinition($operationDefinition)); |
|
| 122 | $validator->validateRequest($request); |
|
| 123 | } |
|
| 124 | ||
| 125 | /** |
|
| 126 | * @param string $format |
|