senskysh / swagger-processors
v0.1.1
2025-03-19 19:54 UTC
Requires
- php: >=8.1
- zircote/swagger-php: ^3.2.0 || ^4.0.0
Requires (Dev)
- phpunit/phpunit: ^11.5
This package is auto-updated.
Last update: 2025-07-13 18:01:28 UTC
README
-
AddSchemaToQueryParameters
Добавляет свойства схемы как query параметры
Пример:#[Schema( properties: [ new Property(property: 'page', type: 'integer', default: 1), new Property(property: 'perPage', type: 'integer', default: 50) ] )] class Pagination{...} #[Get( path: "/api/v1/posts", x: [ AddSchemaToQueryParameters::REF => [Pagination::class] ] )]
Преобразуется в
#[Get( path: "/api/v1/posts", parameters: [ new Parameter(name: 'page', in: 'query', schema: new Schema(type: 'integer', default: 1)), new Parameter(name: 'perPage', in: 'query', schema: new Schema(type: 'integer', default: 50)), ] )]
-
EnsureRequiredProperties
Проставляет в схему обязательность свойства
Пример:#[Schema( properties: [ new Property(property: 'requiredProp1', type: 'integer'), new Property(property: 'requiredProp2', type: 'integer'), new Property(property: 'requiredProp3', type: 'integer'), new Property(property: 'nonRequiredProp', type: 'integer', nullable: true) ] )]
Преобразуется в
#[Schema( required: ['requiredProp1', 'requiredProp2', 'requiredProp3'], properties: [ new Property(property: 'requiredProp1', type: 'integer'), new Property(property: 'requiredProp2', type: 'integer'), new Property(property: 'requiredProp3', type: 'integer'), new Property(property: 'nonRequiredProp', type: 'integer', nullable: true) ] )]
-
GenerateSchemaProperties
Добавляет аннотации свойств публичным свойствам класса с атрибутом GenerateSchema
Пример:#[GenerateSchema] class Pagination { public function __construct( public int $page = 1, public int $perPage = 50, ) { } }
Преобразуется в
#[Schema] class Pagination { public function __construct( #[Property] public int $page = 1, #[Property] public int $perPage = 50, ) { } }