Application API Documentation

Directional Consulting

Classes

Util in package

Class Util.

This class acts as compatibility layer between NelmioApiDocBundle and swagger-php.

It was written to replace the GuilhemN/swagger layer as a lower effort to maintain alternative.

The main purpose of this class is to search for and create child Annotations of swagger Annotation classes with the following convenience methods to get or create the respective Annotation instances if not found

Tags
see
Util::getPath()
see
Util::getSchema()
see
Util::getProperty()
see
Util::getOperation()
see
Util::getOperationParameter()

which in turn get or create the Annotation instances through the following more general methods

see
Util::getChild()
see
Util::getCollectionItem()
see
Util::getIndexedCollectionItem()

which then searches for an existing Annotation through

see
Util::searchCollectionItem()
see
Util::searchIndexedCollectionItem()

and if not found the Annotation creates it through

see
Util::createCollectionItem()
see
Util::createContext()

The merge method @see \Nelmio\ApiDocBundle\OpenApiPhp\Util::merge() has the main purpose to be able to merge properties from an deeply nested array of Annotation properties in the structure of a generated swagger json decoded array.

Table of Contents

OPERATIONS  = ['get', 'post', 'put', 'patch', 'delete', 'options', 'head', 'trace']
All http method verbs as known by swagger.
createChild()  : AbstractAnnotation
Create a new Object of $class with members $properties and set the context parent to be $parent.
createCollectionItem()  : int
Create a new Object of $class with members $properties within $parent->{$collection}[] and return the created index.
createContext()  : Context
Create a new Context with members $properties and parent context $parent.
getChild()  : AbstractAnnotation
Return an existing nested Annotation from $parent->{$property} if exists.
getCollectionItem()  : AbstractAnnotation
Return an existing nested Annotation from $parent->{$collection}[] having all $properties set to the respective values.
getIndexedCollectionItem()  : AbstractAnnotation
Return an existing nested Annotation from $parent->{$collection}[] having its mapped $property set to $value.
getOperation()  : Operation
Return an existing Operation from $path->{$method} or create, set $path->{$method} and return this new Operation object.
getOperationParameter()  : Parameter
Return an existing Parameter object from $operation->parameters[] having its members name set to $name and in set to $in.
getPath()  : PathItem
Return an existing PathItem object from $api->paths[] having its member path set to $path.
getProperty()  : Property
Return an existing Property object from $schema->properties[] having its member property set to $property.
getSchema()  : Schema
Return an existing Schema object from $api->components->schemas[] having its member schema set to $schema.
merge()  : mixed
Merge $from into $annotation. $overwrite is only used for leaf scalar values.
searchCollectionItem()  : int|string|null
Search for an Annotation within $collection that has all members set to the respective values in the associative array $properties.
searchIndexedCollectionItem()  : false|int|string
Search for an Annotation within the $collection that has its member $index set to $value.
getNestingIndexes()  : array<string|int, mixed>
mergeChild()  : mixed
mergeCollection()  : mixed
mergeFromArray()  : mixed
mergeProperty()  : mixed
mergeTyped()  : mixed

Constants

OPERATIONS

All http method verbs as known by swagger.

public array<string|int, mixed> OPERATIONS = ['get', 'post', 'put', 'patch', 'delete', 'options', 'head', 'trace']

Methods

createChild()

Create a new Object of $class with members $properties and set the context parent to be $parent.

public static createChild(AbstractAnnotation $parent, string $class[, array<string|int, mixed> $properties = [] ]) : AbstractAnnotation
Parameters
$parent : AbstractAnnotation
$class : string
$properties : array<string|int, mixed> = []
Tags
throws
InvalidArgumentException

at an attempt to pass in properties that are found in $parent::$_nested

Return values
AbstractAnnotation

createCollectionItem()

Create a new Object of $class with members $properties within $parent->{$collection}[] and return the created index.

public static createCollectionItem(AbstractAnnotation $parent, string $collection, string $class[, array<string|int, mixed> $properties = [] ]) : int
Parameters
$parent : AbstractAnnotation
$collection : string
$class : string
$properties : array<string|int, mixed> = []
Return values
int

createContext()

Create a new Context with members $properties and parent context $parent.

public static createContext([array<string|int, mixed> $properties = [] ][, Context $parent = null ]) : Context
Parameters
$properties : array<string|int, mixed> = []
$parent : Context = null
Tags
see
Context
Return values
Context

getChild()

Return an existing nested Annotation from $parent->{$property} if exists.

public static getChild(AbstractAnnotation $parent,  $class[, array<string|int, mixed> $properties = [] ]) : AbstractAnnotation

Create, add to $parent->{$property} and set its members to $properties otherwise.

$property is determined from $parent::$_nested[$class] it is expected to be a string nested property.

Parameters
$parent : AbstractAnnotation
$class :
$properties : array<string|int, mixed> = []
Tags
see
AbstractAnnotation::$_nested
Return values
AbstractAnnotation

getCollectionItem()

Return an existing nested Annotation from $parent->{$collection}[] having all $properties set to the respective values.

public static getCollectionItem(AbstractAnnotation $parent, string $class[, array<string|int, mixed> $properties = [] ]) : AbstractAnnotation

Create, add to $parent->{$collection}[] and set its members to $properties otherwise.

$collection is determined from $parent::$_nested[$class] it is expected to be a single value array nested Annotation.

Parameters
$parent : AbstractAnnotation
$class : string
$properties : array<string|int, mixed> = []
Tags
see
AbstractAnnotation::$_nested
Return values
AbstractAnnotation

