I'm trying to use Swagger-php to create a documentation for API in application I'm working on. I'm want to secure it using JWT so putted a SecurityScheme in my ControllerBase:
/**
* #SWG\SecurityScheme(
* securityDefinition="Bearer",
* bearerFormat="JWT",
* type="apiKey",
* name="Authorization",
* in="header"
* )
*/
And then in my controller I wanted to use it
/**
* #SWG\Get(
* path="/test",
* #SWG\Response(
* response="200",
* description="Returns test data"
* ),
* security={{"Bearer":{}}}
* )
*/
It is loading correctly on my Swagger UI but when I try to execute the request I got an error in response:
Syntax error, unexpected token }, near to '}}
It looks like the correct annotations for Swagger are incorrect for PHP Interpreter. I can change it to
security={{"Bearer":{''}}}
And then the request is working but when I reload the Swagger UI the request doesn't show up there.
Can anyone help me, please?
UPDATE: I was wrong to think that this is a problem with PHP Interpreter. Problem occurs while using Phalcon Annotations. Here is the whole error returned by server.
Syntax error, unexpected token }, near to '}} ) ' in
/var/www/api/api/app/modules/user/controllers/UserController.php on
line 210 [internal function]:
Phalcon\Annotations\Reader->parse('Api\Modules\Use...')
1 [internal function]: Phalcon\Annotations\Adapter->get('Api\Modules\Use...')
2 /var/www/api/api/app/library/ApiManager/ApiAnnotation.php(54): Phalcon\Annotations\Adapter->getMethod('Api\Modules\Use...',
'getAllUsersActi...')
3 /var/www/api/api/app/library/ApiManager/ApiAnnotation.php(41): Api\Library\ApiManager\ApiAnnotation->getFromActiveAction()
4 /var/www/api/api/app/library/AuthGuard/AuthGuard.php(23): Api\Library\ApiManager\ApiAnnotation->__construct()
5 /var/www/api/api/app/controllers/ControllerBase.php(37): Api\Library\AuthGuard\AuthGuard->__construct()
6 [internal function]: Api\Controllers\ControllerBase->initialize()
7 [internal function]: Phalcon\Dispatcher->dispatch()
8 /var/www/api/api/public/index.php(54): Phalcon\Mvc\Application->handle()
9 {main}
Related
An error occurrs while running this module, clustimage. The error refers to the 'embedding' setting when "embedding='tsne'". If I run the code while "embedding='none'", it works fine. The concern is that embedding is very practical for visual purposes and should be used. Any ideas why this error occurs and how to resolve it?
clustimage resource link:
https://erdogant.github.io/clustimage/pages/html/Abstract.html
clustimage module
cl = Clustimage(method='pca',
embedding='tsne',
grayscale=False,
dim=(128,128),
params_pca={'n_components':0.95},
store_to_disk=True,
verbose=50)
_t_sne.py code
update = momentum * update - learning_rate * grad
p += update
error
File "/Users/name/opt/anaconda3/lib/python3.8/site-packages/sklearn/manifold/_t_sne.py", line 372, in _gradient_descent
update = momentum * update - learning_rate * grad
UFuncTypeError: ufunc 'multiply' did not contain a loop with signature matching types (dtype('<U32'), dtype('<U32')) -> dtype('<U32')
The author of clustimage found the answer:
Thank you for reporting! I found the issue: learning_rate='auto' seems the problem. I simply removed the parameter.
Resolved.
I'm trying to use a TCP Socket in an iOS Kotlin/Native common module.
According Apple's documentation, to open a nw_connection_t, you simply need to:
val connection =
nw_parameters_create_secure_tcp(
NW_PARAMETERS_DISABLE_PROTOCOL, // No TLS
NW_PARAMETERS_DEFAULT_CONFIGURATION // Default TCP config
)
However, when I run this module in an iOS Application, I get the following error:
_nw_parameters_configure_protocol_disable_block_invoke _nw_parameters_configure_protocol_disable called directly, dumping backtrace:
[x86_64] libnetcore-1880.120.4
0 libnetwork.dylib 0x00007fff5118d1f8 __nw_create_backtrace_string + 120
1 libnetwork.dylib 0x00007fff5100a898 _nw_parameters_configure_protocol_disable_block_invoke + 120
2 PhoenixShared 0x00000001099af1b5 _70686f656e69783a70686f656e69782d736861726564_knbridge41 + 37
3 PhoenixShared 0x0000000109972eac kfun:fr.acinq.phoenix.io.BlockFunctionImpl16.invoke#internal + 220
4 PhoenixShared 0x0000000109972fbf kfun:fr.acinq.phoenix.io.BlockFunctionImpl16.$<bridge-UNNN>invoke(platform.darwin.NSObject?){}#internal + 95
5 PhoenixShared 0x000000010997342b _70686f656e69783a70686f656e69782d736861726564_knbridge47 + 251
6 libnetwork.dylib 0x00007fff5100d7b6 nw_parameters_create_secure_tcp + 342
...
The parameters.h header in Apple's Network.framework contains:
#define NW_PARAMETERS_DISABLE_PROTOCOL (_nw_parameters_configure_protocol_disable)
...so of course _nw_parameters_configure_protocol_disable is called directly.
Any idea of what I'm doing wrong?
So, it turns out that neither NW_PARAMETERS_DISABLE_PROTOCOL nor NW_PARAMETERS_DEFAULT_CONFIGURATION are meant to be invoked.
Even though they are of block type ^(nw_protocol_options_t), the nw_parameters_create_secure_tcp function uses their pointer adresses as special markers and never actually invokes them.
This is a problem because the Kotlin/Native ObjC-interop layer:
Transformed NW_PARAMETERS_DISABLE_PROTOCOL and NW_PARAMETERS_DEFAULT_CONFIGURATION blocks into Kotlin lambdas.
Wraps the lambdas to convert them back into ObjC blocks when passing them as arguments (as we can see in the question's stack trace lines numbered 3 & 4).
As a result, the actual pointer address of these special blocks is lost, the blocks are called (which they should not), and the failure occurs.
There is no way to address this problem in Kotlin, as the Kotlin version of nw_parameters_create_secure_tcp requests lambda parameters (and not pointers).
A very simple workaround is to create our own layer of interoperability using our own C-interop def file:
package = fr.acinq.phoenix.io.network_framework
language = Objective-C
---
#include <Network/Network.h>
NW_RETURNS_RETAINED nw_parameters_t nw_k_parameters_create_secure_tcp(bool withTls) {
return nw_parameters_create_secure_tcp(
withTls ? NW_PARAMETERS_DEFAULT_CONFIGURATION : NW_PARAMETERS_DISABLE_PROTOCOL,
NW_PARAMETERS_DEFAULT_CONFIGURATION
);
}
This creates an Objective-C nw_k_parameters_create_secure_tcp function (note the nw_k_ prefix) that directly calls the original nw_parameters_create_secure_tcp with the correct parameters, without Kotlin block-to-lambda-to-block layer, which can be correctly called from Kotlin.
i am working in zendframework 2 in conjuction with doctrine 2
i am trying to use the orm:validate-schema to validate and generate tables in my database; i.e match the entity class User with a new table.
i followed the tutorial by marco pivetta
http://marco-pivetta.com/doctrine-orm-zf2-tutorial/#/24
however when i try to open the schema in my git i.e
andreea#Andreea-HP /cygdrive/c/users/andreea/zend/testingZend
./vendor/bin/doctrine-module orm:validate-schema
i get the following message:
Could not open input file:
/cygdrive/c/users/endy/zend/testingZend/vendor/doctrine/doctrine-module/bin/doctrine-module
does anyone have an idea why i am unable to open the page
warm regards
Andreea
hi again
followng the advice of foozi i tried the folllowing:
php public/index.php orm:validate-schema
however, i received the following error message:
Undefined index: APPLICATION_ENV in C:\Users\andreea\zend\testingZend\public\index.php on line 19
Call Stack:
0.0002 235176 1. {main}() C:\Users\andreea\zend\testingZend\public\index.php:0
Zend Framework 2.2.5 application
Usage:
Reason for failure: Invalid arguments or no arguments provided
PHP Notice: Undefined index: APPLICATION_ENV in C:\Users\andreea\zend\testingZend\public\index.php on line 19
PHP Stack trace:
PHP 1. {main}() C:\Users\andreea\zend\testingZend\public\index.php:0
i believe that the message is referring to the followng:
/**
* Display all errors when APPLICATION_ENV is development.
*/
if ('development' === $_SERVER['APPLICATION_ENV']) {
error_reporting(E_ALL);
ini_set("display_errors", 1);
}
would be gratful for some advice
Try to use doctrine command line over your application's index instead of directly doctrine-module binaries (actually both of them does same thing)
$ cd /your/zf2/project
$ php public/index.php orm:validate-schema
This is the way which i prefer.
So I made my own habbo retro, and everything was done. But when I went to check it out, I got this error:
Parse error: syntax error, unexpected T_STRING in C:\Program Files\xampp\htdocs\app\management\config.php on line 37
I checked it out, and this is what I have
/*
*
* Hotel management - All URLs do not end with an "/"
*
*/
$_CONFIG['hotel']['name'] = 'Habbeen'; // Your Hotel's Name
$_CONFIG['hotel']['desc'] = 'If you're bored, come here to feed your hunger.'; //Hotel's description
That is line 37 above this sentence. Why is that error coming up?
I don't know what a habbo retro is but your problem is because of the apostrophe in the "you're", you should escape it like this:" "you\'re"
I am trying to use partials in my layout on ZF2.
I tried few methods (including those that are described here, where a user has to include a partial to the rout in the module config). Every time I am getting the same error.
For example, I am following instructions from the ZF2 documentation: http://framework.zend.com/manual/2.2/en/modules/zend.view.helpers.partial.html#zend-view-helpers-initial-partial
partials.phtml is in the same folder as the layout.phtml. The server (and I tried both, apache and building PHP server) throws an error:
[Fri Jun 14 18:40:34 2013] 127.0.0.1:36616 [500]: / - Uncaught exception 'Zend\ServiceManager\Exception\ServiceNotFoundException' with message
'Zend\View\HelperPluginManager::get was unable to fetch or create an instance for partial' in /var/www/frameworks/ZF2/library/Zend/ServiceManager/ServiceManager.php:496
Stack trace:
#0 /var/www/frameworks/ZF2/library/Zend/ServiceManager/AbstractPluginManager.php(103): Zend\ServiceManager\ServiceManager->get('partial', true)
#1 /var/www/frameworks/ZF2/library/Zend/View/Renderer/PhpRenderer.php(378): Zend\ServiceManager\AbstractPluginManager->get('partial', NULL)
#2 /var/www/frameworks/ZF2/library/Zend/View/Renderer/PhpRenderer.php(397): Zend\View\Renderer\PhpRenderer->plugin('partial')
#3 /var/www/html/zf2.tutorial/module/Application/view/layout/layout.phtml(129): Zend\View\Renderer\PhpRenderer->__call('partial', Array)
#4 /var/www/html/zf2.tutorial/module/Application/view/layout/layout.phtml(129): Zend\View\Renderer\PhpRenderer->partial('partial.phtml', Array)
#5 /var/www/frameworks/ZF2/library/Zend/View/Renderer/PhpRenderer. in /var/www/frameworks/ZF2/library/Zend/ServiceManager/ServiceManager.php on line 496
I am using PHP5.5.0RC3, ZF2.2.1 and Apache 2.2.15
Any suggestions would be appreciated.