Code Monkey home page Code Monkey logo

Comments (5)

eelco2k avatar eelco2k commented on September 7, 2024 1

I was thinking of putting it in a /Virtual/ folder with some empty classes, that way it is separted from actual code. This also means that you can regenerate API docs of one or more resources based on those api docs stubs again and again.

You are absolutely correct that the BRANDS is not okay. it was just an example and can be dynamically fetched from classname of resource.

And yes, an extra static function on the handler class isTenantAwerenessEnabled() is a good idea.

I just posted a rough WiP.. but i will add your considerations :)

from filament-api-service.

rupadana avatar rupadana commented on September 7, 2024

yeah its a good idea, but i think this must be optional. The documentation will generated if developer parse argument, like --swagger maybe. so the artisan command look like php artisan make:filament-api-service BlogResource --swagger.

and i don't like this part define('TENANT_AWARENESS_BRANDS', true);. The BRANDS is make confused. if you want to do this,
we can use resource property on every handler. maybe adding this method to Handlers class :

public static function isTenantAwarenessEnabled() : bool 
{
   return static::getResource()::isScopedToTenant();
}

so you can call it while registering the routes.

from filament-api-service.

eelco2k avatar eelco2k commented on September 7, 2024

first work on swagger generation. I created it as a separate command instead of --swagger option in the filament-api-service for now.

rough work is in this feature branch as pull request #51

from filament-api-service.

POMXARK avatar POMXARK commented on September 7, 2024

thank you for the tools. eelco2k fix it critical errors

        $baseResourceSourcePath =  (string) str($resourceClass)->prepend('/')->prepend(base_path($resourcePath))
            ->replace('\\', '/')->replace('//', '/')
            ->replace('App', 'app'); // default

and

<?php

namespace {{ namespace }}\{{ resourceClass }}\Transformers;


use OpenApi\Attributes as OAT;

#[OAT\Schema(
    schema: "{{ transformerName }}",
    title: "{{ transformerName }}",
    description: "{{ modelClass }} API Transformer",
    xml: new OAT\Xml(name: "{{ transformerName }}"),
)]

->replace('App', 'app')

Xml

It would be nice to add an example of use

php artisan make:filament-resource User
php artisan make:filament-api-service UserResource
php artisan make:filament-api-transformer UserResource

add in UserResource

    /**
     * @return string|null
     */
    public static function getApiTransformer(): ?string
    {
        return UserTransformer::class;
    }
php artisan make:filament-api-docs UserResource
php artisan l5-swagger:generate

I used the package until the patch was accepted

composer require cweagans/composer-patches

and composer,json

    "extra": {
        "laravel": {
            "dont-discover": []
        },
        "patches": {
            "rupadana/filament-api-service": {
                "add command filament-api-docs (for generate swagger)": "patches/rupadana/filament-api-service/filament-api-docs.txt"
            }
        },
        "enable-patching": true
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "source",
        "sort-packages": true,
        "allow-plugins": {
            "pestphp/pest-plugin": true,
            "php-http/discovery": true,
            "cweagans/composer-patches": true
        }
    },

filament-api-docs.txt

Thanks for the work. Good luck in your development!

from filament-api-service.

eelco2k avatar eelco2k commented on September 7, 2024

@POMXARK I've added your patches. hopefully everything works now.

from filament-api-service.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.