Update OpenAPI generator to improve attributes.

This commit is contained in:
Buster "Silver Eagle" Neece 2021-12-28 12:26:41 -06:00
parent 9643953d45
commit ba10526c94
No known key found for this signature in database
GPG Key ID: 9FC8B9E008872109
21 changed files with 106 additions and 91 deletions

14
composer.lock generated
View File

@ -9457,16 +9457,16 @@
},
{
"name": "zircote/swagger-php",
"version": "4.0.5",
"version": "4.1.0",
"source": {
"type": "git",
"url": "https://github.com/zircote/swagger-php.git",
"reference": "31210d89e8c4df86e01a428bdbd2943fc8fc09b2"
"reference": "faafa3535c11c05e17f05f21a541b96a837a55a2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/zircote/swagger-php/zipball/31210d89e8c4df86e01a428bdbd2943fc8fc09b2",
"reference": "31210d89e8c4df86e01a428bdbd2943fc8fc09b2",
"url": "https://api.github.com/repos/zircote/swagger-php/zipball/faafa3535c11c05e17f05f21a541b96a837a55a2",
"reference": "faafa3535c11c05e17f05f21a541b96a837a55a2",
"shasum": ""
},
"require": {
@ -9526,9 +9526,9 @@
],
"support": {
"issues": "https://github.com/zircote/swagger-php/issues",
"source": "https://github.com/zircote/swagger-php/tree/4.0.5"
"source": "https://github.com/zircote/swagger-php/tree/4.1.0"
},
"time": "2021-12-20T01:09:47+00:00"
"time": "2021-12-23T01:28:48+00:00"
}
],
"packages-dev": [
@ -14091,5 +14091,5 @@
"ext-xmlwriter": "*"
},
"platform-dev": [],
"plugin-api-version": "2.2.0"
"plugin-api-version": "2.1.0"
}

View File

@ -6,7 +6,7 @@ namespace App\Entity;
use App\Entity\Interfaces\IdentifiableEntityInterface;
use Doctrine\ORM\Mapping as ORM;
use OpenApi\Annotations as OA;
use OpenApi\Attributes as OA;
use Stringable;
use Symfony\Component\Validator\Constraints as Assert;

View File

@ -8,7 +8,7 @@ use App\Entity\Interfaces\IdentifiableEntityInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use OpenApi\Annotations as OA;
use OpenApi\Attributes as OA;
#[
OA\Schema(type: "object"),

View File

@ -9,7 +9,7 @@ use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use JsonSerializable;
use OpenApi\Annotations as OA;
use OpenApi\Attributes as OA;
use Stringable;
use Symfony\Component\Validator\Constraints as Assert;

View File

@ -12,7 +12,7 @@ use App\Service\Avatar;
use App\Utilities\Urls;
use Doctrine\ORM\Mapping as ORM;
use GuzzleHttp\Psr7\Uri;
use OpenApi\Annotations as OA;
use OpenApi\Attributes as OA;
use Psr\Http\Message\UriInterface;
use RuntimeException;
use Stringable;
@ -20,7 +20,7 @@ use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
#[
OA\Schema(type: "object", schema: "Settings"),
OA\Schema(schema: "Settings", type: "object"),
ORM\Entity,
ORM\Table(name: 'settings'),
Attributes\Auditable

View File

@ -8,7 +8,7 @@ use App\Entity\Attributes\Auditable;
use App\Entity\Interfaces\IdentifiableEntityInterface;
use App\Validator\Constraints\UniqueEntity;
use Doctrine\ORM\Mapping as ORM;
use OpenApi\Annotations as OA;
use OpenApi\Attributes as OA;
use Symfony\Component\Validator\Constraints as Assert;
use const PASSWORD_ARGON2ID;

View File

