danthedev/laravel-typescript-transformer-api 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

danthedev/laravel-typescript-transformer-api

最新稳定版本:v1.3.0

Composer 安装命令:

composer require danthedev/laravel-typescript-transformer-api

包简介

Extension of `spatie/laravel-typescript-transformer` with improvements to work with API Requests and Responses

README 文档

README

This package is an extension of spatie/laravel-typescript-transformer that offers two pairs of Collector and Transformer that can be used with spatie/laravel-typescript-transformer via the command php artisan typescript:transform:

  • the Request set allow you to transform all sublasses of Illuminate\Http\Request or Illuminate\Foundation\Http\FormRequest - to achieve this, you need:
    • the RequestCollector (\Danthedev\LaravelTypescriptTransformerApi\Collectors\RequestCollector)
    • the RequestTransformer (\Danthedev\LaravelTypescriptTransformerApi\Transformers\RequestTransformer)
  • the Response set allow you to transform all sublasses of Illuminate\Http\Response - to achieve this, you need:
    • the ResponseCollector (\Danthedev\LaravelTypescriptTransformerApi\Collectors\ResponseCollector)
    • the ResponseTransformer (\Danthedev\LaravelTypescriptTransformerApi\Transformers\ResponseTransformer)

You can install the package via composer:

composer require danthedev/laravel-typescript-transformer-api

Requirements

* laravel 9+
* Php 8.1+
* spatie/laravel-typescript-transformer: ^2.1 [https://github.com/spatie/laravel-typescript-transformer]

Usage

Build your Api extending Request and Response Illumante classes, then automatically transform them in Typescript types.


Apply collectors and transformers to your typescript-transformer.php config file (we suggest you put them before spatie/laravel-typescript-transformer collectors and transformars - order is not important between our classes, instead).

// config/typescript-transformer.php

return [
    // ...
    'collectors' => [
        \Danthedev\LaravelTypescriptTransformerApi\Collectors\RequestCollector::class,
        \Danthedev\LaravelTypescriptTransformerApi\Collectors\ResponseCollector::class,

        // ...
    ],
    'transformers' => [
        \Danthedev\LaravelTypescriptTransformerApi\Transformers\RequestTransformer::class,
        \Danthedev\LaravelTypescriptTransformerApi\Transformers\ResponseTransformer::class,

        // ...
    ],
    // ...
];

Run command php artisan typescript:transform to transform to Typescript types all your Api Request and Response objects.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 2.79k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-12-17