getIndexedCollectionItem()

Return an existing nested Annotation from $parent->{$collection}[] having its mapped $property set to $value.

public static getIndexedCollectionItem(AbstractAnnotation $parent, string $class, mixed $value) : AbstractAnnotation

Create, add to $parent->{$collection}[] and set its member $property to $value otherwise.

$collection is determined from $parent::$_nested[$class] it is expected to be a double value array nested Annotation with the second value being the mapping index $property.

Parameters
$parent : AbstractAnnotation
$class : string
$value : mixed
Tags
see
AbstractAnnotation::$_nested
Return values
AbstractAnnotation

getOperation()

Return an existing Operation from $path->{$method} or create, set $path->{$method} and return this new Operation object.

public static getOperation(PathItem $path, string $method) : Operation
Parameters
$path : PathItem
$method : string
Tags
see
PathItem::$get
see
PathItem::$post
see
PathItem::$put
see
PathItem::$patch
see
PathItem::$delete
see
PathItem::$options
see
PathItem::$head
Return values
Operation

getOperationParameter()

Return an existing Parameter object from $operation->parameters[] having its members name set to $name and in set to $in.

public static getOperationParameter(Operation $operation, string $name, string $in) : Parameter

Create, add to $operation->parameters[] and return this new Parameter object and set its members if none found.

Parameters
$operation : Operation
$name : string
$in : string
Tags
see
Operation::$parameters
see
Parameter::$name
see
Parameter::$in
Return values
Parameter

getPath()

Return an existing PathItem object from $api->paths[] having its member path set to $path.

public static getPath(OpenApi $api, string $path) : PathItem

Create, add to $api->paths[] and return this new PathItem object and set the property if none found.

Parameters
$api : OpenApi
$path : string
Tags
see
OpenApi::$paths
see
PathItem::path
Return values
PathItem

getProperty()

Return an existing Property object from $schema->properties[] having its member property set to $property.

public static getProperty(Schema $schema, string $property) : Property

Create, add to $schema->properties[] and return this new Property object and set the property if none found.

Parameters
$schema : Schema
$property : string
Tags
see
Schema::$properties
see
Property::$property
Return values
Property

getSchema()

Return an existing Schema object from $api->components->schemas[] having its member schema set to $schema.

public static getSchema(OpenApi $api, string $schema) : Schema

Create, add to $api->components->schemas[] and return this new Schema object and set the property if none found.

Parameters
$api : OpenApi
$schema : string
Tags
see
Schema::$schema
see
Components::$schemas
Return values
Schema

merge()

Merge $from into $annotation. $overwrite is only used for leaf scalar values.

public static merge(AbstractAnnotation $annotation, array<string|int, mixed>|ArrayObject|AbstractAnnotation $from[, bool $overwrite = false ]) : mixed

The main purpose is to create a Swagger Object from array config values in the structure of a json serialized Swagger object.

Parameters
$annotation : AbstractAnnotation
$from : array<string|int, mixed>|ArrayObject|AbstractAnnotation
$overwrite : bool = false
Return values
mixed

searchCollectionItem()

Search for an Annotation within $collection that has all members set to the respective values in the associative array $properties.

public static searchCollectionItem(array<string|int, mixed> $collection, array<string|int, mixed> $properties) : int|string|null
Parameters
$collection : array<string|int, mixed>
$properties : array<string|int, mixed>
Return values
int|string|null

searchIndexedCollectionItem()

Search for an Annotation within the $collection that has its member $index set to $value.

public static searchIndexedCollectionItem(array<string|int, mixed> $collection, string $member, mixed $value) : false|int|string
Parameters
$collection : array<string|int, mixed>
$member : string
$value : mixed
Return values
false|int|string

getNestingIndexes()

private static getNestingIndexes(mixed $class) : array<string|int, mixed>
Parameters
$class : mixed
Return values
array<string|int, mixed>

mergeChild()

private static mergeChild(AbstractAnnotation $annotation, mixed $className, mixed $value, bool $overwrite) : mixed
Parameters
$annotation : AbstractAnnotation
$className : mixed
$value : mixed
$overwrite : bool
Return values
mixed

mergeCollection()

private static mergeCollection(AbstractAnnotation $annotation, mixed $className, mixed $collection, mixed $property, mixed $items, bool $overwrite) : mixed
Parameters
$annotation : AbstractAnnotation
$className : mixed
$collection : mixed
$property : mixed
$items : mixed
$overwrite : bool
Return values
mixed

mergeFromArray()

private static mergeFromArray(AbstractAnnotation $annotation, array<string|int, mixed> $properties, bool $overwrite) : mixed
Parameters
$annotation : AbstractAnnotation
$properties : array<string|int, mixed>
$overwrite : bool
Return values
mixed

mergeProperty()

private static mergeProperty(AbstractAnnotation $annotation, mixed $propertyName, mixed $value, mixed $default, bool $overwrite) : mixed
Parameters
$annotation : AbstractAnnotation
$propertyName : mixed
$value : mixed
$default : mixed
$overwrite : bool
Return values
mixed

mergeTyped()

private static mergeTyped(AbstractAnnotation $annotation, mixed $propertyName, mixed $type, array<string|int, mixed> $properties, array<string|int, mixed> $defaults, bool $overwrite) : mixed
Parameters
$annotation : AbstractAnnotation
$propertyName : mixed
$type : mixed
$properties : array<string|int, mixed>
$defaults : array<string|int, mixed>
$overwrite : bool
Return values
mixed

        

Search Results

Search results

Found Results