Completed
Pull Request — master (#11)
by Viacheslav
02:53
created

BodyParameter::setIn()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
/**
3
 * @file ATTENTION!!! The code below was carefully crafted by a mean machine.
4
 * Please consider to NOT put any emotional human-generated modifications as the splendid AI will throw them away with no mercy.
5
 */
6
7
namespace Swaggest\JsonSchema\SwaggerSchema;
8
9
use Swaggest\JsonSchema\Constraint\Properties;
10
use Swaggest\JsonSchema\Schema as JsonBasicSchema;
11
use Swaggest\JsonSchema\Structure\ClassStructure;
12
13
14
class BodyParameter extends ClassStructure {
15
	/** @var string A brief description of the parameter. This could contain examples of use.  GitHub Flavored Markdown is allowed. */
16
	public $description;
17
18
	/** @var string The name of the parameter. */
19
	public $name;
20
21
	/** @var string Determines the location of the parameter. */
22
	public $in;
23
24
	/** @var bool Determines whether or not this parameter is required or optional. */
25
	public $required;
26
27
	/** @var Schema A deterministic version of a JSON Schema object. */
28
	public $schema;
29
30
	/**
31
	 * @param Properties|static $properties
32
	 * @param JsonBasicSchema $ownerSchema
33
	 */
34
	public static function setUpProperties($properties, JsonBasicSchema $ownerSchema)
35
	{
36
		$properties->description = JsonBasicSchema::string();
37
		$properties->description->description = 'A brief description of the parameter. This could contain examples of use.  GitHub Flavored Markdown is allowed.';
38
		$properties->name = JsonBasicSchema::string();
39
		$properties->name->description = 'The name of the parameter.';
40
		$properties->in = JsonBasicSchema::string();
41
		$properties->in->description = 'Determines the location of the parameter.';
42
		$properties->in->enum = array (
43
		  0 => 'body',
44
		);
45
		$properties->required = JsonBasicSchema::boolean();
46
		$properties->required->description = 'Determines whether or not this parameter is required or optional.';
47
		$properties->required->default = false;
48
		$properties->schema = Schema::schema();
49
		$ownerSchema->type = 'object';
0 ignored issues
show
Documentation Bug introduced by
It seems like 'object' of type string is incompatible with the declared type array of property $type.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
50
		$ownerSchema->additionalProperties = false;
51
		$ownerSchema->patternProperties['^x-'] = new JsonBasicSchema();
52
		$ownerSchema->patternProperties['^x-']->description = 'Any property starting with x- is valid.';
53
		$ownerSchema->required = array (
54
		  0 => 'name',
55
		  1 => 'in',
56
		  2 => 'schema',
57
		);
58
	}
59
60
	/**
61
	 * @param string $description A brief description of the parameter. This could contain examples of use.  GitHub Flavored Markdown is allowed.
62
	 * @return $this
63
	 */
64
	public function setDescription($description)
65
	{
66
		$this->description = $description;
67
		return $this;
68
	}
69
70
	/**
71
	 * @param string $name The name of the parameter.
72
	 * @return $this
73
	 */
74
	public function setName($name)
75
	{
76
		$this->name = $name;
77
		return $this;
78
	}
79
80
	/**
81
	 * @param string $in Determines the location of the parameter.
82
	 * @return $this
83
	 */
84
	public function setIn($in)
85
	{
86
		$this->in = $in;
87
		return $this;
88
	}
89
90
	/**
91
	 * @param bool $required Determines whether or not this parameter is required or optional.
92
	 * @return $this
93
	 */
94
	public function setRequired($required)
95
	{
96
		$this->required = $required;
97
		return $this;
98
	}
99
100
	/**
101
	 * @param Schema $schema A deterministic version of a JSON Schema object.
102
	 * @return $this
103
	 */
104
	public function setSchema($schema)
105
	{
106
		$this->schema = $schema;
107
		return $this;
108
	}
109
}
110
111