Tribe__Events__REST__V1__Endpoints__Base::swaggerize_post_args( string $contentType, array $args )
Returns a swagger structured array for the requestBody field.
Contents
Parameters
- $contentType
-
(string) (Required) The Content-Type header.
- $args
-
(<span class="arrayarray<string|">mixed>) (Required) The provided post args.
Return
(array<string|mixed>) The array of arguments for the swagger requestBody field.
Source
File: src/Tribe/REST/V1/Endpoints/Base.php
public function swaggerize_post_args( $contentType, array $args ) {
$defaults = [
'description' => __( 'No description provided', 'the-events-calendar' ),
];
$swaggerized = [];
foreach ( $args as $name => $arg ) {
if ( isset( $arg['swagger_type'] ) ) {
$type = $arg['swagger_type'];
} else {
$type = isset( $arg['type'] ) ? $arg['type'] : 'string';
}
$type = $this->convert_type( $type );
$read = [ 'type' => $type ];
if ( isset( $arg['description'] ) ) {
$read['description'] = $arg['description'];
}
if ( isset( $arg['items'] ) ) {
$read['items'] = $arg['items'];
}
$swaggerized[ $name ] = array_merge( $defaults, $read );
}
return [
'content' => [
$contentType => [
'schema' => [
'type' => 'object',
'properties' => $swaggerized,
]
]
]
];
}
Changelog
| Version | Description |
|---|---|
| 5.10.0 | Introduced. |