Giter Site home page Giter Site logo

8.0 versioning does not work about cakephp-api HOT 5 CLOSED

cakedc avatar cakedc commented on August 22, 2024
8.0 versioning does not work

from cakephp-api.

Comments (5)

skie avatar skie commented on August 22, 2024

Please provide configuration config you have to reproduce

from cakephp-api.

Unbekannt1998 avatar Unbekannt1998 commented on August 22, 2024

` <?php
/**

use Authentication\Middleware\AuthenticationMiddleware;
use CakeDC\Api\Middleware\ParseApiRequestMiddleware;
use CakeDC\Api\Middleware\ProcessApiRequestMiddleware;
use CakeDC\Api\ApiInitializer;

return [
'Api' => [
// if service class is not defined we use crud fallback service
'ServiceFallback' => '\CakeDC\Api\Service\FallbackService',
// response rendered as JSend
'renderer' => 'CakeDC/Api.JSend',
// Data parse from cakephp request object
'parser' => 'CakeDC/Api.Form',

    //routes inflector: specify underscore, dasherize, or false for neither/no inflection
    'routesInflectorMethod' => false,

    // version is not used
    'useVersioning' => true,
    'versionPrefix' => 'v',

    // auth permission uses require auth strategy
    'Auth' => [
        'Crud' => [
            'default' => 'auth'
        ],
    ],
    
    'Middleware' => [
        'authentication' => [
            'class' => AuthenticationMiddleware::class,
            'request' => ApiInitializer::class,
            'method' => 'getAuthenticationService',
        ],
        'apiParser' => [
            'class' => ParseApiRequestMiddleware::class,
        ],
        'apiProcessor' => [
            'class' => ProcessApiRequestMiddleware::class,
        ],
    ],

    'Service' => [
        'default' => [
            'options' => [],
            'Action' => [
                'default' => [
                    //auth configuration
                    'Auth' => [
                        //'allow' => '*', // PUBLIC ACCESS for all API endpoints, remove this line to secure
                        'authenticate' => [
                            'CakeDC/Api.Token' => [
                                'require_ssl' => false,
                            ]
                        ],
                    ],
                    // default app extensions
                    'Extension' => [
                        // allow request from other domains
                        'CakeDC/Api.Cors',
                        // enable sort
                        'CakeDC/Api.Sort',
                        // load Hateoas
                        'CakeDC/Api.CrudHateoas',
                        // enable relations
                        'CakeDC/Api.CrudRelations',
                    ]
                ],
                
                // all index actions configuration
                'Index' => [
                    'Extension' => [
                        // enable pagination for index actions
                        'CakeDC/Api.Paginate',
                    ],
                ],
            ],
        ],
    ],
    'Log' => [
        'className' => 'File',
        'scopes' => ['api'],
        'levels' => ['error', 'info'],
        'file' => 'api.log',
    ],
    'Flysystem' => [
        'expire' => '+1 day'
    ]
]

];`

from cakephp-api.

Unbekannt1998 avatar Unbekannt1998 commented on August 22, 2024

Hi,
since there was no more comment and no update do you need more info or am i doing something wrong and nobody told me?
An Update would be nice or at least some info on the status.
Kind Regard

from cakephp-api.

mortinp avatar mortinp commented on August 22, 2024

I'm having the same issue, and it is definitely an issue in the CakeDC\Api\Middleware\ParseApiRequestMiddleware::process() funcion.

The middleware tries to parse the version from the uri path at line 63, and it matches well to "v1" (v1 here is just an example). Then on line 78 it tries to configure the service using "v1" as the value for the 2nd parameter for CakeDC\Api\Service\ConfigReader::serviceOptions() function, which strictly checks the second parameter to be an integer or null.

It ovbiously fails because "v1" is NOT an integer.

There is no way to bypass this check without modifying the plugin's code or copying the middleware's code into another one inside our app, and reconfigure the plugin to use this new middleware.

from cakephp-api.

skie avatar skie commented on August 22, 2024

resolved in 8.0.7

from cakephp-api.

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.