@ -19,7 +19,7 @@ use Doctrine\ORM\Mapping as ORM;
use InvalidArgumentException;
use League\Flysystem\UnixVisibility\PortableVisibilityConverter;
use League\Flysystem\Visibility;
use OpenApi\Annotations as OA;
use OpenApi\Attributes as OA;
use Psr\Http\Message\UriInterface;
use RuntimeException;
use Stringable;
@ -27,7 +27,7 @@ use Symfony\Component\Serializer\Annotation as Serializer;
use Symfony\Component\Validator\Constraints as Assert;
#[
OA\Schema(type: "object", schema: "Station"),
OA\Schema(schema: "Station", type: "object"),
ORM\Entity,
ORM\Table(name: 'station'),
ORM\Index(columns: ['short_name'], name: 'idx_short_name'),
@ -86,8 +86,8 @@ class Station implements Stringable, IdentifiableEntityInterface
#[
OA\Property(
type: "array",
description: "An array containing station-specific frontend configuration",
type: "array",
items: new OA\Items()
),
ORM\Column(type: 'json', nullable: true),
@ -108,8 +108,8 @@ class Station implements Stringable, IdentifiableEntityInterface
#[
OA\Property(
type: "array",
description: "An array containing station-specific backend configuration",
type: "array",
items: new OA\Items()
),
ORM\Column(type: 'json', nullable: true),

View File

