| @@ 75-91 (lines=17) @@ | ||
| 72 | /** |
|
| 73 | * @test |
|
| 74 | */ |
|
| 75 | public function canOmitParameterWhenNotExplicitlyMarkedAsRequired() |
|
| 76 | { |
|
| 77 | $operationDefinition = (object)[ |
|
| 78 | 'parameters' => [ |
|
| 79 | (object)[ |
|
| 80 | 'name' => 'foo', |
|
| 81 | 'in' => 'body', |
|
| 82 | 'schema' => (object)[ |
|
| 83 | 'type' => 'integer' |
|
| 84 | ] |
|
| 85 | ] |
|
| 86 | ] |
|
| 87 | ]; |
|
| 88 | ||
| 89 | $validator = new RequestValidator(OperationObject::createFromOperationDefinition($operationDefinition)); |
|
| 90 | $request = new Request(); |
|
| 91 | $validator->validateRequest($request); |
|
| 92 | } |
|
| 93 | ||
| 94 | /** |
|
| @@ 98-114 (lines=17) @@ | ||
| 95 | * @test |
|
| 96 | * @expectedException \KleijnWeb\SwaggerBundle\Exception\InvalidParametersException |
|
| 97 | */ |
|
| 98 | public function cannotOmitParameterWhenExplicitlyMarkedAsRequired() |
|
| 99 | { |
|
| 100 | $request = new Request(); |
|
| 101 | ||
| 102 | $operationDefinition = (object)[ |
|
| 103 | 'parameters' => [ |
|
| 104 | (object)[ |
|
| 105 | 'name' => 'foo', |
|
| 106 | 'required' => true, |
|
| 107 | 'in' => 'query', |
|
| 108 | 'type' => 'int' |
|
| 109 | ] |
|
| 110 | ] |
|
| 111 | ]; |
|
| 112 | ||
| 113 | $validator = new RequestValidator(OperationObject::createFromOperationDefinition($operationDefinition)); |
|
| 114 | $validator->validateRequest($request); |
|
| 115 | } |
|
| 116 | ||
| 117 | /** |
|
| @@ 121-137 (lines=17) @@ | ||
| 118 | * @test |
|
| 119 | * @expectedException \KleijnWeb\SwaggerBundle\Exception\InvalidParametersException |
|
| 120 | */ |
|
| 121 | public function cannotOmitBodyWhenExplicitlyMarkedAsRequired() |
|
| 122 | { |
|
| 123 | $request = new Request(); |
|
| 124 | ||
| 125 | $operationDefinition = (object)[ |
|
| 126 | 'parameters' => [ |
|
| 127 | (object)[ |
|
| 128 | 'name' => 'foo', |
|
| 129 | 'required' => true, |
|
| 130 | 'in' => 'query', |
|
| 131 | 'type' => 'int' |
|
| 132 | ] |
|
| 133 | ] |
|
| 134 | ]; |
|
| 135 | ||
| 136 | $validator = new RequestValidator(OperationObject::createFromOperationDefinition($operationDefinition)); |
|
| 137 | ||
| 138 | $validator->validateRequest($request); |
|
| 139 | } |
|
| 140 | ||