@ -16,7 +16,7 @@ use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Exception;
use OpenApi\Annotations as OA;
use OpenApi\Attributes as OA;
use RuntimeException;
use Symfony\Component\Serializer\Annotation as Serializer;
@ -30,7 +30,6 @@ use Symfony\Component\Serializer\Annotation as Serializer;
class StationMedia implements SongInterface, ProcessableMediaInterface, PathAwareInterface, IdentifiableEntityInterface
{
use Traits\HasAutoIncrementId;
use Traits\TruncateStrings;
use Traits\HasSongFields;
public const UNIQUE_ID_LENGTH = 24;
@ -229,7 +228,7 @@ class StationMedia implements SongInterface, ProcessableMediaInterface, PathAwar
*
* @throws Exception
*/
public function generateUniqueId($force_new = false): void
public function generateUniqueId(bool $force_new = false): void
{
if (!isset($this->unique_id) || $force_new) {
$this->unique_id = bin2hex(random_bytes(12));
@ -427,6 +426,9 @@ class StationMedia implements SongInterface, ProcessableMediaInterface, PathAwar
$this->art_updated_at = $art_updated_at;
}
/**
* @return Collection<CustomField>
*/
public function getCustomFields(): Collection
{
return $this->custom_fields;
@ -459,7 +461,7 @@ class StationMedia implements SongInterface, ProcessableMediaInterface, PathAwar
}
/**
* @return StationPlaylistMedia[]|Collection
* @return Collection<StationPlaylistMedia>
*/
public function getPlaylists(): Collection
{

View File

@ -8,7 +8,7 @@ use App\Radio\Adapters;
use App\Radio\Frontend\AbstractFrontend;
use App\Utilities\Urls;
use Doctrine\ORM\Mapping as ORM;
use OpenApi\Annotations as OA;
use OpenApi\Attributes as OA;
use Psr\Http\Message\UriInterface;
use Stringable;
use Symfony\Component\Validator\Constraints as Assert;

View File

@ -8,7 +8,7 @@ use Azura\Normalizer\Attributes\DeepNormalize;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use OpenApi\Annotations as OA;
use OpenApi\Attributes as OA;
use Stringable;
use Symfony\Component\Serializer\Annotation as Serializer;
use Symfony\Component\Validator\Constraints as Assert;
@ -417,7 +417,7 @@ class StationPlaylist implements
}
/**
* @return Collection|StationPlaylistMedia[]
* @return Collection<StationPlaylistMedia>
*/
public function getMediaItems(): Collection
{
@ -425,7 +425,7 @@ class StationPlaylist implements
}
/**
* @return Collection|StationPlaylistFolder[]
* @return Collection<StationPlaylistFolder>
*/
public function getFolders(): Collection
{
@ -433,7 +433,7 @@ class StationPlaylist implements
}
/**
* @return Collection|StationSchedule[]
* @return Collection<StationSchedule>
*/
public function getScheduleItems(): Collection
{

View File

@ -9,8 +9,7 @@ use Carbon\CarbonImmutable;
use Carbon\CarbonInterface;
use DateTimeZone;
use Doctrine\ORM\Mapping as ORM;
use InvalidArgumentException;
use OpenApi\Annotations as OA;
use OpenApi\Attributes as OA;
#[
OA\Schema(type: "object"),
@ -71,10 +70,8 @@ class StationSchedule implements IdentifiableEntityInterface
{
if ($relation instanceof StationPlaylist) {
$this->playlist = $relation;
} elseif ($relation instanceof StationStreamer) {
$this->streamer = $relation;
} else {
throw new InvalidArgumentException('Schedule must be created with either a playlist or a streamer.');
$this->streamer = $relation;
}
}

View File

@ -9,7 +9,7 @@ use Azura\Normalizer\Attributes\DeepNormalize;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use OpenApi\Annotations as OA;
use OpenApi\Attributes as OA;
use Stringable;
use Symfony\Component\Serializer\Annotation as Serializer;
use Symfony\Component\Validator\Constraints as Assert;
@ -208,7 +208,7 @@ class StationStreamer implements
}
/**
* @return Collection|StationSchedule[]
* @return Collection<StationSchedule>
*/
public function getScheduleItems(): Collection
{

View File

@ -8,7 +8,7 @@ use App\Entity\Interfaces\IdentifiableEntityInterface;
use App\Entity\Interfaces\StationMountInterface;
use Carbon\CarbonImmutable;
use Doctrine\ORM\Mapping as ORM;
use OpenApi\Annotations as OA;
use OpenApi\Attributes as OA;
#[
OA\Schema(

View File

@ -5,7 +5,7 @@ declare(strict_types=1);
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use OpenApi\Annotations as OA;
use OpenApi\Attributes as OA;
use Stringable;
use Symfony\Component\Validator\Constraints as Assert;
@ -70,8 +70,8 @@ class StationWebhook implements
#[
OA\Property(
type: "array",
description: "List of events that should trigger the webhook notification.",
type: "array",
items: new OA\Items()
),
ORM\Column(type: 'json', nullable: true)
@ -80,8 +80,8 @@ class StationWebhook implements
#[
OA\Property(
type: "array",
description: "Detailed webhook configuration (if applicable)",
type: "array",
items: new OA\Items()
),
ORM\Column(type: 'json', nullable: true)
@ -90,8 +90,8 @@ class StationWebhook implements
#[
OA\Property(
type: "array",
description: "Internal details used by the webhook to preserve state.",
type: "array",
items: new OA\Items()
),
ORM\Column(type: 'json', nullable: true),
@ -170,9 +170,9 @@ class StationWebhook implements
* Set the value of a given metadata key.
*
* @param string $key
* @param mixed $value
* @param mixed|null $value
*/
public function setMetadataKey(string $key, $value = null): void
public function setMetadataKey(string $key, mixed $value = null): void
{
if (null === $value) {
unset($this->metadata[$key]);

View File

@ -382,7 +382,7 @@ class StorageLocation implements Stringable, IdentifiableEntityInterface
}
/**
* @return Collection|StationMedia[]
* @return Collection<StationMedia>
*/
public function getMedia(): Collection
{

View File

@ -6,19 +6,20 @@ namespace App\Entity\Traits;
use App\Entity\Interfaces\EntityGroupsInterface;
use Doctrine\ORM\Mapping as ORM;
use OpenApi\Annotations as OA;
use OpenApi\Attributes as OA;
use RuntimeException;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @OA\Schema(type="object")
*/
#[OA\Schema(type: 'object')]
trait HasAutoIncrementId
{
/** @OA\Property() */
#[ORM\Column(nullable: false)]
#[ORM\Id, ORM\GeneratedValue]
#[Groups([EntityGroupsInterface::GROUP_ID, EntityGroupsInterface::GROUP_ALL])]
#[
OA\Property,
ORM\Column(nullable: false),
ORM\Id,
ORM\GeneratedValue,
Groups([EntityGroupsInterface::GROUP_ID, EntityGroupsInterface::GROUP_ALL])
]
protected ?int $id = null;
public function getId(): ?int

View File

@ -8,33 +8,40 @@ use App\Entity\Interfaces\EntityGroupsInterface;
use App\Entity\Interfaces\SongInterface;
use App\Entity\Song;
use Doctrine\ORM\Mapping as ORM;
use OpenApi\Attributes as OA;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @OA\Schema(type="object")
*/
#[OA\Schema(type: 'object')]
trait HasSongFields
{
use TruncateStrings;
/** @OA\Property() */
#[ORM\Column(length: 50)]
#[Groups([EntityGroupsInterface::GROUP_GENERAL, EntityGroupsInterface::GROUP_ALL])]
#[
OA\Property(),
ORM\Column(length: 50),
Groups([EntityGroupsInterface::GROUP_GENERAL, EntityGroupsInterface::GROUP_ALL])
]
protected string $song_id;
/** @OA\Property() */
#[ORM\Column(length: 303, nullable: true)]
#[Groups([EntityGroupsInterface::GROUP_GENERAL, EntityGroupsInterface::GROUP_ALL])]
#[
OA\Property,
ORM\Column(length: 303, nullable: true),
Groups([EntityGroupsInterface::GROUP_GENERAL, EntityGroupsInterface::GROUP_ALL])
]
protected ?string $text = null;
/** @OA\Property() */
#[ORM\Column(length: 150, nullable: true)]
#[Groups([EntityGroupsInterface::GROUP_GENERAL, EntityGroupsInterface::GROUP_ALL])]
#[
OA\Property,
ORM\Column(length: 150, nullable: true),
Groups([EntityGroupsInterface::GROUP_GENERAL, EntityGroupsInterface::GROUP_ALL])
]
protected ?string $artist = null;
/** @OA\Property() */
#[ORM\Column(length: 150, nullable: true)]
#[Groups([EntityGroupsInterface::GROUP_GENERAL, EntityGroupsInterface::GROUP_ALL])]
#[
OA\Property,
ORM\Column(length: 150, nullable: true),
Groups([EntityGroupsInterface::GROUP_GENERAL, EntityGroupsInterface::GROUP_ALL])
]
protected ?string $title = null;
public function setSong(SongInterface $song): void

View File

@ -7,19 +7,19 @@ namespace App\Entity\Traits;
use App\Doctrine\Generator\UuidV6Generator;
use App\Entity\Interfaces\EntityGroupsInterface;
use Doctrine\ORM\Mapping as ORM;
use OpenApi\Annotations as OA;
use OpenApi\Attributes as OA;
use RuntimeException;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @OA\Schema(type="object")
*/
#[OA\Schema(type: 'object')]
trait HasUniqueId
{
/** @OA\Property() */
#[ORM\Column(type: 'guid', unique: true, nullable: false)]
#[ORM\Id, ORM\GeneratedValue(strategy: 'CUSTOM'), ORM\CustomIdGenerator(UuidV6Generator::class)]
#[Groups([EntityGroupsInterface::GROUP_ID, EntityGroupsInterface::GROUP_ALL])]
#[
OA\Property,
ORM\Column(type: 'guid', unique: true, nullable: false),
ORM\Id, ORM\GeneratedValue(strategy: 'CUSTOM'), ORM\CustomIdGenerator(UuidV6Generator::class),
Groups([EntityGroupsInterface::GROUP_ID, EntityGroupsInterface::GROUP_ALL])
]
protected ?string $id = null;
public function getId(): ?string

View File

@ -13,7 +13,7 @@ use Azura\Normalizer\Attributes\DeepNormalize;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use OpenApi\Annotations as OA;
use OpenApi\Attributes as OA;
use OTPHP\Factory;
use Stringable;
use Symfony\Component\Serializer\Annotation as Serializer;

View File

@ -1,13 +1,13 @@
<?php
use OpenApi\Annotations as OA;
use OpenApi\Attributes as OA;
#[
OA\OpenApi(
info: new OA\Info(
version: AZURACAST_VERSION,
title: 'AzuraCast',
description: "AzuraCast is a standalone, turnkey web radio management tool. Radio stations hosted by AzuraCast expose a public API for viewing now playing data, making requests and more.",
title: 'AzuraCast',
license: new OA\License(
name: 'Apache 2.0',
url: "http://www.apache.org/licenses/LICENSE-2.0.html"
@ -15,14 +15,10 @@ use OpenApi\Annotations as OA;
),
servers: [
new OA\Server(
description: AZURACAST_API_NAME,
url: AZURACAST_API_URL
url: AZURACAST_API_URL,
description: AZURACAST_API_NAME
),
],
externalDocs: new OA\ExternalDocumentation(
description: "AzuraCast on GitHub",
url: "https://github.com/AzuraCast/AzuraCast"
),
tags: [
new OA\Tag(
name: "Now Playing",
@ -55,18 +51,20 @@ use OpenApi\Annotations as OA;
new OA\Tag(name: "Administration: Storage Locations"),
new OA\Tag(name: "Miscellaneous"),
]
],
externalDocs: new OA\ExternalDocumentation(
description: "AzuraCast on GitHub",
url: "https://github.com/AzuraCast/AzuraCast"
)
),
OA\Parameter(
name: "station_id_required",
in: "path",
required: true,
schema: new OA\Schema(
properties: [
'anyOf' => [
new OA\Schema(type: "integer", format: "int64"),
new OA\Schema(type: "string", format: "string")
]
anyOf: [
new OA\Schema(type: "integer", format: "int64"),
new OA\Schema(type: "string", format: "string"),
]
),
),
@ -75,10 +73,10 @@ use OpenApi\Annotations as OA;
description: "This API call has no documented response (yet)",
),
OA\SecurityScheme(
type: "apiKey",
in: "header",
securityScheme: "api_key",
name: "X-API-Key"
type: "apiKey",
name: "X-API-Key",
in: "header"
)
]
class OpenApi

View File

@ -1,4 +1,4 @@
openapi: 3.0.0
openapi: 3.1.0
info:
title: AzuraCast
description: 'AzuraCast is a standalone, turnkey web radio management tool. Radio stations hosted by AzuraCast expose a public API for viewing now playing data, making requests and more.'
@ -2710,14 +2710,19 @@ components:
properties:
station:
$ref: '#/components/schemas/Api_NowPlaying_Station'
description: Station
listeners:
$ref: '#/components/schemas/Api_NowPlaying_Listeners'
description: 'Listener details'
live:
$ref: '#/components/schemas/Api_NowPlaying_Live'
description: 'Live broadcast details'
now_playing:
$ref: '#/components/schemas/Api_NowPlaying_CurrentSong'
description: 'Current Song'
playing_next:
$ref: '#/components/schemas/Api_NowPlaying_StationQueue'
description: 'Next Playing Song'
song_history:
type: array
items:
@ -2763,6 +2768,7 @@ components:
type: boolean
song:
$ref: '#/components/schemas/Api_Song'
description: Song
type: object
Api_NowPlaying_Station:
properties:
@ -2859,6 +2865,7 @@ components:
type: boolean
song:
$ref: '#/components/schemas/Api_Song'
description: Song
type: object
Api_NowPlaying_StationRemote:
properties:
@ -2885,6 +2892,7 @@ components:
nullable: true
listeners:
$ref: '#/components/schemas/Api_NowPlaying_Listeners'
description: 'Listener details'
type: object
Api_Podcast:
type: object
@ -3033,6 +3041,7 @@ components:
example: /api/station/1/ondemand/download/1
media:
$ref: '#/components/schemas/Api_Song'
description: Song
playlist:
type: string
type: object
@ -3168,6 +3177,7 @@ components:
example: /api/station/1/request/1
song:
$ref: '#/components/schemas/Api_Song'
description: Song
type: object
Api_StationSchedule:
properties: